From 37f3d08c18549c4943ae986bc461204f255fb437 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Tue, 2 Jun 2015 12:07:50 +0200 Subject: [PATCH] [IMP] Add a way to bypass check on dropshipping with both invoice policies on delivery. This improve #6824 as it procures no way to implement the missed feature and bypass the check. --- .../stock_dropshipping/stock_dropshipping.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/addons/stock_dropshipping/stock_dropshipping.py b/addons/stock_dropshipping/stock_dropshipping.py index 0d29448dd5f..a41760820e3 100644 --- a/addons/stock_dropshipping/stock_dropshipping.py +++ b/addons/stock_dropshipping/stock_dropshipping.py @@ -26,11 +26,20 @@ class sale_order_line(models.Model): class purchase_order(models.Model): _inherit = 'purchase.order' + @api.one + def _check_invoice_policy(self): + if self.invoice_method == 'picking' and self.location_id.usage == 'customer': + for proc in self.order_line.mapped('procurement_ids'): + if proc.sale_line_id.order_id.order_policy == 'picking': + raise Warning(_('In the case of a dropship route, it is not possible to have an invoicing control set on "Based on incoming shipments" and a sale order with an invoice creation on "On Delivery Order"')) + @api.multi def wkf_confirm_order(self): - for po in self: - if po.invoice_method == 'picking' and po.location_id.usage == 'customer': - for proc in po.order_line.mapped('procurement_ids'): - if proc.sale_line_id.order_id.order_policy == 'picking': - raise Warning(_('In the case of a dropship route, it is not possible to have an invoicing control set on "Based on incoming shipments" and a sale order with an invoice creation on "On Delivery Order"')) + """ Raise a warning to forbid to have both purchase and sale invoices + policies at delivery in dropshipping. As it is not implemented. + + This check can be disabled setting 'no_invoice_policy_check' in context + """ + if not self.env.context.get('no_invoice_policy_check'): + self._check_invoice_policy() super(purchase_order, self).wkf_confirm_order()