[FIX] purchase: set all dates and not-stored field (9.0 only)

The feature "set all date to all order line" on a purchase order allow
user to update the schedulded date of all order lines.

It was backported in 9.0 with 401a3cfa but in 9.0 date_planned was not
stored, the button would wrongly set the scheduled dates of the lines to
the minimum date.

With this commit the functionality should work as expected, unless
someone use an out-of-date template in which case the functionnality is
disabled.

opw-697680

note: PO date_planned is stored after 9.0 so this commit must not be
forward-ported.
This commit is contained in:
Nicolas Lempereur
2016-12-14 07:41:01 +01:00
parent d1eca511a8
commit 2d0ff8afa4
2 changed files with 6 additions and 3 deletions
+5 -2
View File
@@ -441,10 +441,13 @@ class PurchaseOrder(models.Model):
@api.multi
def action_set_date_planned(self):
# implementation for 9.0 where PO date_planned is not stored
date_planned = self.env.context.get('date_planned')
if not date_planned:
return
for order in self:
#DO NOT FORWARD PORT
for line in order.order_line:
line.update({'date_planned': order.date_planned})
line.update({'date_planned': date_planned})
class PurchaseOrderLine(models.Model):
+1 -1
View File
@@ -252,7 +252,7 @@
<label for="date_planned"/>
<div>
<field name="date_planned" required="1" attrs="{'readonly': [('state', 'not in', ('draft', 'sent'))]}"/>
<button name="action_set_date_planned" type="object"
<button name="action_set_date_planned" context="{'date_planned': date_planned}" type="object"
states="draft,sent"
string="Set date to all order lines"
help="This changes the scheduled date of all order lines to the given date"