Is there a way to fallback to a Pricelist only in the case where the sales price is set to 0?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Contabilidad
- Inventario
- PoS
- Project
- MRP
Se marcó esta pregunta
Well, as a matter of fact, Norma just recently created a post here, outlining how to utilize multiple price lists in a single Quotation. I would be wondering if this approach could not get adopted to your needs: https://www.odoo.com/forum/1/278106 (leave your Kudos there, I'm but the mail man)
Hi,
Option 1: python code
from odoo import models, fields, api
class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'
@api.onchange('product_id', 'product_uom_qty', 'order_id.pricelist_id')
def _onchange_product_id(self):
super()._onchange_product_id()
if self.product_id and self.product_id.lst_price == 0:
# If sales price = 0, use pricelist
price = self.order_id.pricelist_id.get_product_price(self.product_id, self.product_uom_qty, self.order_id.partner_id)
self.price_unit = price
else:
# Otherwise, keep product’s sale price
self.price_unit = self.product_id.lst_price
When you add a product to a quotation/order, Odoo checks:If product.lst_price == 0, it gets the price from the pricelist. Otherwise, it uses the product’s normal sale price.
Option 2: Automated action
If you want a no-code approach (in Odoo Studio or base system):
Go to Settings → Technical → Automation → Automated Actions
Create new:
Model: Sale Order Line
Trigger: On Creation & Update
Condition: record.product_id.lst_price == 0
Action:Execute code
record.price_unit = record.order_id.pricelist_id.get_product_price(
record.product_id,
record.product_uom_qty,
record.order_id.partner_id
)
This lets Odoo auto-fill the price only if product price = 0.
Hope it helps
The correct way to do this in Odoo17 is simply this (in sale order line model)
def _get_pricelist_price(self):
"""Compute the price given by the pricelist for the given line information.
:return: the product sales price in the order currency (without taxes)
:rtype: float
"""
self.ensure_one()
self.product_id.ensure_one()
if self.product_id.lst_price is False or self.product_id.lst_price == 0:
return super()._get_pricelist_price()
else:
return self.product_id.lst_price
¿Le interesa esta conversación? ¡Participe en ella!
Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.
RegistrarsePublicaciones relacionadas | Respuestas | Vistas | Actividad | |
---|---|---|---|---|
|
1
mar 15
|
3745 | ||
|
1
dic 22
|
4385 | ||
|
0
oct 25
|
964 | ||
|
3
oct 25
|
491 | ||
Add pdf file to quote
Resuelto
|
|
1
sept 25
|
592 |