Skip to Content
Menu
This question has been flagged
3 Replies
6257 Views

I using Odoo13 in retail stores, and customers can do negotiate the product that they want.


But, sometimes a cashier can sell the product from POS or sometimes trough sales.order bellow its product Cost which the cost has been set from Inventory.


So I want to give an alert or whatever that will give a warning whenever a user do some mistake when they sell a product bellow it cost.
The alert can just change the product name or the price to be red color.


So, any clue, tutorial or whatever to do that?

Please, any help would be appreciated :)

Avatar
Discard
Best Answer

Hi Lima:

You can display the Sales Order Lines in red color if the unit price is less than the cost by adding a custom boolean field to the Sales Order Line model and using it to change the color of the text in that row. The boolean field will compare the value of the unit price and the cost and return a True or a False as it's value which can then be used in the QWeb view.

a. Add a computed boolean field to the Sales Order Line model like so.

 

b. Inherit and extend the sale.view_order_form to use the value of the custom field to change the color of the rows where the unit price is less than the cost like so.


Code in Architecture field:

<data>
    <xpath expr="//page[@name='order_lines']//tree[1]">
        <field name="x_price_below_cost" invisible="1"/>
    </xpath>
    <xpath expr="//page[@name='order_lines']//tree[1]" position="attributes">
        <attribute name="decoration-danger">(x_price_below_cost)</attribute>
    </xpath>
</data>

The result in the Sales Order form. The cost of the first line item is $190. The entered unit price is $150 so the row is displayed in red. The cost of the second line item is $85 so it is displayed in the normal color.


Avatar
Discard
Author

Thank you very much :)

This is perfect the answer, I'll think about the POS for now.

Best Answer

thank you so much

but this code not working in v 18

how update this

Avatar
Discard
Best Answer

Any Idea how to prevent the sale if the value is lower than cost? in the given answer it just alerts.

Avatar
Discard

Hi Moustafa: You can extend the model, perform a similar check in the "create" method and raise a ValidationError to prevent the user from saving the order.

If writing a custom module is not an option, you can implement something similar using an automated action/automation rule.

Thanks Paresh, this really helps

Related Posts Replies Views Activity
0
Jul 25
538
2
Jun 24
4927
2
Jun 23
2039
0
Aug 22
1812
1
Jul 22
3511