Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
6320 Lượt xem

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 :)

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.


Ảnh đại diện
Huỷ bỏ
Tác giả

Thank you very much :)

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

Câu trả lời hay nhất

thank you so much

but this code not working in v 18

how update this

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 8 25
655
2
thg 6 24
4967
2
thg 6 23
2115
0
thg 8 22
1856
1
thg 7 22
3602