Good afternoon,
You are trying to round the price_subtotal to 6 decimal places, I am trying to redefine the field, but it always appears rounded.
Where can I make the field, the change has to be by code so that it does not affect the configuration of other fields.
Thanks a lot
I see that it is a question that is asked very often but there is not much information.
**the rounding change must be by python code.
My code is:
class AccountInvoiceLine(models.Model):
_inherit = "account.invoice.line"
price_subtotal=fields.Float("Precio Unitario",digits=(12,6),readonly=False)
@api.one
@api.depends(
'discount', 'invoice_line_tax_ids','quantity',
'invoice_id.partner_id', 'invoice_id.currency_id', 'price_unit',
'invoice_id.company_id','invoice_id.date_invoice','discount'
)
def _compute_price(self):
price=0.000000
taxes = False
tasa=1+(self.invoice_line_tax_ids[0].amount/100)
if self.invoice_line_tax_ids[0].price_include:
self.price_unit=(self.price_unit2-( (self.price_unit2*self.discount/100)+self.descuento_unitario) )
price=self.price_unit
taxes = self.invoice_line_tax_ids.compute_all(price*tasa,currency, self.quantity, product=self.product_id,partner=self.invoice_id.partner_id )
else:
self.price_unit=(self.price_unit2-( (self.price_unit2*self.discount/100)+self.descuento_unitario) )*((100-self.invoice_id.descuento_global)/100)
price=self.price_unit
taxes = self.invoice_line_tax_ids.compute_all(price,currency, self.quantity, product=self.product_id,partner=self.invoice_id.partner_id )
self.price_unit=price
self.price_subtotal =taxes['total_excluded'] if taxes else self.quantity *price
expected result:
quantity=3
price_unit=55.356
tax1=15
tax2=13
price_subtotal=55.356*3=166.068 (line value, not rounded)