From 4ec07602aaa349adb7ad99e04c33067375e8e734 Mon Sep 17 00:00:00 2001 From: svs-odoo Date: Mon, 18 May 2020 15:35:08 +0000 Subject: [PATCH] [FIX] product_expiry: update quantity on hand Before this commit, when the user tries to create a new quant, even if the product doesn't use an expiration date, he/she will not be able to create the quant. The issue was as `removal_date` field is added by `product_expiry` in the quant list view, the field is on the values used to create a new quant but not in the list of accepted field for quant creation. So, it raises an UserError. task-2260085 closes odoo/odoo#51482 Signed-off-by: Simon Lejeune (sle) --- addons/product_expiry/models/stock_quant.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/product_expiry/models/stock_quant.py b/addons/product_expiry/models/stock_quant.py index af036fcdc3c..1a5ce2f6b17 100644 --- a/addons/product_expiry/models/stock_quant.py +++ b/addons/product_expiry/models/stock_quant.py @@ -9,6 +9,14 @@ class StockQuant(models.Model): removal_date = fields.Datetime(related='lot_id.removal_date', store=True, readonly=False) + @api.model + def _get_inventory_fields_create(self): + """ Returns a list of fields user can edit when he want to create a quant in `inventory_mode`. + """ + res = super()._get_inventory_fields_create() + res += ['removal_date'] + return res + @api.model def _get_removal_strategy_order(self, removal_strategy): if removal_strategy == 'fefo':