[FIX] stock_account: fix dependencies

Purchase and Sale are not part of the dependencies of stock_account, so purchase_line_id
and sale_line_id might not exist.

Fixes #6619
This commit is contained in:
Nicolas Martinelli 2015-05-12 16:11:33 +02:00
parent 3e14a4ee5e
commit 769fc81140
4 changed files with 11 additions and 5 deletions

View File

@ -156,6 +156,10 @@ class stock_move(osv.osv):
return self.write(cr, uid, [move.id], {'price_unit': price}, context=context)
super(stock_move, self).attribute_price(cr, uid, move, context=context)
def _get_taxes(self, cr, uid, move, context=None):
if move.origin_returned_move_id.purchase_line_id.taxes_id:
return [tax.id for tax in move.origin_returned_move_id.purchase_line_id.taxes_id]
return super(stock_move, self)._get_taxes(cr, uid, move, context=context)
class stock_picking(osv.osv):
_inherit = 'stock.picking'

View File

@ -413,6 +413,10 @@ class stock_move(osv.osv):
extra_move_tax[move.picking_id, move.product_id] = [(6, 0, [x.id for x in move.procurement_id.sale_line_id.tax_id])]
return (is_extra_move, extra_move_tax)
def _get_taxes(self, cr, uid, move, context=None):
if move.procurement_id.sale_line_id.tax_id:
return [tax.id for tax in move.procurement_id.sale_line_id.tax_id]
return super(stock_move, self)._get_taxes(cr, uid, move, context=context)
class stock_location_route(osv.osv):
_inherit = "stock.location.route"

View File

@ -2555,6 +2555,8 @@ class stock_move(osv.osv):
code = 'incoming'
return code
def _get_taxes(self, cr, uid, move, context=None):
return []
class stock_inventory(osv.osv):
_name = "stock.inventory"

View File

@ -152,11 +152,7 @@ class stock_move(osv.osv):
uos_id = move.product_uos.id
quantity = move.product_uos_qty
taxes_ids = []
if move.origin_returned_move_id.purchase_line_id.taxes_id:
taxes_ids = [tax.id for tax in move.origin_returned_move_id.purchase_line_id.taxes_id]
elif move.procurement_id.sale_line_id.tax_id:
taxes_ids = [tax.id for tax in move.procurement_id.sale_line_id.tax_id]
taxes_ids = self._get_taxes(cr, uid, move, context=context)
return {
'name': move.name,