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:

  1. add _constraints field 1 module , force module depend on other custom module.

    {'name': 'custom_a', 'depends': ['custom_b']} 
  2. 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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -