summaryrefslogtreecommitdiff
path: root/addons/analytic/analytic.py
diff options
context:
space:
mode:
Diffstat (limited to 'addons/analytic/analytic.py')
-rw-r--r--addons/analytic/analytic.py37
1 files changed, 32 insertions, 5 deletions
diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py
index 3cb98d81f43..fea0e330143 100644
--- a/addons/analytic/analytic.py
+++ b/addons/analytic/analytic.py
@@ -96,9 +96,29 @@ class account_analytic_account(osv.osv):
res[row['id']][field] = row[field]
return self._compute_level_tree(cr, uid, ids, child_ids, res, fields, context)
- def _complete_name_calc(self, cr, uid, ids, prop, unknow_none, unknow_dict):
- res = self.name_get(cr, uid, ids)
- return dict(res)
+ def name_get(self, cr, uid, ids, context=None):
+ res = []
+ for id in ids:
+ elmt = self.browse(cr, uid, id, context=context)
+ res.append((id, self._get_one_full_name(elmt)))
+ return res
+
+ def _get_full_name(self, cr, uid, ids, name=None, args=None, context=None):
+ if context == None:
+ context = {}
+ res = {}
+ for elmt in self.browse(cr, uid, ids, context=context):
+ res[elmt.id] = self._get_one_full_name(elmt)
+ return res
+
+ def _get_one_full_name(self, elmt, level=6):
+ if level<=0:
+ return '...'
+ if elmt.parent_id:
+ parent_path = self._get_one_full_name(elmt.parent_id, level-1) + "/"
+ else:
+ parent_path = ''
+ return parent_path + elmt.name
def _child_compute(self, cr, uid, ids, name, arg, context=None):
result = {}
@@ -139,7 +159,7 @@ class account_analytic_account(osv.osv):
_columns = {
'name': fields.char('Account/Contract Name', size=128, required=True),
- 'complete_name': fields.function(_complete_name_calc, type='char', string='Full Account Name'),
+ 'complete_name': fields.function(_get_full_name, type='char', string='Full Account Name'),
'code': fields.char('Reference', size=24, select=True),
'type': fields.selection([('view','Analytic View'), ('normal','Analytic Account'),('contract','Contract or Project'),('template','Template of Contract')], 'Type of Account', required=True,
help="If you select the View Type, it means you won\'t allow to create journal entries using that account.\n"\
@@ -305,8 +325,15 @@ class account_analytic_line(osv.osv):
'company_id': fields.related('account_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
}
+
+ def _get_default_date(self, cr, uid, context=None):
+ return fields.date.context_today(self, cr, uid, context=context)
+
+ def __get_default_date(self, cr, uid, context=None):
+ return self._get_default_date(cr, uid, context=context)
+
_defaults = {
- 'date': lambda *a: time.strftime('%Y-%m-%d'),
+ 'date': __get_default_date,
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', context=c),
'amount': 0.00
}