[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
This commit is contained in:
parent
74f18581f1
commit
9ab18cd149
|
@ -21,22 +21,25 @@
|
||||||
|
|
||||||
from openerp.osv import osv
|
from openerp.osv import osv
|
||||||
|
|
||||||
#----------------------------------------------------------
|
class stock_move(osv.Model):
|
||||||
# Stock Picking
|
_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):
|
class stock_picking(osv.osv):
|
||||||
_inherit = "stock.picking"
|
_inherit = "stock.picking"
|
||||||
_description = "Picking List"
|
_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,
|
def action_invoice_create(self, cr, uid, ids, journal_id=False,
|
||||||
group=False, type='out_invoice', context=None):
|
group=False, type='out_invoice', context=None):
|
||||||
'''Return ids of created invoices for the pickings'''
|
'''Return ids of created invoices for the pickings'''
|
||||||
|
|
Loading…
Reference in New Issue