diff --git a/CHANGELOG b/CHANGELOG index f3729481c6..b8538d421c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Allow to override the stock moves used to compute the account move + Version 3.4.0 - 2014-10-20 * Bug fixes (see mercurial logs for details) * Add account stock method on fiscal year diff --git a/invoice.py b/invoice.py index 54a0fafc97..424f8258c3 100644 --- a/invoice.py +++ b/invoice.py @@ -46,11 +46,18 @@ class InvoiceLine: result.append(move_line) return result + @property + def _anglo_saxon_stock_moves(self): + pool = Pool() + PurchaseLine = pool.get('purchase.line') + SaleLine = pool.get('sale.line') + if isinstance(self.origin, (PurchaseLine, SaleLine)): + return list(self.origin.moves) + return [] + def get_move_line(self): pool = Pool() Move = pool.get('stock.move') - PurchaseLine = pool.get('purchase.line') - SaleLine = pool.get('sale.line') Period = pool.get('account.period') result = super(InvoiceLine, self).get_move_line() @@ -69,11 +76,9 @@ class InvoiceLine: if period.fiscalyear.account_stock_method != 'anglo_saxon': return result - moves = [] - # other types will get current cost price - if isinstance(self.origin, (PurchaseLine, SaleLine)): - moves = [move for move in self.origin.moves - if move.state == 'done'] + # an empty list means we'll use the current cost price + moves = [move for move in self._anglo_saxon_stock_moves + if move.state == 'done'] if self.invoice.type == 'in_invoice': type_ = 'in_supplier' elif self.invoice.type == 'out_invoice':