[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:
Victor Feyens
2020-04-02 13:53:04 +02:00
parent 6576aedc0d
commit 475abff87b
+8 -7
View File
@@ -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):