Allow to decide if we create serial numbers or not
This commit is contained in:
parent
f6ad9d3481
commit
98c9a77115
|
@ -7,6 +7,7 @@ from .production import *
|
||||||
def register():
|
def register():
|
||||||
Pool.register(
|
Pool.register(
|
||||||
Production,
|
Production,
|
||||||
|
SplitProductionStart,
|
||||||
module='production_split_serial_number', type_='model')
|
module='production_split_serial_number', type_='model')
|
||||||
Pool.register(
|
Pool.register(
|
||||||
SplitProduction,
|
SplitProduction,
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||||
|
|
||||||
|
msgctxt "field:production.split.start,create_serial_numbers:"
|
||||||
|
msgid "Create Serial Numbers?"
|
||||||
|
msgstr "Crear números de sèrie?"
|
||||||
|
|
||||||
|
msgctxt "field:production.split.start,serial_number_product:"
|
||||||
|
msgid "Serial Numbers Product"
|
||||||
|
msgstr "Producte amb números de sèrie"
|
|
@ -0,0 +1,11 @@
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||||
|
|
||||||
|
msgctxt "field:production.split.start,create_serial_numbers:"
|
||||||
|
msgid "Create Serial Numbers?"
|
||||||
|
msgstr "Crear números de serie?"
|
||||||
|
|
||||||
|
msgctxt "field:production.split.start,serial_number_product:"
|
||||||
|
msgid "Serial Numbers Product"
|
||||||
|
msgstr "Producto con número de serie"
|
|
@ -1,9 +1,11 @@
|
||||||
# The COPYRIGHT file at the top level of this repository contains the full
|
# The COPYRIGHT file at the top level of this repository contains the full
|
||||||
# copyright notices and license terms.
|
# copyright notices and license terms.
|
||||||
|
from trytond.model import fields
|
||||||
from trytond.pool import Pool, PoolMeta
|
from trytond.pool import Pool, PoolMeta
|
||||||
|
from trytond.pyson import Eval
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
|
|
||||||
__all__ = ['Production', 'SplitProduction']
|
__all__ = ['Production', 'SplitProductionStart', 'SplitProduction']
|
||||||
__metaclass__ = PoolMeta
|
__metaclass__ = PoolMeta
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,6 +19,8 @@ class Production:
|
||||||
for output in self.outputs:
|
for output in self.outputs:
|
||||||
if not output.product.serial_number:
|
if not output.product.serial_number:
|
||||||
continue
|
continue
|
||||||
|
if not Transaction().context.get('create_serial_numbers', True):
|
||||||
|
continue
|
||||||
if output.quantity != 1.0 or output.lot:
|
if output.quantity != 1.0 or output.lot:
|
||||||
continue
|
continue
|
||||||
if hasattr(output, 'get_production_output_lot'):
|
if hasattr(output, 'get_production_output_lot'):
|
||||||
|
@ -30,6 +34,25 @@ class Production:
|
||||||
output.save()
|
output.save()
|
||||||
|
|
||||||
|
|
||||||
|
class SplitProductionStart:
|
||||||
|
__name__ = 'production.split.start'
|
||||||
|
|
||||||
|
serial_number_product = fields.Boolean('Serial Numbers Product')
|
||||||
|
create_serial_numbers = fields.Boolean('Create Serial Numbers?',
|
||||||
|
states={
|
||||||
|
'invisible': ~Eval('serial_number_product', False),
|
||||||
|
},
|
||||||
|
depends=['serial_number_product'])
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def default_serial_number_product():
|
||||||
|
return False
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def default_create_serial_numbers():
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class SplitProduction:
|
class SplitProduction:
|
||||||
'Split Production'
|
'Split Production'
|
||||||
__name__ = 'production.split'
|
__name__ = 'production.split'
|
||||||
|
@ -41,4 +64,11 @@ class SplitProduction:
|
||||||
production = Production(Transaction().context['active_id'])
|
production = Production(Transaction().context['active_id'])
|
||||||
if production.product and production.product.serial_number:
|
if production.product and production.product.serial_number:
|
||||||
default['quantity'] = 1.0
|
default['quantity'] = 1.0
|
||||||
|
default['serial_number_product'] = True
|
||||||
|
default['create_serial_numbers'] = True
|
||||||
return default
|
return default
|
||||||
|
|
||||||
|
def transition_split(self):
|
||||||
|
with Transaction().set_context(
|
||||||
|
create_serial_numbers=self.start.create_serial_numbers):
|
||||||
|
return super(SplitProduction, self).transition_split()
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- The COPYRIGHT file at the top level of this repository contains the full
|
||||||
|
copyright notices and license terms. -->
|
||||||
|
<tryton>
|
||||||
|
<data>
|
||||||
|
<record model="ir.ui.view" id="split_start_view_form">
|
||||||
|
<field name="model">production.split.start</field>
|
||||||
|
<field name="name">split_start_form</field>
|
||||||
|
<field name="inherit"
|
||||||
|
ref="production_split.split_start_view_form"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</tryton>
|
|
@ -176,3 +176,23 @@ Make a production::
|
||||||
>>> product_sequence.reload()
|
>>> product_sequence.reload()
|
||||||
>>> product_sequence.number_next
|
>>> product_sequence.number_next
|
||||||
3
|
3
|
||||||
|
|
||||||
|
Split a production without creating serial numbers::
|
||||||
|
|
||||||
|
>>> Production = Model.get('production')
|
||||||
|
>>> production = Production()
|
||||||
|
>>> production.product = product
|
||||||
|
>>> production.bom = bom
|
||||||
|
>>> production.quantity = 4
|
||||||
|
>>> production.save()
|
||||||
|
>>> split_production = Wizard('production.split', [production])
|
||||||
|
>>> split_production.form.quantity
|
||||||
|
1.0
|
||||||
|
>>> split_production.form.count = 2
|
||||||
|
>>> split_production.form.create_serial_numbers = False
|
||||||
|
>>> split_production.execute('split')
|
||||||
|
>>> productions = Production.find([('code', 'like', '2-%')])
|
||||||
|
>>> len(productions)
|
||||||
|
3
|
||||||
|
>>> [o.lot for p in productions for o in p.outputs]
|
||||||
|
[None, None, None]
|
||||||
|
|
|
@ -172,6 +172,8 @@ Make a production::
|
||||||
>>> split_production.form.quantity
|
>>> split_production.form.quantity
|
||||||
1.0
|
1.0
|
||||||
>>> split_production.form.count = 2
|
>>> split_production.form.count = 2
|
||||||
|
>>> split_production.form.create_serial_numbers
|
||||||
|
True
|
||||||
>>> split_production.execute('split')
|
>>> split_production.execute('split')
|
||||||
>>> productions = Production.find([])
|
>>> productions = Production.find([])
|
||||||
>>> len(productions)
|
>>> len(productions)
|
||||||
|
@ -185,3 +187,23 @@ Make a production::
|
||||||
>>> output_sequence.reload()
|
>>> output_sequence.reload()
|
||||||
>>> output_sequence.number_next
|
>>> output_sequence.number_next
|
||||||
3
|
3
|
||||||
|
|
||||||
|
Split a production without creating serial numbers::
|
||||||
|
|
||||||
|
>>> Production = Model.get('production')
|
||||||
|
>>> production = Production()
|
||||||
|
>>> production.product = product
|
||||||
|
>>> production.bom = bom
|
||||||
|
>>> production.quantity = 4
|
||||||
|
>>> production.save()
|
||||||
|
>>> split_production = Wizard('production.split', [production])
|
||||||
|
>>> split_production.form.quantity
|
||||||
|
1.0
|
||||||
|
>>> split_production.form.count = 2
|
||||||
|
>>> split_production.form.create_serial_numbers = False
|
||||||
|
>>> split_production.execute('split')
|
||||||
|
>>> productions = Production.find([('code', 'like', '2-%')])
|
||||||
|
>>> len(productions)
|
||||||
|
3
|
||||||
|
>>> [o.lot for p in productions for o in p.outputs]
|
||||||
|
[None, None, None]
|
||||||
|
|
|
@ -7,3 +7,4 @@ depends:
|
||||||
extras_depend:
|
extras_depend:
|
||||||
production_output_lot
|
production_output_lot
|
||||||
xml:
|
xml:
|
||||||
|
production.xml
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- The COPYRIGHT file at the top level of this repository contains the full
|
||||||
|
copyright notices and license terms. -->
|
||||||
|
<data>
|
||||||
|
<xpath expr="/form" position="inside">
|
||||||
|
<label name="create_serial_numbers"/>
|
||||||
|
<field name="create_serial_numbers" colspan="5"/>
|
||||||
|
</xpath>
|
||||||
|
</data>
|
Loading…
Reference in New Issue