[IMP] hr_expense: create products in batch
Products are created in batch, unless hr_expense is installed, because its create override isn't defined and implemented for batch creation. Because products creation in batch can be up to 10 times faster than creation record by record, it is important to ensure the creation of products is always done in batch. X-original-commit: e8e34ed5b66274264c27e9a379a7857e086e5264
This commit is contained in:
@@ -9,13 +9,14 @@ class ProductTemplate(models.Model):
|
||||
|
||||
can_be_expensed = fields.Boolean(string="Can be Expensed", help="Specify whether the product can be selected in an expense.")
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
# 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)
|
||||
@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.onchange('type')
|
||||
def _onchange_type_for_expense(self):
|
||||
|
||||
Reference in New Issue
Block a user