跳至内容
菜单
此问题已终结
I have an invoice with 1 line, and two taxes. I need the price to change according to the selected tax.
example:
price:500, Quantity:1
tax1: (price * 0.084)* %tax1
tax2: (price * 1) * %Tax2
Being a single line, the price is the same for both taxes. 
The error is that it always takes the same price for the calculation of the two taxes. despite the filter. (if xx.code [10])
code:
    @api.multi

def get_taxes_values(self):#para calcular el valor de los impuestos.
tax_grouped = {}
for line in self.invoice_line_ids:
if len(line.invoice_line_tax_ids)==2:
for line_tax in line.invoice_line_tax_ids:
taxes={}
taxesisc={}
if line_tax.tipo_afectacion_igv.code in ["10"]:
price_unit = line.price_unit * (1 - (line.discount or 0.0) / 100.0)-line.descuento_unitario
taxes=line.invoice_line_tax_ids.compute_all(price_unit, self.currency_id, line.quantity, line.product_id, self.partner_id)['taxes']
for tax in taxes:
if line_tax.tipo_afectacion_igv.code in ["10"]:
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'] elif line_tax.tipo_afectacion_igv.code in ["99"]:
price_unitisc = line.price_unit*0.847 * (1 - (line.discount or 0.0) / 100.0)-line.descuento_unitario
taxesisc=line.invoice_line_tax_ids.compute_all(price_unitisc, self.currency_id, line.quantity, line.product_id, self.partner_id)['taxes']
for taxisc in taxesisc:
if line_tax.tipo_afectacion_igv.code in ["99"]:
val1 = self._prepare_tax_line_vals(line, taxisc)
key = self.env['account.tax'].browse(taxisc['id']).get_grouping_key(val1)
if key not in tax_grouped:
tax_grouped[key] = val1
else:
tax_grouped[key]['amount'] = val1['amount']
tax_grouped[key]['base'] = val1['base'] return tax_grouped
形象
丢弃
相关帖文 回复 查看 活动
4
4月 25
79315
1
10月 22
8233
1
12月 18
4552
2
5月 24
2745
2
1月 23
4218