Hello, I have a problem, I have a many2one field with 5000 records and applying the domain creates 1000 records, but when I write to the domain without opening the "search for more" the domains are ignored, does anyone know if there is a way to solve it? i am using odoo 12 This is how I have declared the Many2one fieldlocation_id = fields.Many2one('crm.customer.location', string='Codigo', required=False, domain="[('location_type_id','=',location_type_id),('partner_id','=',partner_id)]")
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- 客户关系管理
- e-Commerce
- 会计
- 库存
- PoS
- Project
- MRP
此问题已终结
It sounds like you are encountering an issue with the domain applied to your many2one field. In Odoo, a domain is a condition that is used to filter the records that are available for selection in a many2one field.
One possible solution to your issue might be to use an "and" operator in your domain to specify multiple conditions. For example:
Copy codelocation_id = fields.Many2one('crm.customer.location', string='Codigo', required=False, domain="[('location_type_id','=',location_type_id), ('partner_id','=',partner_id)]")
This will apply both the location_type_id and partner_id conditions to the many2one field, and will only show records that meet both criteria.
Another solution might be to use a computed field to filter the available records. A computed field is a field that is calculated based on the values of other fields, and can be used to dynamically update the domain of a many2one field.
For example:
Copy codefrom odoo import models, fields class CustomModel(models.Model): _name = 'custom.model' location_type_id = fields.Many2one('crm.customer.location.type', string='Location Type') partner_id = fields.Many2one('res.partner', string='Partner') filtered_location_ids = fields.Many2one('crm.customer.location', string='Filtered Locations', compute='_compute_filtered_locations') @api.depends('location_type_id', 'partner_id') def _compute_filtered_locations(self): for record in self: domain = [('location_type_id', '=', record.location_type_id.id), ('partner_id', '=', record.partner_id
Hi William, have you ever found a solution for this issue? I've encountered similar behavior in v13.0