From 475abff87be98d860bee408bd011e93a2da3a73a Mon Sep 17 00:00:00 2001 From: Victor Feyens Date: Wed, 1 Apr 2020 18:01:47 +0200 Subject: [PATCH] [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 --- addons/hr_expense/models/product_template.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/addons/hr_expense/models/product_template.py b/addons/hr_expense/models/product_template.py index 25c4719a612..614c02898b5 100644 --- a/addons/hr_expense/models/product_template.py +++ b/addons/hr_expense/models/product_template.py @@ -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):