From 492df3625eafcc24232e01ddb110c58b867e786d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 25 Nov 2008 00:40:58 +0100 Subject: [PATCH] Add domain and check on invoice sequence --- invoice.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/invoice.py b/invoice.py index f6513d4e2f..9098208309 100644 --- a/invoice.py +++ b/invoice.py @@ -1936,16 +1936,24 @@ class FiscalYear(OSV): _name = 'account.fiscalyear' out_invoice_sequence = fields.Many2One('ir.sequence.strict', 'Customer Invoice Sequence', required=True, - domain="[('code', '=', 'account.invoice')]") + domain="[('code', '=', 'account.invoice')," \ + "['OR', ('company', '=', company)," \ + "('company', '=', False)]]") in_invoice_sequence = fields.Many2One('ir.sequence.strict', 'Supplier Invoice Sequence', required=True, - domain="[('code', '=', 'account.invoice')]") + domain="[('code', '=', 'account.invoice')," \ + "['OR', ('company', '=', company)," \ + "('company', '=', False)]]") out_credit_note_sequence = fields.Many2One('ir.sequence.strict', 'Customer Credit Note Sequence', required=True, - domain="[('code', '=', 'account.invoice')]") + domain="[('code', '=', 'account.invoice')," \ + "['OR', ('company', '=', company)," \ + "('company', '=', False)]]") in_credit_note_sequence = fields.Many2One('ir.sequence.strict', 'Supplier Credit Note Sequence', required=True, - domain="[('code', '=', 'account.invoice')]") + domain="[('code', '=', 'account.invoice')," \ + "['OR', ('company', '=', company)," \ + "('company', '=', False)]]") def __init__(self): super(FiscalYear, self).__init__() @@ -2029,16 +2037,15 @@ class Period(OSV): def __init__(self): super(Period, self).__init__() self._constraints += [ - ('check_invoice_sequences', - 'Error! You must have different invoice sequences ' \ - 'per fiscal year!', ['out_invoice_sequence', - 'in_invoice_sequence', 'out_credit_note_sequence', - 'in_credit_note_sequence']), + ('check_invoice_sequences', 'check_invoice_sequences'), ] self._error_messages.update({ 'change_invoice_sequence': 'You can not change ' \ 'the invoice sequence if there is already ' \ 'an invoice opened in the period', + 'check_invoice_sequences': 'You must have different ' \ + 'invoice sequences per fiscal year and ' \ + 'in the same company!', }) def check_invoice_sequences(self, cursor, user, ids): @@ -2050,6 +2057,10 @@ class Period(OSV): ('fiscalyear', '!=', period.fiscalyear.id), ]): return False + if period[sequence].company \ + and period[sequence].company.id != \ + period.fiscalyear.company.id: + return False return True def create(self, cursor, user, vals, context=None):