From 25b6dd6e882ecd29c746921aac75b957d3597750 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 21 Jun 2018 08:42:40 +0200 Subject: [PATCH 1/2] [FIX] sale_mrp, sale_stock: sort moves `sorted` returns a new sorted recordset, but doesn't modify the actual one. Therefore, the current code doesn't work as expected. opw-1824734 --- addons/sale_mrp/sale_mrp.py | 5 +---- addons/sale_stock/sale_stock.py | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/addons/sale_mrp/sale_mrp.py b/addons/sale_mrp/sale_mrp.py index 5e5640f7a5b..6af99b787a1 100644 --- a/addons/sale_mrp/sale_mrp.py +++ b/addons/sale_mrp/sale_mrp.py @@ -125,10 +125,7 @@ class AccountInvoiceLine(models.Model): qty_done = sum([uom_obj._compute_qty_obj(x.uom_id, x.quantity, x.product_id.uom_id) for x in s_line.invoice_lines if x.invoice_id.state in ('open', 'paid')]) quantity = uom_obj._compute_qty_obj(self.uom_id, self.quantity, self.product_id.uom_id) # Put moves in fixed order by date executed - moves = self.env['stock.move'] - for procurement in s_line.procurement_ids: - moves |= procurement.move_ids - moves.sorted(lambda x: x.date) + moves = s_line.mapped('procurement_ids.move_ids').sorted(lambda x: x.date) # Go through all the moves and do nothing until you get to qty_done # Beyond qty_done we need to calculate the average of the price_unit # on the moves we encounter. diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py index 9ef92b7ee3d..eaac072f61a 100644 --- a/addons/sale_stock/sale_stock.py +++ b/addons/sale_stock/sale_stock.py @@ -329,10 +329,7 @@ class AccountInvoiceLine(models.Model): qty_done = sum([uom_obj._compute_qty_obj(x.uom_id, x.quantity, x.product_id.uom_id) for x in s_line.invoice_lines if x.invoice_id.state in ('open', 'paid')]) quantity = uom_obj._compute_qty_obj(self.uom_id, self.quantity, self.product_id.uom_id) # Put moves in fixed order by date executed - moves = self.env['stock.move'] - for procurement in s_line.procurement_ids: - moves |= procurement.move_ids - moves.sorted(lambda x: x.date) + moves = s_line.mapped('procurement_ids.move_ids').sorted(lambda x: x.date) # Go through all the moves and do nothing until you get to qty_done # Beyond qty_done we need to calculate the average of the price_unit # on the moves we encounter. From 22084bc52edf4fe620e33aed675a4464ef95f8f1 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 14 Jun 2018 14:21:02 +0200 Subject: [PATCH 2/2] [FIX] website_quote: token assignation Speed up assignation of initial access tokens for large databases. opw-1856946 --- addons/website_quote/models/order.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/addons/website_quote/models/order.py b/addons/website_quote/models/order.py index 72852c2a083..b6af2b227cc 100644 --- a/addons/website_quote/models/order.py +++ b/addons/website_quote/models/order.py @@ -314,6 +314,17 @@ class sale_order(osv.osv): def _get_payment_type(self, cr, uid, ids, context=None): return 'form' + def _set_default_value_on_column(self, cr, column_name, context=None): + if column_name != 'access_token': + super(sale_order, self)._set_default_value_on_column(cr, column_name, context=context) + else: + query = """UPDATE %(table_name)s + SET %(column_name)s = md5(random()::text || clock_timestamp()::text)::uuid + WHERE %(column_name)s IS NULL + """ % {'table_name': self._table, 'column_name': column_name} + cr.execute(query) + + class sale_quote_option(osv.osv): _name = "sale.quote.option" _description = "Quotation Option"