Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
1
Reply
1157
Views
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
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up
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!