def copy_data(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
- if not context: context = {}
default['state'] = self.browse(cr, uid, id, context=context).state
return super(account_invoice_line, self).copy_data(cr, uid, id, default, context)
def _fnct(self, cr, uid, ids, name, args, context=None):
res = {}
- if not context: context = {}
lines = self.browse(cr, uid, ids, context=context)
account_ids = [line.account_id.id for line in lines]
account_names = dict(self.pool.get('account.account').name_get(cr, uid, account_ids, context=context))
}
def _default_account(self, cr, uid, context=None):
- cr.execute("select id from account_account where parent_id IS NULL LIMIT 1")
- res = cr.fetchone()
- return res[0]
+ if context is None:
+ context = {}
+ current_company = self.pool.get('res.users').browse(cr,uid,uid).company_id.id
+ account_id = self.pool.get('account.account').search(cr, uid, [('company_id','=',current_company),('parent_id','=',False)], limit=1,context=context)
+ return account_id and account_id[0] or False
_defaults = {
'state': 'article',
class one2many_mod2(fields.one2many):
def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None):
- if not context:
+ if context is None:
context = {}
if not values:
values = {}