Naming convention for code, number and reference
issue1479 review17171002
This commit is contained in:
1 parent
3b81114b2f
commit
21a9747fda
8 files changed
+58
-8
No files matched your search
@@ -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
|
||||
|
||||
@@ -13,6 +13,7 @@ def register():
|
||||
MoveLine,
|
||||
ProcessPaymentStart,
|
||||
PayLineStart,
|
||||
Configuration,
|
||||
module='account_payment', type_='model')
|
||||
Pool.register(
|
||||
ProcessPayment,
|
||||
|
||||
+12
-1
@@ -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))
|
||||
+11
@@ -75,5 +75,16 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="group" ref="group_payment"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.property" id="property_payment_group_sequence">
|
||||
<field name="field"
|
||||
search="[('model.model', '=', 'account.configuration'), ('name', '=', 'payment_group_sequence')]"/>
|
||||
<field name="value" eval="'ir.sequence,' + str(ref('sequence_account_payment_group'))"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="configuration_view_form">
|
||||
<field name="model">account.configuration</field>
|
||||
<field name="inherit" ref="account.configuration_view_form"/>
|
||||
<field name="name">configuration_form</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
+18
-4
@@ -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)
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/form" position="inside">
|
||||
<separator id="payment" string="Payment" colspan="4"/>
|
||||
<label name="payment_group_sequence" string="Group Sequence"/>
|
||||
<field name="payment_group_sequence"/>
|
||||
<newline/>
|
||||
</xpath>
|
||||
</data>
|
||||
@@ -2,8 +2,8 @@
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<form string="Payment Group">
|
||||
<label name="reference"/>
|
||||
<field name="reference"/>
|
||||
<label name="number"/>
|
||||
<field name="number"/>
|
||||
<label name="company"/>
|
||||
<field name="company"/>
|
||||
<label name="journal"/>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tree string="Payment Groups" keyword_open="1">
|
||||
<field name="reference"/>
|
||||
<field name="number"/>
|
||||
<field name="journal"/>
|
||||
<field name="kind"/>
|
||||
</tree>
|
||||
Reference in new issue
Block a user