Add wizard to add lots and sequence for lot number

issue9800
review326511002
This commit is contained in:
Cédric Krier
2021-02-03 21:19:06 +01:00
parent 93872fb55d
commit d73e657f02
3 changed files with 33 additions and 3 deletions
+5
View File
@@ -5,6 +5,10 @@ from trytond.pool import Pool
from . import product
from . import stock
from .stock import LotSledMixin
__all__ = ['LotSledMixin', 'register']
def register():
Pool.register(
@@ -13,6 +17,7 @@ def register():
stock.Configuration,
stock.ConfigurationLotShelfLife,
stock.Lot,
stock.MoveAddLotsStartLot,
stock.Move,
stock.Period,
module='stock_lot_sled', type_='model')
+22 -3
View File
@@ -45,8 +45,7 @@ class ConfigurationLotShelfLife(ModelSQL, ValueMixin):
shelf_life_delay = shelf_life_delay
class Lot(metaclass=PoolMeta):
__name__ = 'stock.lot'
class LotSledMixin:
shelf_life_expiration_date = fields.Date('Shelf Life Expiration Date',
states={
@@ -85,7 +84,7 @@ class Lot(metaclass=PoolMeta):
pool = Pool()
Date = pool.get('ir.date')
try:
super(Lot, self).on_change_product()
super().on_change_product()
except AttributeError:
pass
if self.product:
@@ -99,6 +98,10 @@ class Lot(metaclass=PoolMeta):
self.expiration_date = (today
+ datetime.timedelta(days=self.product.expiration_time))
class Lot(LotSledMixin, metaclass=PoolMeta):
__name__ = 'stock.lot'
@classmethod
def write(cls, *args):
super(Lot, cls).write(*args)
@@ -138,6 +141,22 @@ class Lot(metaclass=PoolMeta):
move=move.rec_name))
class MoveAddLotsStartLot(LotSledMixin, metaclass=PoolMeta):
__name__ = 'stock.move.add.lots.start.lot'
@fields.depends('shelf_life_expiration_date', 'expiration_date')
def _set_lot_values(self, lot):
super()._set_lot_values(lot)
self.shelf_life_expiration_date = lot.shelf_life_expiration_date
self.expiration_date = lot.expiration_date
def _get_lot_values(self, move):
values = super()._get_lot_values(move)
values['shelf_life_expiration_date'] = self.shelf_life_expiration_date
values['expiration_date'] = self.expiration_date
return values
class Move(metaclass=PoolMeta):
__name__ = 'stock.move'
+6
View File
@@ -28,5 +28,11 @@ this repository contains the full copyright notices and license terms. -->
<field name="inherit" ref="stock_lot.lot_view_tree"/>
<field name="name">lot_tree</field>
</record>
<record model="ir.ui.view" id="move_add_lots_start_lot_view_list">
<field name="model">stock.move.add.lots.start.lot</field>
<field name="inherit" ref="stock_lot.move_add_lots_start_lot_view_list"/>
<field name="name">lot_tree</field>
</record>
</data>
</tryton>