我想从stock.picking
模型计算所包含的总税款。这是我的代码:
@api.multi
@api.depends('move_lines', 'move_lines.product_qty',
'move_lines.product_uos_qty')
def _amount_all(self):
print '_amount_all dans StockPicking'
for picking in self:
picking.amount_untaxed = 0.0
picking.amount_total = 0.0
val2 = val1 = val = 0.0
for line in picking.move_lines:
print line.product_id.id
# using to get product taxes
taxes=self.env['account.tax'].compute_all(line.price_unit,line.product_uom_qty,line.product_id.id)
print taxes
val1 += taxes['total']
val += taxes['total_included']
for tax in taxes['taxes']:
val2 += tax.get('amount', 0.0)
picking.amount_untaxed = val1
picking.amount_tax = val2
picking.amount_total = val
但是行taxes=self.env['account.tax'].compute_all(line.price_unit,line.product_uom_qty,line.product_id.id)
始终返回空税。
注意:从报价单中我可以获得税额。