Skip to Content
Menu
This question has been flagged
3 Replies
2859 Views


How to change the price according to the selected tax.

Detail of invoice, with 2 types of taxes in the same invoice line.
amount = 1
price: 500

Tax to: 10%
Value: 1 * 500 * 10% = 50
tax b: 18%
the tax b: takes as a basis the price * amount + (tax A)
amount * price + (tax A) * 18%
1 * 500 + (50) = 550 * 18% = 99

code
I need to differentiate the price according to the selected tax code. All the lines of the
The tax is calculated in the same way.
Observation: I am considering +50 test on the price.
class AccountInvoice(models.Model):    
_inherit = "account.invoice"
......
..........
    @api.multi

def get_taxes_values(self):
tax_grouped = {}
for line in self.invoice_line_ids:
if len(line.invoice_line_tax_ids)>0:
for line2 in line.invoice_line_tax_ids: if line_tax.tipo_afectacion_igv.code in ["10"]:
taxes=line.invoice_line_tax_ids.compute_all(price_unit+50 if line_tax.tipo_afectacion_igv.code in ["10"] else price_unit, self.currency_id, line.quantity, line.product_id, self.partner_id)['taxes']
for tax in taxes:
val = self._prepare_tax_line_vals(line, tax)
key = self.env['account.tax'].browse(tax['id']).get_grouping_key(val)
if key not in tax_grouped:
tax_grouped[key] = val
else:
tax_grouped[key]['amount'] += val['amount']
tax_grouped[key]['base'] += val['base']
return tax_grouped



Avatar
Discard
Best Answer

This is a typical tax on tax case, which is covered by default Odoo functionality. Please search for "Group of Taxes", I made a step by step tutorial in this forum lately.

If I did not understand you correctly, please provide a logically and mathematically proper description.

Avatar
Discard
Best Answer

Good day,


Why don't you set up a fiscal position to assign taxes and add a  price list based on country?

This way the right taxes are assigned and the prices can be changed based on origin.


Avatar
Discard
Author

I need to be able to calculate the price, it has to be dynamic. because it varies according to conditions.

for example:

to the price per line according to the conditions, it is multiplied by additional values. but not for all lines, only those that meet the conditions.

then, you need to do for line 1, a calculation.

for line 2 another calculation.

Thank you,

Related Posts Replies Views Activity
2
Nov 24
272
1
Oct 24
335
4
Oct 24
326
2
Oct 24
362
2
Dec 24
677