*cleaned and added a function to create analytic lines (in order to be inherited by other modules liek account_analytic_plans)
bzr revid: qdp@tinyerp.com-20081124165126-rb1j9kscaa406siw
This commit is contained in:
parent
5a3a7a9f01
commit
36d4f14a2a
|
@ -1032,23 +1032,10 @@ class account_move(osv.osv):
|
||||||
}, context, check=False)
|
}, context, check=False)
|
||||||
ok = False
|
ok = False
|
||||||
if ok:
|
if ok:
|
||||||
obj_line=self.browse(cr, uid, ids[0])
|
list_ids = []
|
||||||
for move in self.browse(cr, uid, ids, context):
|
for tmp in move.line_id:
|
||||||
for obj_line in move.line_id:
|
list_ids.append(tmp.id)
|
||||||
#create analytic lines
|
self.pool.get('account.move.line').create_analytic_lines(cr, uid, list_ids, context)
|
||||||
if obj_line.analytic_account_id:
|
|
||||||
vals_lines={
|
|
||||||
'name': obj_line.name,
|
|
||||||
'date': obj_line.date,
|
|
||||||
'account_id': obj_line.analytic_account_id.id,
|
|
||||||
'unit_amount':obj_line.quantity,
|
|
||||||
'amount': obj_line.debit or obj_line.credit,
|
|
||||||
'general_account_id': obj_line.account_id.id,
|
|
||||||
'journal_id': obj_line.journal_id.analytic_journal_id.id,
|
|
||||||
'ref': obj_line.ref,
|
|
||||||
'move_id':obj_line.id
|
|
||||||
}
|
|
||||||
self.pool.get('account.analytic.line').create(cr,uid,vals_lines)
|
|
||||||
return ok
|
return ok
|
||||||
account_move()
|
account_move()
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,24 @@ class account_move_line(osv.osv):
|
||||||
del data[f]
|
del data[f]
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def create_analytic_lines(self, cr, uid, ids, context={}):
|
||||||
|
for obj_line in self.browse(cr, uid, ids, context):
|
||||||
|
if obj_line.analytic_account_id:
|
||||||
|
amt = (obj_line.credit or 0.0) - (obj_line.debit or 0.0)
|
||||||
|
vals_lines={
|
||||||
|
'name': obj_line.name,
|
||||||
|
'date': obj_line.date,
|
||||||
|
'account_id': obj_line.analytic_account_id.id,
|
||||||
|
'unit_amount':obj_line.quantity,
|
||||||
|
'amount': amt,
|
||||||
|
'general_account_id': obj_line.account_id.id,
|
||||||
|
'journal_id': obj_line.journal_id.analytic_journal_id.id,
|
||||||
|
'ref': obj_line.ref,
|
||||||
|
'move_id':obj_line.id
|
||||||
|
}
|
||||||
|
new_id = self.pool.get('account.analytic.line').create(cr,uid,vals_lines)
|
||||||
|
return True
|
||||||
|
|
||||||
def _default_get(self, cr, uid, fields, context={}):
|
def _default_get(self, cr, uid, fields, context={}):
|
||||||
# Compute simple values
|
# Compute simple values
|
||||||
data = super(account_move_line, self).default_get(cr, uid, fields, context)
|
data = super(account_move_line, self).default_get(cr, uid, fields, context)
|
||||||
|
|
Loading…
Reference in New Issue