Hassan ALi
Hassan ALi

Reputation: 1331

How to find Onchange function of field in odoo 13

Hope my message finds you well,

I had inherited a odoo model (product.attribute) and also had overridden a field (display_type).

class darazProductAttributes(models.Model):
    _inherit = "product.attribute"

    display_type = fields.Selection([
        ('text', 'Text'),
        ('radio', 'Radio'),
        ('select', 'Select'),
        ('color', 'Color')], default='radio', required=True, help="The display type used in the Product Configurator.")

i had added one more option (text) in field.Now the selection of option field it loads product.attribute.lines model form basically it have a onchange method.Odoo shows me that display_type have a onchange but odoo don't show method name. enter image description here

So i want to override that function.

Thanks

Upvotes: 2

Views: 1643

Answers (2)

Farnoush Hosseini
Farnoush Hosseini

Reputation: 21

journal_id= fields.Many2one(comodel="account",
                             string="journal",
                             required=True
                                )  
 @api.onchange('journal_id')
 # call function every change field journal_id:
    def _onchange_journal(self):
        if self.journal_id and self.journal_id.currency_id:
            new_currency = self.journal_id.currency_id
            if new_currency != self.currency_id:
                self.currency_id = new_currency
                self._onchange_currency()

Upvotes: 0

Charif DZ
Charif DZ

Reputation: 14721

Field can have more than one onchange method, all you have to do is look for methods that are decorated with onchange:

@api.onchange('your_field_name')

Upvotes: 1

Related Questions