From 55e3ba33dfa54028fb4fae8cbe3867b1a972a6a8 Mon Sep 17 00:00:00 2001 From: Guillem Barba Date: Thu, 3 Apr 2014 18:52:42 +0200 Subject: [PATCH] Fix cancel invoice+reinvoice moves --- purchase.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/purchase.py b/purchase.py index 4f76b4a..2077dd1 100644 --- a/purchase.py +++ b/purchase.py @@ -22,7 +22,7 @@ class StockMove: if self.from_openerp_to_invoice: return 0.0 return self.quantity - return super(StockMove, self).invoiced_quantity() + return super(StockMove, self).invoiced_quantity class Purchase: @@ -49,10 +49,27 @@ class Purchase: return 'paid' return state + @classmethod + def copy(cls, purchases, default=None): + if default is None: + default = {} + else: + default = default.copy() + default['from_openerp'] = False + return super(Purchase, cls).copy(purchases, default=default) + class PurchaseLine: __name__ = 'purchase.line' + def get_move(self): + move = super(PurchaseLine, self).get_move() + if move and self.purchase.from_openerp: + move.from_openerp = True + if self.purchase.invoice_method == 'shipment': + move.from_openerp_to_invoice = True + return move + def get_invoice_line(self, invoice_type): pool = Pool() InvoiceLine = pool.get('account.invoice.line')