[英]odoo10 how to inherit other function and update line?
如果我想修改采購訂單的計算,現在我正在嘗試采購模塊上的代碼?
這段代碼是關於計算的。
@api.depends('order_line.price_total')
def _amount_all(self):
for order in self:
amount_untaxed = amount_tax = 0.0
for line in order.order_line:
amount_untaxed += line.price_subtotal
# FORWARDPORT UP TO 10.0
if order.company_id.tax_calculation_rounding_method == 'round_globally':
taxes = line.taxes_id.compute_all(line.price_unit, line.order_id.currency_id, line.product_qty, product=line.product_id, partner=line.order_id.partner_id)
amount_tax += sum(t.get('amount', 0.0) for t in taxes.get('taxes', []))
else:
amount_tax += line.price_tax
order.update({
'amount_untaxed': order.currency_id.round(amount_untaxed),
'amount_tax': order.currency_id.round(amount_tax),
'amount_total': amount_untaxed + amount_tax,
})
這是我用於繼承該代碼的模塊。
class PurchaseOrderNew(models.Model):
_inherit = "purchase.order.line"
new_currency = fields.Float()
def _amount_all(self):
res = super(PurchaseOrderLine, self)_amount_all()
#### i don't have no idea how to let 'new_currency' to
#### multiple with amount_total in order.update
return res
有人知道嗎?
我只想要 new_currency 多個 a amount_total 在 order.update 。
[ new_currency * amount_total ]
但不知道如何編寫這樣的函數。
請嘗試以下代碼
def _amount_all(self):
res = super(PurchaseOrderLine, self)_amount_all()
for record in self:
record.amount_total = self.new_currency*(amount_untaxed + amount_tax)
return res
如果你不想交稅,你可以留下
def _amount_all(self):
res = super(PurchaseOrderLine, self)_amount_all()
for record in self:
record.amount_total = self.new_currency*amount_untaxed
return res
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.