[FIX] res_company: make _company_default_get return a recordset in new API
This fixes a number of new-API default values for `company_id` fields.
This commit is contained in:
@@ -91,7 +91,7 @@ class AccountBankStatement(models.Model):
|
||||
@api.model
|
||||
def _default_journal(self):
|
||||
journal_type = self.env.context.get('journal_type', False)
|
||||
company_id = self.env['res.company']._company_default_get('account.bank.statement')
|
||||
company_id = self.env['res.company']._company_default_get('account.bank.statement').id
|
||||
if journal_type:
|
||||
journals = self.env['account.journal'].search([('type', '=', journal_type), ('company_id', '=', company_id)])
|
||||
if journals:
|
||||
|
||||
@@ -209,7 +209,7 @@ class ir_property(osv.osv):
|
||||
# retrieve the properties corresponding to the given record ids
|
||||
self._cr.execute("SELECT id FROM ir_model_fields WHERE name=%s AND model=%s", (name, model))
|
||||
field_id = self._cr.fetchone()[0]
|
||||
company_id = self.env.context.get('force_company') or self.env['res.company']._company_default_get(model, field_id)
|
||||
company_id = self.env.context.get('force_company') or self.env['res.company']._company_default_get(model, field_id).id
|
||||
refs = {('%s,%s' % (model, id)): id for id in values}
|
||||
props = self.search([
|
||||
('fields_id', '=', field_id),
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import os
|
||||
import re
|
||||
import openerp
|
||||
from openerp import SUPERUSER_ID, tools
|
||||
from openerp import SUPERUSER_ID, tools, api
|
||||
from openerp.osv import fields, osv
|
||||
from openerp.tools.translate import _
|
||||
from openerp.tools.safe_eval import safe_eval as eval
|
||||
@@ -203,6 +203,7 @@ class res_company(osv.osv):
|
||||
args = (args or []) + [('id', 'in', cmp_ids)]
|
||||
return super(res_company, self).name_search(cr, uid, name=name, args=args, operator=operator, context=context, limit=limit)
|
||||
|
||||
@api.returns('self')
|
||||
def _company_default_get(self, cr, uid, object=False, field=False, context=None):
|
||||
"""
|
||||
Check if the object for this company have a default value
|
||||
|
||||
Reference in New Issue
Block a user