[FW][IMP] *: keep batch records creation for better performance.
`Products` and `Stock Move Lines` are main models, for which the creation is batch happens frequently. Their creation in batch shouldn't be split because of one "create single" override. closes odoo/odoo#48874 Forward-port-of: odoo/odoo#48838 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
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):
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class StockMoveLine(models.Model):
|
||||
_inherit = 'stock.move.line'
|
||||
|
||||
def create(self, values):
|
||||
records = super(StockMoveLine, self).create(values)
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
records = super(StockMoveLine, self).create(vals_list)
|
||||
records.filtered(lambda ml: ml.move_id.is_subcontract).move_id._check_overprocessed_subcontract_qty()
|
||||
return records
|
||||
|
||||
|
||||
Reference in New Issue
Block a user