Hi!
I need to set parameter to record.field to find string with certaing characters to trigger the record of another field.
Can anyone help me?
Thanks!
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi!
I need to set parameter to record.field to find string with certaing characters to trigger the record of another field.
Can anyone help me?
Thanks!
If I understand correctly.
What you are trying to do is,
If field_A contains certain string, something happens to field_B.
This can be done by using @api.onchange or @api.depends.
onchange is dynamic even when the record is not saved yet.
depends requires the field to be saved first.
onchange cannot reference fields to another model, so access a field of another model through relational field is NOT doable.
depends does not have such restriction.
For example:
A = fields.Char('Field A')
B = fields.Char('Field B')
@api.onchange('A')
def _check_A(self):
if 'abc' in str(self.A):
self.update({'B': 'A contains abc'})
The above code will validate field A contains string 'abc' or not, even when the record is not saved (on creation).
If it does, the moment you click on to field B, 'A contains abc' will show.
Change the behavior accordingly to your needs.
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up
need more data