diff --git a/addons/account/account.py b/addons/account/account.py index 208bf1d6f68..3dc5c36c889 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1162,32 +1162,36 @@ class account_move(osv.osv): ] def post(self, cr, uid, ids, context=None): + if context is None: + context = {} invoice = context.get('invoice', False) valid_moves = self.validate(cr, uid, ids, context) - if valid_moves: - for move in self.browse(cr, uid, valid_moves): - if move.name =='/': - new_name = False - journal = move.journal_id + + if not valid_moves: + raise osv.except_osv(_('Integrity Error !'), _('You cannot validate a non-balanced entry !\nMake sure you have configured Payment Term properly !\nIt should contain atleast one Payment Term Line with type "Balance" !')) + + for move in self.browse(cr, uid, valid_moves): + if move.name =='/': + new_name = False + journal = move.journal_id - if invoice and invoice.internal_number: - new_name = invoice.internal_number + if invoice and invoice.internal_number: + new_name = invoice.internal_number + else: + if journal.sequence_id: + c = {'fiscalyear_id': move.period_id.fiscalyear_id.id} + new_name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id, context=c) else: - if journal.sequence_id: - c = {'fiscalyear_id': move.period_id.fiscalyear_id.id} - new_name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id, context=c) - else: - raise osv.except_osv(_('Error'), _('No sequence defined in the journal !')) + raise osv.except_osv(_('Error'), _('No sequence defined on the journal !')) - if new_name: - self.write(cr, uid, [move.id], {'name':new_name}) + if new_name: + self.write(cr, uid, [move.id], {'name':new_name}) - cr.execute('UPDATE account_move '\ - 'SET state=%s '\ - 'WHERE id IN %s', - ('posted', tuple(valid_moves),)) - else: - raise osv.except_osv(_('Integrity Error !'), _('You can not validate a non-balanced entry !\nMake sure you have configured Payment Term properly !\nIt should contain atleast one Payment Term Line with type "Balance" !')) + cr.execute('UPDATE account_move '\ + 'SET state=%s '\ + 'WHERE id IN %s', + ('posted', tuple(valid_moves),)) + return True def button_validate(self, cursor, user, ids, context=None): diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 1aa4e30d95d..777955d5a8e 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -650,18 +650,19 @@ class account_invoice(osv.osv): return ok def button_reset_taxes(self, cr, uid, ids, context=None): - if not context: + if context is None: context = {} + ctx = context.copy() ait_obj = self.pool.get('account.invoice.tax') for id in ids: cr.execute("DELETE FROM account_invoice_tax WHERE invoice_id=%s", (id,)) - partner = self.browse(cr, uid, id, context=context).partner_id + partner = self.browse(cr, uid, id, context=ctx).partner_id if partner.lang: - context.update({'lang': partner.lang}) - for taxe in ait_obj.compute(cr, uid, id, context=context).values(): + ctx.update({'lang': partner.lang}) + for taxe in ait_obj.compute(cr, uid, id, context=ctx).values(): ait_obj.create(cr, uid, taxe) # Update the stored value (fields.function), so we write to trigger recompute - self.pool.get('account.invoice').write(cr, uid, ids, {'invoice_line':[]}, context=context) + self.pool.get('account.invoice').write(cr, uid, ids, {'invoice_line':[]}, context=ctx) return True def button_compute(self, cr, uid, ids, context=None, set_total=False): diff --git a/addons/account/wizard/account_automatic_reconcile.py b/addons/account/wizard/account_automatic_reconcile.py index efce4bc4da4..f94082445da 100644 --- a/addons/account/wizard/account_automatic_reconcile.py +++ b/addons/account/wizard/account_automatic_reconcile.py @@ -200,7 +200,8 @@ class account_automatic_reconcile(osv.osv_memory): "AND partner_id=%s " \ "AND reconcile_id IS NULL " \ "AND state <> 'draft' " \ - "AND debit > 0", + "AND debit > 0 " \ + "ORDER BY date_maturity", (account_id, partner_id)) debits = cr.fetchall() @@ -212,7 +213,8 @@ class account_automatic_reconcile(osv.osv_memory): "AND partner_id=%s " \ "AND reconcile_id IS NULL " \ "AND state <> 'draft' " \ - "AND credit > 0", + "AND credit > 0 " \ + "ORDER BY date_maturity", (account_id, partner_id)) credits = cr.fetchall() diff --git a/addons/association/profile_association.xml b/addons/association/profile_association.xml index 8460cfa6cc9..d5a5baab946 100644 --- a/addons/association/profile_association.xml +++ b/addons/association/profile_association.xml @@ -48,8 +48,9 @@ - - 3 + + 3 + always diff --git a/addons/base_report_designer/base_report_designer_installer.xml b/addons/base_report_designer/base_report_designer_installer.xml index 4ea4970d19a..2c0cf191e4e 100644 --- a/addons/base_report_designer/base_report_designer_installer.xml +++ b/addons/base_report_designer/base_report_designer_installer.xml @@ -19,7 +19,7 @@ This plug-in allows you to create/modify OpenERP Reports into OpenOffice Writer. - +