Skip to Content
Menu
This question has been flagged
2 Replies
2738 Views

Hi, Experts

We can see the Odoo standard function for incoming shippment check.

The color of the line is red if quantity done > order quantity, but still can save. It is a warning, not an error.


My question is how and where Odoo does this check?

I checked [stock_pack_operation.py] and [stock_picking.py], but could not find the codes.

I am thinking about adding an error check and prevent the user saving it if quantity done > order quantity,

Where should I change? 

Avatar
Discard
Author Best Answer

Hi, Mohammed Amal

Thank you so much for your advice.

I used @api.constrains  and It works. Great!

Avatar
Discard
Best Answer

Hi,

Hi the colour change is done from xml.

check form view of stock.picking

<record id="view_picking_form" model="ir.ui.view">

in that record check the tree view definition for pack_operation_product_ids

<tree editable="bottom" decoration-muted="result_package_id" decoration-danger="qty_done&gt;product_qty" decoration-success="qty_done==product_qty and state!='done' and not result_package_id">

If you want to give an error message you can use @api.constrains for the model stock.pack.operations.

Or on onchange of the fields done and to_do

Avatar
Discard
Author

I used @api.constrains and It works. Great!