From 142e8fca2e0fe9d74e98c3b1e324dff4a43c922a Mon Sep 17 00:00:00 2001 From: Darshil Trivedi Date: Fri, 16 Feb 2018 17:53:18 +0530 Subject: [PATCH] [IMP] purchase: create purchase order without any purchase order lines. On purchase orders, the scheduled date is mantadory. This date is computed from the purchase order lines and hidden. If there is no purchase order line, the date stays empty and it's not possible to save the PO. This commit uses the order date as scheduled date if there are no PO lines --- addons/purchase/models/purchase.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index 7af71e14f43..01827138000 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -32,7 +32,7 @@ class PurchaseOrder(models.Model): 'amount_total': amount_untaxed + amount_tax, }) - @api.depends('order_line.date_planned') + @api.depends('order_line.date_planned', 'date_order') def _compute_date_planned(self): for order in self: min_date = False @@ -41,6 +41,8 @@ class PurchaseOrder(models.Model): min_date = line.date_planned if min_date: order.date_planned = min_date + else: + order.date_planned = order.date_order @api.depends('state', 'order_line.qty_invoiced', 'order_line.qty_received', 'order_line.product_qty') def _get_invoiced(self):