bzr revid: olt@tinyerp.com-20081118114320-41p8yhekug0vlb7p
This commit is contained in:
Olivier Laurent 2008-11-18 12:43:20 +01:00
commit c7fbda545e
3 changed files with 84 additions and 7 deletions

View File

@ -676,7 +676,83 @@ class account_move_line(osv.osv):
if update_check:
if ('account_id' in vals) or ('journal_id' in vals) or ('period_id' in vals) or ('move_id' in vals) or ('debit' in vals) or ('credit' in vals) or ('date' in vals):
self._update_check(cr, uid, ids, context)
obj_line=self.browse(cr, uid, ids[0])
lines={}
obj_analytic_line=self.pool.get('account.analytic.line')
analytic=True
journal_flag=False
del_line=False
if ('journal_id' in vals):
journal=self.pool.get('account.journal').browse(cr,uid,vals['journal_id'])
journal_flag=True
if not journal.analytic_journal_id:
del_line=True
if ('analytic_account_id' in vals) and (not vals['analytic_account_id']):
del_line=True
if del_line:
for obj in obj_line.analytic_lines:
obj_analytic_line.unlink(cr,uid,obj.id)
analytic=False
if obj_line.analytic_lines:
mode='write'
else:
mode='create'
if obj_line.analytic_lines and analytic:
if ('analytic_account_id' in vals):
lines['account_id'] = vals['analytic_account_id']
if ('account_id' in vals):
lines['general_account_id'] = vals['account_id']
if ('name' in vals):
lines['name'] = vals['name']
if ('date' in vals):
lines['date'] = vals['date']
if ('ref' in vals and vals['ref']):
lines['ref'] = vals['ref']
if ('quantity' in vals and vals['quantity']):
lines['unit_amount'] = vals['quantity']
if ('credit' in vals and vals['credit']):
lines['amount'] = vals['credit']
if ('debit' in vals and vals['debit']):
lines['amount'] = vals['debit']
if journal_flag:
lines['journal_id']=journal.analytic_journal_id.id
if lines:
if mode=='write':
obj_analytic_line.write(cr,uid,obj_line.analytic_lines[0].id,lines,context)
result = super(osv.osv, self).write(cr, uid, ids, vals, context)
if mode=='create' and analytic and obj_line.analytic_account_id:
if obj_line.journal_id.analytic_journal_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
}
obj_analytic_line.create(cr,uid,vals_lines)
if check:
done = []
for line in self.browse(cr, uid, ids):
@ -786,20 +862,20 @@ class account_move_line(osv.osv):
if not ok:
raise osv.except_osv(_('Bad account !'), _('You can not use this general account in this journal !'))
result = super(osv.osv, self).create(cr, uid, vals, context)
# result = super(osv.osv, self).create(cr, uid, vals, context)
if 'analytic_account_id' in vals and vals['analytic_account_id']:
if journal.analytic_journal_id:
vals['analytic_lines'] = [(0,0, {
'name': vals['name'],
'date': vals['date'],
'account_id': vals['analytic_account_id'],
'unit_amount': vals['quantity'],
'unit_amount':'quantity' in vals and vals['quantity'] or 1.0,
'amount': vals['debit'] or vals['credit'],
'general_account_id': vals['account_id'],
'journal_id': journal.analytic_journal_id.id,
'ref': vals['ref'],
})]
result = super(osv.osv, self).create(cr, uid, vals, context)
# CREATE Taxes
if 'account_tax_id' in vals and vals['account_tax_id']:
tax_id=tax_obj.browse(cr,uid,vals['account_tax_id'])

View File

@ -717,10 +717,10 @@
<page string="Analytic Lines">
<field colspan="4" name="analytic_lines" nolabel="1"/>
</page>
<page string="Move Lines">
<!--<page string="Move Lines">
<field colspan="4" name="reconcile_implicit"/>
<field colspan="4" name="parent_move_lines" nolabel="0"/>
</page>
</page>-->
</notebook>
</form>
</field>

View File

@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
@ -237,7 +237,8 @@ class event_registration(osv.osv):
_defaults = {
'nb_register': lambda *a: 1,
'tobe_invoiced' : lambda *a: True,
'name': lambda *a: 'Registration'
'name': lambda *a: 'Registration',
'state': lambda *b: 'draft'
}
def onchange_badge_name(self, cr, uid, ids, badge_name):