I've made a fucntion inside a model how I can execute the fucntion everytime the user see the view
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
Compute method would do the job you are looking for.
Try following code:
@api.multi
def _calc_something(self):
for rec in self:
rec.compute_field = rec.field1 + rec.field2 # your logic goes here...
compute_field = fields.Float(string='My Compute Field', compute='_calc_something')
Add your compute field (compute_field) in the tree and/or form view so that it will call the function everytime the record is loaded.
Hello Wildhen,
In Odoo, You can define a compute/functional field and define a method for that field.
Compute method will be called when user see the form view. You have to create a compute field with store=False. You must display your output in that compute field.
It is necessary to display compute field in form view otherwise compute method will not be called.
If in case you do not want to add a field, you can override ORM's a method called " def fields_view_get". This method is called when a view is loaded.
Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up
You need these tips: https://goo.gl/8HgnCF