Hello,
In sale order line I don't want Odoo to update price automatically when I change the quantity because sometime, I change the price manually and then change the quantity so I need to keep the price. Please help!
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello,
In sale order line I don't want Odoo to update price automatically when I change the quantity because sometime, I change the price manually and then change the quantity so I need to keep the price. Please help!
you can customize the behavior by overriding the relevant method in the sale.order.line model. Here's an example of how you can achieve this:
Create a custom module:
Inherit the sale.order.line model:
from odoo import models, api classSaleOrderLine(models.Model): _inherit = 'sale.order.line'
@api.onchange('product_uom_qty')
defonchange_product_uom_qty(self): # Skip price update if price has been manually set
for line in self: if line.price_unit_manual: continue
else: # Call the original onchange method to update the price
super(SaleOrderLine, line).onchange_product_uom_qty()
HI,
By default there is no option to disable it. If you need to achieve this you have add custom codes into the system, which will do the same for you.
The case is that, odoo has the functionality of the price list, where the price can change based on the number of quantities we are selling, once you applied this change, you will loose this functionality in the system.
Anyway if you need to achieve this, you have to create a custom module, which inherit the sale.order.line model and remove the product_uom_qty dependency from _compute_price_unit function.
Thanks
am sorry , the function is def _compute_price_unit(self): in the sale order line model
Hi!
This behavior was changed in Odoo 18, please have a look at the following video (starting from 12:40): https://www.odoo.com/odoo/project/809/tasks/4035579
Once you've upgraded the database to 18, you'll have access to the new feature.
Hope this helps,
This solution doens't work for me,
You can made override of function to avoid update:
from odoo import _, api, models, fields
class SaleOrderLine(models.Model): @api.depends('product_id', 'product_uom', 'product_uom_qty')
def _compute_price_unit(self):
for line in self:
if line.price_unit > 0:
continue
else:
super(SaleOrderLine, line)._compute_price_unit()