[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.

This commit is contained in:
Yannick Vaucher 2015-06-02 12:07:50 +02:00 committed by Nicolas Martinelli
parent eabf7df5f9
commit 37f3d08c18
1 changed files with 14 additions and 5 deletions

View File

@ -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()