From a136b4c29a9b40353d837f44b7f19ace993181f5 Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Fri, 6 Sep 2019 15:26:34 +0000 Subject: [PATCH] [FIX] stock: transfers calendar view There's no readonly possibility on the calendar view so the only way to prevent updating a done or cancelled transfer is to raise on the write. We should to raise in the inverse function so that it is possible to bypass the constraint by writing directly on the move, as we want to change some date in the demo data. closes odoo/odoo#36550 Signed-off-by: Simon Lejeune (sle) --- addons/stock/data/stock_demo2.xml | 18 +++++++++++++++--- addons/stock/models/stock_picking.py | 2 ++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/addons/stock/data/stock_demo2.xml b/addons/stock/data/stock_demo2.xml index 5335ea12533..c9ef3c1868a 100644 --- a/addons/stock/data/stock_demo2.xml +++ b/addons/stock/data/stock_demo2.xml @@ -535,18 +535,30 @@ - - - + + + + + + + + + + + + + + + diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index 4af5eeb1a6b..f58b74cb27d 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -449,6 +449,8 @@ class Picking(models.Model): def _set_scheduled_date(self): for picking in self: + if picking.state in ('done', 'cancel'): + raise UserError(_("You cannot change the Scheduled Date on a done or cancelled transfer.")) picking.move_lines.write({'date_expected': picking.scheduled_date}) def _has_scrap_move(self):