*added option on account_journal to group the account_move_line generated by an invoice if the columns tax_code_id, product_id, analityc_account_id and account_id are
the same *bugfix: error when no analytic journal was defined on the account_journal and we tried to add an analytic account on an invoice line *improved translatability bzr revid: qdp@tinyerp.com-20081226181102-7daak46z0wyut9eu
This commit is contained in:
parent
6de8fb6059
commit
16195435ed
|
@ -451,8 +451,9 @@ class account_journal(osv.osv):
|
|||
'view_id': fields.many2one('account.journal.view', 'View', required=True, help="Gives the view used when writing or browsing entries in this journal. The view tell Open ERP which fields should be visible, required or readonly and in which order. You can create your own view for a faster encoding in each journal."),
|
||||
'default_credit_account_id': fields.many2one('account.account', 'Default Credit Account'),
|
||||
'default_debit_account_id': fields.many2one('account.account', 'Default Debit Account'),
|
||||
'centralisation': fields.boolean('Centralised counterpart', help="Check this box if you want that each entry doesn't create a counterpart but share the same counterpart for each entry of this journal."),
|
||||
'centralisation': fields.boolean('Centralised counterpart', help="Check this box if you want that each entry doesn't create a counterpart but share the same counterpart for each entry of this journal. This is used in fiscal year closing."),
|
||||
'update_posted': fields.boolean('Allow Cancelling Entries'),
|
||||
'group_invoice_lines': fields.boolean('Group invoice lines', help="If this box is cheked, the system will try to group the accouting lines when generating them from invoices."),
|
||||
'sequence_id': fields.many2one('ir.sequence', 'Entry Sequence', help="The sequence gives the display order for a list of journals", required=True),
|
||||
'user_id': fields.many2one('res.users', 'User', help="The responsible user of this journal"),
|
||||
'groups_id': fields.many2many('res.groups', 'account_journal_group_rel', 'journal_id', 'group_id', 'Groups'),
|
||||
|
|
|
@ -61,6 +61,8 @@ class account_move_line(osv.osv):
|
|||
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:
|
||||
if not obj_line.journal_id.analytic_journal_id:
|
||||
raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (obj_line.journal_id.name,))
|
||||
amt = (obj_line.credit or 0.0) - (obj_line.debit or 0.0)
|
||||
vals_lines={
|
||||
'name': obj_line.name,
|
||||
|
|
|
@ -267,6 +267,8 @@
|
|||
<field name="user_id" groups="base.group_extended"/>
|
||||
<newline/>
|
||||
<field name="centralisation"/>
|
||||
<field name="group_invoice_lines"/>
|
||||
|
||||
<field name="update_posted"/>
|
||||
<field name="entry_posted"/>
|
||||
</page>
|
||||
|
|
|
@ -68,7 +68,7 @@ class account_invoice(osv.osv):
|
|||
tt = type2journal.get(type_inv, 'sale')
|
||||
result = self.pool.get('account.analytic.journal').search(cr, uid, [('type','=',tt)], context=context)
|
||||
if not result:
|
||||
raise osv.except_osv(_('No Analytic Journal !'),("You have to define an analytic journal of type '%s' !") % (tt,))
|
||||
raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal of type '%s' !") % (tt,))
|
||||
return result[0]
|
||||
|
||||
def _get_type(self, cr, uid, context={}):
|
||||
|
@ -448,7 +448,7 @@ class account_invoice(osv.osv):
|
|||
ait_obj = self.pool.get('account.invoice.tax')
|
||||
cur_obj = self.pool.get('res.currency')
|
||||
acc_obj = self.pool.get('account.account')
|
||||
self.button_compute(cr, uid, ids, context={}, set_total=True)
|
||||
self.button_compute(cr, uid, ids, context={}, set_total=False)
|
||||
for inv in self.browse(cr, uid, ids):
|
||||
if inv.move_id:
|
||||
continue
|
||||
|
@ -598,14 +598,34 @@ class account_invoice(osv.osv):
|
|||
|
||||
date = inv.date_invoice or time.strftime('%Y-%m-%d')
|
||||
part = inv.partner_id.id
|
||||
|
||||
line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x, part, date, context={})) ,iml)
|
||||
|
||||
if inv.journal_id.group_invoice_lines:
|
||||
line2 = {}
|
||||
for x, y, l in line:
|
||||
tmp = str(l['account_id'])
|
||||
tmp += '-'+str('tax_code_id' in l and l['tax_code_id'] or "False")
|
||||
tmp += '-'+str('product_id' in l and l['product_id'] or "False")
|
||||
tmp += '-'+str('analytic_account_id' in l and l['analytic_account_id'] or "False")
|
||||
|
||||
if tmp in line2:
|
||||
am = line2[tmp]['debit'] - line2[tmp]['credit'] + (l['debit'] - l['credit'])
|
||||
line2[tmp]['debit'] = (am > 0) and am or 0.0
|
||||
line2[tmp]['credit'] = (am < 0) and -am or 0.0
|
||||
line2[tmp]['tax_amount'] += l['tax_amount']
|
||||
line2[tmp]['analytic_lines'] += l['analytic_lines']
|
||||
else:
|
||||
line2[tmp] = l
|
||||
line = []
|
||||
for key, val in line2.items():
|
||||
line.append((0,0,val))
|
||||
|
||||
journal_id = inv.journal_id.id #self._get_journal(cr, uid, {'type': inv['type']})
|
||||
journal = self.pool.get('account.journal').browse(cr, uid, journal_id)
|
||||
if journal.centralisation:
|
||||
raise osv.except_osv(_('UserError'),
|
||||
_('Can not create invoice move on centralized journal'))
|
||||
|
||||
move = {'ref': inv.number, 'line_id': line, 'journal_id': journal_id, 'date': date}
|
||||
period_id=inv.period_id and inv.period_id.id or False
|
||||
if not period_id:
|
||||
|
|
Loading…
Reference in New Issue