I have a field many2many and filter domain added in onchange of customer_id.It actually work when customer id changed the domain worked correctly for the many2many field but when i duplicate the record the onchnage function is not calling.
i want the filter domain when i duplicate the record also
odoo13
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Boekhouding
- Voorraad
- PoS
- Project
- MRP
Deze vraag is gerapporteerd
Hi,
You will have problem in the original record with the domain if you follow this method.
* Save the original record
* refresh the screen and see the field, now you wont have the domain
As a stable method, you can use the web domain module from the OCA, see how you can use it: Return Dynamic Domain For Field In Odoo
Thanks
Hi,
In Odoo, when you duplicate a record, the onchange methods are
not triggered automatically. This is because duplicating a record is
essentially creating a new record with the same values as the original
record, without triggering any field change events.
To achieve
your requirement of applying the filter domain when duplicating a
record, you can Override the copy method of your model to manually
trigger the onchange method after duplicating the recordExample:@api.model
def copy(self, default=None):
# Call super to perform the default copy operation
new_record = super(YourModel, self).copy(default=default)
# Retrieve the record's customer_id
customer_id = new_record.customer_id
# Call the onchange method of customer_id to trigger the domain filter
new_record.onchange_customer_id(customer_id)
return new_record
Hope it helps
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
Aanmelden