This question has been flagged
1 Reply
4294 Views

Set single pricelist, Based on Public Price

 

Base Price * (1 + 0) + 0

Minimum Margin: 5.00

 

When creating an SO with my test user of the lowest sales access rights, the Price that comes up in the form is $Price + 5.00. Which is correct. It still allows the test user to drop the price below this amount. THe purpose of the minimum margin is to stop this kind of behavior.

 

Secondly, is there a way to make this minimum margin based on cost with the price based on public price? I can set two or more pricelists if this is needed.

Avatar
Discard
Best Answer

I believe it is working as intended.   If you look at the code**, the price for a Sales order line is fully editable:

'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Product Price'), readonly=True, states={'draft': [('readonly', False)]}),

The implications of this design decision is that no matter what a pricelist is set to, users will always be able to edit the value.  

You can prevent this by creating a group that is allowed to edit prices and only adding the relevant users to that group.  You just need to inherit the sale.order.form view and restrict the price_unit field to those who are members of a new group you create****.

 

 

** - https://github.com/odoo/odoo/blob/master/addons/sale/sale.py#L863

*** - https://www.odoo.com/forum/help-1/question/make-field-readonly-based-on-group-58921

Avatar
Discard
Author

That doesn't make sense. On the one hand, you have a price calculation formula in the pricelist. Then you have a minimum margin, but to get the minimum margin to work, you have to restrict access to change prices. Now the user will only get the price created in the formula but still not be getting the minimum margin. If we use this advice, the minimum margin is a useless field that will never work regardless of your permissions.

Everything works out of the box without needing changes, once you understand how to set things up. The documentation helps a lot. Permissions changes are only needed it you want an ENFORCED price instead of a SUGGESTION. Pricelists work with price calculations AND margins, not one or the other. Margins dictate the floor or ceiling that the calculation must work within. If the calculation works out to be below or above the margin limits, then they are used instead. If you are not seeing that you should post a screenshot of your rule. https://doc.odoo.com/book/6/6_16_Sales/6_16_Sales_pricing/

The part of your assumption that isn't correct is "The purpose of the minimum margin is to stop this kind of behavior". Permissions stop changes that pricelists suggest. A pricelist will never create a price that can't be changed.

Author

Ok well that explanation actually makes sense. That the minimum is only used to control the formula you provide in price.

I just found http://stackoverflow.com/questions/23359684/dont-allow-to-quote-below-the-sales-price-of-a-product-in-openerp - it shows how you can create a function to 'validate' any change a user makes to a price and warn them about it.

Author

Yeah I think I saw that before and there was another one like it. There's also some community modules that protect against price change. This question was more about my confusion about how the minimum margin works, which you cleared up. I'm pretty sure there are ways to write a module that can handle my use-case but I was just thinking the minimum margin was what I was thinking. Which it wasn't. Thanks for coming back and posting a followup info.