pycharm-odoo
pycharm-odoo copied to clipboard
Support complex selection value expression
The Odoo plugin is currently unable to understand the following selection value expression:
SERVICE_POLICY = [
# (service_policy, (invoice_policy, service_type), string)
('ordered_timesheet', ('order', 'timesheet'), 'Prepaid/Fixed Price'),
('delivered_timesheet', ('delivery', 'timesheet'), 'Based on Timesheets'),
('delivered_manual', ('delivery', 'manual'), 'Based on Milestones'),
]
SERVICE_TO_GENERAL = {policy[0]: policy[1] for policy in SERVICE_POLICY}
GENERAL_TO_SERVICE = {policy[1]: policy[0] for policy in SERVICE_POLICY}
class ProductTemplate(models.Model):
_inherit = 'product.template'
service_policy = fields.Selection([
(policy[0], policy[2]) for policy in SERVICE_POLICY
], string="Service Invoicing Policy", compute='_compute_service_policy', inverse='_inverse_service_policy')
https://github.com/odoo/odoo/blob/4d184bc6ca3b1308ffd7c890928b1c3244f89d45/addons/sale_timesheet/models/product.py#L22
https://github.com/odoo/odoo/blob/800e175c5bc5d8ba23265c69c5c2cab6957fc73a/odoo/addons/base/models/ir_asset.py#L77