From cef1024645e23cccccdaf0f54ba511a9a6fe309e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 14 May 2012 15:36:16 +0200 Subject: [PATCH] Remove required on sequence review348001 --- invoice.py | 20 ++++++++++++++++++-- payment_term.py | 9 +++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/invoice.py b/invoice.py index dbb8059d33..5e42b52067 100644 --- a/invoice.py +++ b/invoice.py @@ -1361,7 +1361,9 @@ class InvoiceLine(ModelSQL, ModelView): ], depends=['invoice'], select=True) - sequence = fields.Integer('Sequence', required=True, + sequence = fields.Integer('Sequence', + order_field='(%(table)s.sequence IS NULL) %(order)s, ' + '%(table)s.sequence %(order)s', states={ 'invisible': Bool(Eval('context', {}).get('standalone')), }) @@ -1483,6 +1485,9 @@ class InvoiceLine(ModelSQL, ModelView): # Migration from 1.0 invoice is no more required table.not_null_action('invoice', action='remove') + # Migration from 2.4: drop required on sequence + table.not_null_action('sequence', action='remove') + def default_invoice_type(self): return Transaction().context.get('invoice_type', 'out_invoice') @@ -1952,7 +1957,9 @@ class InvoiceTax(ModelSQL, ModelView): invoice = fields.Many2One('account.invoice', 'Invoice', ondelete='CASCADE', select=True) description = fields.Char('Description', size=None, required=True) - sequence = fields.Integer('Sequence', required=True) + sequence = fields.Integer('Sequence', + order_field='(%(table)s.sequence IS NULL) %(order)s, ' + '%(table)s.sequence %(order)s') sequence_number = fields.Function(fields.Integer('Sequence Number'), 'get_sequence_number') account = fields.Many2One('account.account', 'Account', required=True, @@ -1992,6 +1999,15 @@ class InvoiceTax(ModelSQL, ModelView): 'that is open, paid or canceled!', }) + def init(self, module_name): + cursor = Transaction().cursor + table = TableHandler(cursor, self, module_name) + + super(InvoiceTax, self).init(module_name) + + # Migration from 2.4: drop required on sequence + table.not_null_action('sequence', action='remove') + def default_base(self): return Decimal('0.0') diff --git a/payment_term.py b/payment_term.py index 3c32599959..108fb8c8a7 100644 --- a/payment_term.py +++ b/payment_term.py @@ -77,8 +77,10 @@ class PaymentTermLine(ModelSQL, ModelView): 'Payment Term Line' _name = 'account.invoice.payment_term.line' _description = __doc__ - sequence = fields.Integer('Sequence', required=True, - help='Use to order lines in ascending order') + sequence = fields.Integer('Sequence', + order_field='(%(table)s.sequence IS NULL) %(order)s, ' + '%(table)s.sequence %(order)s', + help='Use to order lines in ascending order') payment = fields.Many2One('account.invoice.payment_term', 'Payment Term', required=True, ondelete="CASCADE") type = fields.Selection([ @@ -179,6 +181,9 @@ class PaymentTermLine(ModelSQL, ModelView): line.percentage, self.divisor.digits[1]), }) + # Migration from 2.4: drop required on sequence + table.not_null_action('sequence', action='remove') + def default_currency_digits(self): return 2