Impacted modules:
hr, hr_contract, hr_recruitment, hr_payroll, fleet, hr_skills, hr_appraisal, ....
Several onchanges have been converted to computed fields in the following modules :
Community :
- hr
- hr_contract
- hr_recruitment
- hr_work_entry
- hr_maintenance
- hr_expense
- hr_expense_check
- hr_holidays
- sale_expense
- account_analytic_default_hr_expense
Enterprise:
- hr_contract_salary
- hr_referral
- hr_payroll
- hr_payroll_expense
- test_l10n_be_hr_payroll_account
There are still 2 onchanges with complex behavior that couldn't be converted easily:
- an onchange that updates "tz" (timezone) that is defined as a related field
to "resource_id.tz". Apparently it is useless except to initialize the default
value of "tz".
- an onchange that updates "name" that is defined as a related field to
"resource_id.name".
the applicant.
closes odoo/odoo#45414
Taskid: 2169099
Related: odoo/enterprise#8572
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
25 lines
956 B
Python
25 lines
956 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, fields, models
|
|
|
|
|
|
class ProductTemplate(models.Model):
|
|
_inherit = "product.template"
|
|
|
|
can_be_expensed = fields.Boolean(string="Can be Expensed", compute='_compute_can_be_expensed',
|
|
store=True, readonly=False, help="Specify whether the product can be selected in an expense.")
|
|
|
|
@api.model_create_multi
|
|
def create(self, vals_list):
|
|
for vals in vals_list:
|
|
# When creating an expense product on the fly, you don't expect to
|
|
# have taxes on it
|
|
if vals.get('can_be_expensed', False):
|
|
vals.update({'supplier_taxes_id': False})
|
|
return super(ProductTemplate, self).create(vals_list)
|
|
|
|
@api.depends('type')
|
|
def _compute_can_be_expensed(self):
|
|
self.filtered(lambda p: p.type not in ['consu', 'service']).update({'can_be_expensed': False})
|