Store directly sequence type to sequence
issue10122 review351381002
This commit is contained in:
1 parent
4fea1dcb5b
commit
6e2beb699e
4 files changed
+11
-8
No files matched your search
@@ -5,7 +5,6 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<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"/>
|
||||
|
||||
+6
-4
@@ -4,7 +4,7 @@ from sql import Table
|
||||
|
||||
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 @@ class Configuration(metaclass=PoolMeta):
|
||||
fields.Many2One(
|
||||
'ir.sequence', "Default Lot Sequence",
|
||||
domain=[
|
||||
('code', '=', 'stock.lot'),
|
||||
('sequence_type', '=',
|
||||
Id('stock_lot', 'sequence_type_stock_lot')),
|
||||
]))
|
||||
|
||||
|
||||
@@ -26,7 +27,8 @@ class ConfigurationDefaultLotSequence(ModelSQL, ValueMixin):
|
||||
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 @@ class Template(metaclass=PoolMeta):
|
||||
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']),
|
||||
|
||||
@@ -125,11 +125,10 @@ class Lot(ModelSQL, ModelView, LotMixin, StockMixin):
|
||||
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
|
||||
|
||||
@@ -15,7 +15,10 @@ Activate modules::
|
||||
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::
|
||||
|
||||
Reference in new issue
Block a user