[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) <sle@openerp.com>
This commit is contained in:
Simon Lejeune
2019-09-09 08:09:35 +00:00
parent cc505b4b57
commit a136b4c29a
2 changed files with 17 additions and 3 deletions
+15 -3
View File
@@ -535,18 +535,30 @@
<record id="stock.outgoing_shipment_main_warehouse4" model="stock.picking">
<field name="date_done" eval="DateTime.today() - timedelta(days=24)"/>
<field name="scheduled_date" eval="DateTime.today() - timedelta(days=26)"/>
</record>
<record id="stock.outgoing_shipment_main_warehouse5" model="stock.picking">
<field name="date_done" eval="DateTime.today() - timedelta(days=17)"/>
<field name="scheduled_date" eval="DateTime.today() - timedelta(days=18)"/>
</record>
<record id="stock.outgoing_shipment_main_warehouse6" model="stock.picking">
<field name="date_done" eval="DateTime.today() - timedelta(days=7)"/>
<field name="scheduled_date" eval="DateTime.today() - timedelta(days=7)"/>
</record>
<function model="stock.move" name="write">
<value model="stock.move" search="[('picking_id', '=', ref('stock.outgoing_shipment_main_warehouse4'))]"/>
<value eval="{'date_expected': DateTime.today() - timedelta(days=26)}"/>
</function>
<function model="stock.move" name="write">
<value model="stock.move" search="[('picking_id', '=', ref('stock.outgoing_shipment_main_warehouse5'))]"/>
<value eval="{'date_expected': DateTime.today() - timedelta(days=18)}"/>
</function>
<function model="stock.move" name="write">
<value model="stock.move" search="[('picking_id', '=', ref('stock.outgoing_shipment_main_warehouse6'))]"/>
<value eval="{'date_expected': DateTime.today() - timedelta(days=7)}"/>
</function>
</data>
</odoo>
+2
View File
@@ -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):