python - How to check for a float field and give a constraint for any action in Odoo v8 -
suppose, in custom module, have fields for:
product_id, stock_location, stock_move, etc
and on custom module have float field, have quantity, represent fiscal year.
so, before movement, should check float field, , somehow compare it's data product, or products moving (product have field called 'sale_price'
custom float on product)
i don't know if i'm explaining myself, want compare these fields, , give constraint action, if custom_fiscal
float field has lower value product_price
float one, show validationerror
or that.
these fields on 2 different modules, although possible inheritance , module dependence.
i'm not sure if scenario achievable using _constraint
or _sql_constraint
any ideas?
you have couple of different options here:
add
_constraints
field 1 module , force module depend on other custom module.{'name': 'custom_a', 'depends': ['custom_b']}
create independent third custom module links them together. you'll see odoo core quite bit modules such
stock_account
.{'name': 'custom_link', 'depends': ['custom_a', 'custom_b']} class constrains(models.model): _constraints = [(_check, 'my message...', ['my_field'])]
Comments
Post a Comment