I want to change the behavior of the calculated field total_amount depending on the id of the selected quote template.
Example: if the quote template id is 1 , I want the quote total to be amount_total = subtotal
I want to change the behavior of the calculated field total_amount depending on the id of the selected quote template.
Example: if the quote template id is 1 , I want the quote total to be amount_total = subtotal
Hi,
To override the _compute_amounts function with a custom module, you'll need to inherit from the relevant model and then overwrite the function. Here is an example:from odoo import models, api
class SaleOrderInherit(models.Model):
_inherit = 'sale.order'
@api.depends('order_line')
def _compute_amounts(self):
for order in self:
if order.quote_template_id.id == 1: # Apply default calculation logic
order.amount_total = order.amount_subtotal
else:
# Apply default calculation logic
Make sure to replace 'sale.order' with the appropriate model name in your Odoo instance.
After implementing this code in your custom module, make sure to upgrade your Odoo database.
Hope it helps
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.