[FIX] analytic: fixed name_search() on analytic account. The partner_id field is not mandatory, but the previous domain was making an inner join with the partner table, which resulted in not finding the accounts matching the search criteria on name/code if they hadn't a partner set.
This commit is contained in:
@@ -77,7 +77,11 @@ class account_analytic_account(models.Model):
|
||||
@api.model
|
||||
def name_search(self, name='', args=None, operator='ilike', limit=100):
|
||||
args = args or []
|
||||
recs = self.search(['|', '|', ('code', operator, name), ('partner_id.name', operator, name), ('name', operator, name)] + args, limit=limit)
|
||||
domain = ['|', ('code', operator, name), ('name', operator, name)]
|
||||
partners = self.env['res.partner'].search([('name', operator, name)], limit=limit)
|
||||
if partners:
|
||||
domain = ['|'] + domain + [('partner_id', 'in', partners.ids)]
|
||||
recs = self.search(domain + args, limit=limit)
|
||||
return recs.name_get()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user