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:
- Create a custom module or use an existing one to implement the required customization. Let's assume the module name is custom_sale.
Inherit the sale.order.line model:
- In the custom_sale/models/sale_order.py file, define a new Python class that inherits from sale.order.line:
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()
- Update the module manifest:
- In the custom_sale/__manifest__.py file, add the dependency on the sale module: