changeset 90fb37dd1e95 in modules/stock_lot:default
details: https://hg.tryton.org/modules/stock_lot?cmd=changeset;node=90fb37dd1e95
description:
Store directly sequence type to sequence
issue10122
review351381002
diffstat:
ir.xml | 1 -
product.py | 10 ++++++----
stock.py | 3 +--
tests/scenario_stock_lot_number.rst | 5 ++++-
4 files changed, 11 insertions(+), 8 deletions(-)
diffs (83 lines):
diff -r 4a70240f51da -r 90fb37dd1e95 ir.xml
--- a/ir.xml Sat Feb 27 18:16:29 2021 +0100
+++ b/ir.xml Thu Mar 11 23:00:10 2021 +0100
@@ -5,7 +5,6 @@
<data>
<record model="ir.sequence.type" id="sequence_type_stock_lot">
<field name="name">Stock Lot</field>
- <field name="code">stock.lot</field>
</record>
<record model="ir.sequence.type-res.group"
id="sequence_type_stock_lot_group_admin">
<field name="sequence_type" ref="sequence_type_stock_lot"/>
diff -r 4a70240f51da -r 90fb37dd1e95 product.py
--- a/product.py Sat Feb 27 18:16:29 2021 +0100
+++ b/product.py Thu Mar 11 23:00:10 2021 +0100
@@ -4,7 +4,7 @@
from trytond.config import config
from trytond.model import ModelSQL, ValueMixin, fields
-from trytond.pyson import Eval
+from trytond.pyson import Eval, Id
from trytond.pool import PoolMeta, Pool
from trytond.transaction import Transaction
@@ -16,7 +16,8 @@
fields.Many2One(
'ir.sequence', "Default Lot Sequence",
domain=[
- ('code', '=', 'stock.lot'),
+ ('sequence_type', '=',
+ Id('stock_lot', 'sequence_type_stock_lot')),
]))
@@ -26,7 +27,8 @@
default_lot_sequence = fields.Many2One(
'ir.sequence', "Default Lot Sequence",
domain=[
- ('code', '=', 'stock.lot'),
+ ('sequence_type', '=',
+ Id('stock_lot', 'sequence_type_stock_lot')),
])
@@ -48,7 +50,7 @@
lot_sequence = fields.Many2One(
'ir.sequence', "Lot Sequence",
domain=[
- ('code', '=', 'stock.lot'),
+ ('sequence_type', '=', Id('stock_lot', 'sequence_type_stock_lot')),
],
states={
'invisible': ~Eval('type').in_(['goods', 'assets']),
diff -r 4a70240f51da -r 90fb37dd1e95 stock.py
--- a/stock.py Sat Feb 27 18:16:29 2021 +0100
+++ b/stock.py Thu Mar 11 23:00:10 2021 +0100
@@ -125,11 +125,10 @@
def _new_number(cls, values):
pool = Pool()
Product = pool.get('product.product')
- Sequence = pool.get('ir.sequence')
if values.get('product'):
product = Product(values['product'])
if product.lot_sequence:
- return Sequence.get_id(product.lot_sequence.id)
+ return product.lot_sequence.get()
@classmethod
@check_no_move
diff -r 4a70240f51da -r 90fb37dd1e95 tests/scenario_stock_lot_number.rst
--- a/tests/scenario_stock_lot_number.rst Sat Feb 27 18:16:29 2021 +0100
+++ b/tests/scenario_stock_lot_number.rst Thu Mar 11 23:00:10 2021 +0100
@@ -15,7 +15,10 @@
Create lot sequence::
>>> Sequence = Model.get('ir.sequence')
- >>> sequence = Sequence(name="Lot", code='stock.lot')
+ >>> SequenceType = Model.get('ir.sequence.type')
+ >>> sequence_type, = SequenceType.find(
+ ... [('name', '=', "Stock Lot")], limit=1)
+ >>> sequence = Sequence(name="Lot", sequence_type=sequence_type)
>>> sequence.save()
Set default sequence::