From a7915f0ef75caceac31fbcb78cdcb5ac6c2d095e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 15 Nov 2020 23:55:06 +0100 Subject: [PATCH] Allow drop shipment's effective date to be defined issue9787 review318701002 --- CHANGELOG | 1 + stock.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f65cce04a4..906527722c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Allow drop shipment's effective date to be defined * Add relate from party to drop shipments Version 5.8.0 - 2020-11-02 diff --git a/stock.py b/stock.py index abcbbe4d30..941453871a 100644 --- a/stock.py +++ b/stock.py @@ -89,7 +89,13 @@ class ShipmentDrop(Workflow, ModelSQL, ModelView): "Drop Shipment" __name__ = 'stock.shipment.drop' - effective_date = fields.Date('Effective Date', readonly=True) + effective_date = fields.Date( + "Effective Date", + states={ + 'readonly': Eval('state').in_(['cancelled', 'done']), + }, + depends=['state'], + help="When the stock was actually sent.") planned_date = fields.Date('Planned Date', states={ 'readonly': Eval('state') != 'draft', }, depends=['state']) @@ -556,7 +562,7 @@ class ShipmentDrop(Workflow, ModelSQL, ModelView): Move = pool.get('stock.move') Date = pool.get('ir.date') Move.do([m for s in shipments for m in s.customer_moves]) - cls.write(shipments, { + cls.write([s for s in shipments if not s.effective_date], { 'effective_date': Date.today(), })