From 9ab18cd149fccbd844e075caf25e7239c2939dde Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 18 Dec 2014 17:33:51 +0100 Subject: [PATCH] [FIX] account_anglo_saxon: keep reference to stock.move on invoice line When an invoice is created from a picking keep a reference to the stock.move to use the right price for the COGS entry. This used to be done by the _prepare_invoice_line method but it was removed during WMS refactoring, replacing by the brand new _get_invoice_line_vals method! opw 615263 --- addons/account_anglo_saxon/stock.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/addons/account_anglo_saxon/stock.py b/addons/account_anglo_saxon/stock.py index cfa35b47627..37dab7b4b86 100644 --- a/addons/account_anglo_saxon/stock.py +++ b/addons/account_anglo_saxon/stock.py @@ -21,22 +21,25 @@ from openerp.osv import osv -#---------------------------------------------------------- -# Stock Picking -#---------------------------------------------------------- +class stock_move(osv.Model): + _inherit = "stock.move" + + def _get_invoice_line_vals(self, cr, uid, move, partner, inv_type, context=None): + """ Add a reference to the stock.move in the invoice line + + In anglo-saxon the price for COGS should be taken from stock.move + if possible (fallback on standard_price) + """ + res = super(stock_move, self)._get_invoice_line_vals(cr, uid, move, partner, inv_type, context=context) + res.update({ + 'move_id': move.id, + }) + return res + class stock_picking(osv.osv): _inherit = "stock.picking" _description = "Picking List" - def _prepare_invoice_line(self, cr, uid, group, picking, move_line, invoice_id, - invoice_vals, context=None): - """Overwrite to add move_id reference""" - res = super(stock_picking, self)._prepare_invoice_line(cr, uid, group, picking, move_line, invoice_id, invoice_vals, context=context) - res.update({ - 'move_id': move_line.id, - }) - return res - def action_invoice_create(self, cr, uid, ids, journal_id=False, group=False, type='out_invoice', context=None): '''Return ids of created invoices for the pickings'''