Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
1
Trả lời
1542
Lượt xem
How to caculate amount_total without discount additionally in invoice in odoo 14?
Hi,
You can inherit the _compute_amount function that computes the value to amount_total field and make necessary changes.
Thanks
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng ký
Hi,
from odoo import api, fields, models
class AccountInvoice(models.Model):
_inherit = "account.move"
@api.depends('invoice_line_ids.price_subtotal', 'tax_line_ids.amount', 'tax_line_ids.amount_rounding',
'currency_id', 'company_id', 'date_invoice', 'type')
def _compute_amount(self):
super(AccountInvoice, self)._compute_amount()
self.amount_total_no_discount = sum(self.invoice_line_ids.mapped('price_subtotal_no_discount'))
amount_total_no_discount = fields.Monetary(string='Total without discount', store=True, readonly=True,
compute='_compute_amount')
class AccountInvoiceLine(models.Model):
_inherit = "account.move.line"
@api.depends('price_unit', 'discount', 'invoice_line_tax_ids', 'quantity', 'product_id', 'invoice_id.partner_id',
'invoice_id.currency_id', 'invoice_id.company_id','invoice_id.date_invoice', 'invoice_id.date')
def _compute_price(self):
super(AccountInvoiceLine, self)._compute_price()
if self.invoice_line_tax_ids:
taxes = self.invoice_line_tax_ids.compute_all(self.price_unit, self.invoice_id.currency_id, self.quantity,
product=self.product_id, partner=self.invoice_id.partner_id)
self.price_subtotal_no_discount = taxes['total_included']
else:
self.price_subtotal_no_discount = self.price_unit * self.quantity
price_subtotal_no_discount = fields.Monetary(string='Amount without discount', store=True, readonly=True,
compute='_compute_price')
This code don't work on odoo14.
How to edit it for working on odoo 14?
Thank's
please help me!