From 21a9747fda7d8727bef7482a2f6c52cfd3ba7ab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 28 Mar 2016 10:32:47 +0200 Subject: [PATCH] Naming convention for code, number and reference issue1479 review17171002 --- CHANGELOG | 2 ++ __init__.py | 1 + account.py | 13 ++++++++++++- account.xml | 11 +++++++++++ payment.py | 22 ++++++++++++++++++---- view/configuration_form.xml | 11 +++++++++++ view/payment_group_form.xml | 4 ++-- view/payment_group_list.xml | 2 +- 8 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 view/configuration_form.xml diff --git a/CHANGELOG b/CHANGELOG index c9f7c5f403..7c8f7e5595 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Rename Payment Group reference into number +* Add payment group sequence in configuration * Add Python3 support Version 3.8.0 - 2015-11-02 diff --git a/__init__.py b/__init__.py index 8b07f5fec3..d7fb65f94a 100644 --- a/__init__.py +++ b/__init__.py @@ -13,6 +13,7 @@ def register(): MoveLine, ProcessPaymentStart, PayLineStart, + Configuration, module='account_payment', type_='model') Pool.register( ProcessPayment, diff --git a/account.py b/account.py index ac28f2b0a3..d30c445c36 100644 --- a/account.py +++ b/account.py @@ -13,7 +13,7 @@ from trytond.transaction import Transaction from .payment import KINDS -__all__ = ['MoveLine', 'PayLine', 'PayLineStart'] +__all__ = ['MoveLine', 'PayLine', 'PayLineStart', 'Configuration'] class MoveLine: @@ -178,3 +178,14 @@ class PayLine(Wizard): return action, { 'res_id': [p.id for p in payments], } + + +class Configuration: + __metaclass__ = PoolMeta + __name__ = 'account.configuration' + payment_group_sequence = fields.Property(fields.Many2One('ir.sequence', + 'Payment Group Sequence', domain=[ + ('company', 'in', + [Eval('context', {}).get('company', -1), None]), + ('code', '=', 'account.payment.group'), + ], required=True)) diff --git a/account.xml b/account.xml index ec21cc489c..a1e68092f3 100644 --- a/account.xml +++ b/account.xml @@ -75,5 +75,16 @@ this repository contains the full copyright notices and license terms. --> + + + + + + + account.configuration + + configuration_form + diff --git a/payment.py b/payment.py index 3fa6fe88c2..674529f5dc 100644 --- a/payment.py +++ b/payment.py @@ -7,6 +7,7 @@ from trytond.pyson import Eval, If from trytond.transaction import Transaction from trytond.wizard import Wizard, StateView, StateAction, Button from trytond.pool import Pool +from trytond import backend __all__ = ['Journal', 'Group', 'Payment', 'ProcessPaymentStart', 'ProcessPayment'] @@ -43,8 +44,8 @@ class Journal(ModelSQL, ModelView): class Group(ModelSQL, ModelView): 'Payment Group' __name__ = 'account.payment.group' - _rec_name = 'reference' - reference = fields.Char('Reference', required=True, readonly=True) + _rec_name = 'number' + number = fields.Char('Number', required=True, readonly=True) company = fields.Many2One('company.company', 'Company', required=True, readonly=True, select=True, domain=[ ('id', If(Eval('context', {}).contains('company'), '=', '!='), @@ -59,6 +60,16 @@ class Group(ModelSQL, ModelView): payments = fields.One2Many('account.payment', 'group', 'Payments', readonly=True) + @classmethod + def __register__(cls, module_name): + TableHandler = backend.get('TableHandler') + table_h = TableHandler(cls, module_name) + + # Migration from 3.8: rename reference into number + if table_h.column_exist('reference'): + table_h.column_rename('reference', 'number') + super(Group, cls).__register__(module_name) + @staticmethod def default_company(): return Transaction().context.get('company') @@ -67,11 +78,14 @@ class Group(ModelSQL, ModelView): def create(cls, vlist): pool = Pool() Sequence = pool.get('ir.sequence') + Config = pool.get('account.configuration') vlist = [v.copy() for v in vlist] + config = Config(1) for values in vlist: - if 'reference' not in values: - values['reference'] = Sequence.get('account.payment.group') + if values.get('number') is None: + values['number'] = Sequence.get_id( + config.payment_group_sequence.id) return super(Group, cls).create(vlist) diff --git a/view/configuration_form.xml b/view/configuration_form.xml new file mode 100644 index 0000000000..69d861f06c --- /dev/null +++ b/view/configuration_form.xml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/view/payment_group_form.xml b/view/payment_group_form.xml index 89c710738b..daa38244e6 100644 --- a/view/payment_group_form.xml +++ b/view/payment_group_form.xml @@ -2,8 +2,8 @@
-