Dear All,
Using Community V10.
I need an urgent help. It may be silly but still new to Odoo so any help is appreciated
I have added new field to Invoice line named "Fuel Surcharge". This is calculated as percent and entered value is properly shown in Untaxed amount..
Here is the code.
I have added custom module and here is the module account_invoice.py related code..
----------------------
class CustomAccountInvoiceLine(models.Model):
_inherit = "account.invoice.line"
@api.one
@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','fuel_surcharge')
def _compute_price(self):
currency = self.invoice_id and self.invoice_id.currency_id or None
price = self.price_unit * (1 - ((self.discount or 0.0) / 100.0) + self.fuel_surcharge /100 )
taxes = False
if self.invoice_line_tax_ids:
taxes = self.invoice_line_tax_ids.compute_all(price, currency,
self.quantity, product=self.product_id,
partner=self.invoice_id.partner_id)
self.price_subtotal = price_subtotal_signed = taxes['total_excluded'] if taxes else self.quantity * price
if self.invoice_id.currency_id and self.invoice_id.company_id and
self.invoice_id.currency_id != self.invoice_id.company_id.currency_id:
price_subtotal_signed =
self.invoice_id.currency_id.with_context(date=self.invoice_id.date_invoice).compute(price_subtotal_signed,
self.invoice_id.company_id.currency_id)
sign = self.invoice_id.type in ['in_refund', 'out_refund'] and -1 or 1
self.price_subtotal_signed = price_subtotal_signed * sign
invoice_bdate = fields.Date(string="Booking Date", store=True)
invoice_docket = fields.Char(string="Docket No.", store=True)
invoice_destination = fields.Char(string="Destination", store=True)
invoice_weight = fields.Float(string="Weight", store=True)
fuel_surcharge = fields.Float(string="Fuel Surcharge(%)", store=True)
# amount_before_surcharge = fields.Float(string="Amount Before", compute="_compute_price", store=True)
----------------
Attaching the screenshot of the Invoice for reference.
The Untaxed amount is correct, line subtotal is correct.. But the tax still is calculated on just the product price * Amount. :(
Sample calculation.
Product Price = 100
Surcharge = 10%.
Effective product price = 110 after surcharge
Untaxed price = 110
Tax @ 12.36 %
Now, the tax should be calculated on subtotal 110 .
It still calculates on Product Price.
Pleaseeeeeeee help friends.