From eb6ddb6e9f7dea3a1251e59aca3f05488f661c70 Mon Sep 17 00:00:00 2001 From: yhu-odoo Date: Mon, 27 Apr 2020 14:30:32 +0000 Subject: [PATCH] [FIX] purchase_stock: old PO not update qty_received after install purchase_stock Before this commit, after install purchase_stock, old pol records won't update their qty_received when receive products. This is because their qty_received_method are not updated during the installation. Task 2230811 PR #49921 --- addons/purchase_stock/data/purchase_stock_data.xml | 2 ++ addons/purchase_stock/models/purchase.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/addons/purchase_stock/data/purchase_stock_data.xml b/addons/purchase_stock/data/purchase_stock_data.xml index 431147a5b01..859d4cc1c63 100644 --- a/addons/purchase_stock/data/purchase_stock_data.xml +++ b/addons/purchase_stock/data/purchase_stock_data.xml @@ -2,6 +2,8 @@ + + diff --git a/addons/purchase_stock/models/purchase.py b/addons/purchase_stock/models/purchase.py index 2651107d036..bfff1567238 100644 --- a/addons/purchase_stock/models/purchase.py +++ b/addons/purchase_stock/models/purchase.py @@ -510,3 +510,8 @@ class PurchaseOrderLine(models.Model): incoming_moves |= move return outgoing_moves, incoming_moves + + @api.model + def _update_qty_received_method(self): + """Update qty_received_method for old PO before install this module.""" + self.search([])._compute_qty_received_method()