Naming convention for code, number and reference
issue1479 review17171002
This commit is contained in:
1 parent
779df5d70f
commit
00744e6f76
5 files changed
+24
-10
No files matched your search
@@ -1,3 +1,4 @@
|
||||
* Rename Production code into number
|
||||
* Add Python3 support
|
||||
|
||||
Version 3.8.0 - 2015-11-02
|
||||
|
||||
+18
-5
@@ -7,6 +7,7 @@ from trytond.wizard import Wizard, StateTransition, StateView, Button
|
||||
from trytond.pyson import Eval, Bool, If, Id
|
||||
from trytond.pool import Pool
|
||||
from trytond.transaction import Transaction
|
||||
from trytond import backend
|
||||
|
||||
from trytond.modules.product import price_digits, TemplateFunction
|
||||
|
||||
@@ -19,9 +20,9 @@ BOM_CHANGES = ['bom', 'product', 'quantity', 'uom', 'warehouse', 'location',
|
||||
class Production(Workflow, ModelSQL, ModelView):
|
||||
"Production"
|
||||
__name__ = 'production'
|
||||
_rec_name = 'code'
|
||||
_rec_name = 'number'
|
||||
|
||||
code = fields.Char('Code', select=True, readonly=True)
|
||||
number = fields.Char('Number', select=True, readonly=True)
|
||||
reference = fields.Char('Reference', select=1,
|
||||
states={
|
||||
'readonly': ~Eval('state').in_(['request', 'draft']),
|
||||
@@ -202,6 +203,17 @@ class Production(Workflow, ModelSQL, ModelView):
|
||||
'assign_force': {},
|
||||
})
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
TableHandler = backend.get('TableHandler')
|
||||
table_h = TableHandler(cls, module_name)
|
||||
|
||||
# Migration from 3.8: rename code into number
|
||||
if table_h.column_exist('code'):
|
||||
table_h.column_rename('code', 'number')
|
||||
|
||||
super(Production, cls).__register__(module_name)
|
||||
|
||||
@staticmethod
|
||||
def default_state():
|
||||
return 'draft'
|
||||
@@ -448,8 +460,9 @@ class Production(Workflow, ModelSQL, ModelView):
|
||||
vlist = [x.copy() for x in vlist]
|
||||
config = Config(1)
|
||||
for values in vlist:
|
||||
if not values.get('code'):
|
||||
values['code'] = Sequence.get_id(config.production_sequence.id)
|
||||
if values.get('number') is None:
|
||||
values['number'] = Sequence.get_id(
|
||||
config.production_sequence.id)
|
||||
productions = super(Production, cls).create(vlist)
|
||||
for production in productions:
|
||||
production._set_move_planned_date()
|
||||
@@ -466,7 +479,7 @@ class Production(Workflow, ModelSQL, ModelView):
|
||||
if default is None:
|
||||
default = {}
|
||||
default = default.copy()
|
||||
default.setdefault('code', None)
|
||||
default.setdefault('number', None)
|
||||
return super(Production, cls).copy(productions, default=default)
|
||||
|
||||
def _get_move_planned_date(self):
|
||||
|
||||
@@ -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. -->
|
||||
<calendar string="Productions" dtstart="planned_date">
|
||||
<field name="code"/>
|
||||
<field name="number"/>
|
||||
<field name="product"/>
|
||||
<field name="reference"/>
|
||||
</calendar>
|
||||
@@ -1,11 +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. -->
|
||||
<form string="Production">
|
||||
<form string="Production" cursor="planned_date">
|
||||
<label name="reference"/>
|
||||
<field name="reference"/>
|
||||
<label name="code"/>
|
||||
<field name="code"/>
|
||||
<label name="number"/>
|
||||
<field name="number"/>
|
||||
<label name="planned_date"/>
|
||||
<field name="planned_date"/>
|
||||
<label name="effective_date"/>
|
||||
|
||||
@@ -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="Productions">
|
||||
<field name="code"/>
|
||||
<field name="number"/>
|
||||
<field name="reference"/>
|
||||
<field name="product"/>
|
||||
<field name="quantity"/>
|
||||
|
||||
Reference in new issue
Block a user