Add new line field with the planned date, becasuse the EDI files will

have it in DTMLIN register.
This commit is contained in:
Bernat Brunet 2021-04-15 11:14:02 +02:00
parent 994494276c
commit b90a01f762
4 changed files with 25 additions and 5 deletions

View File

@ -16,6 +16,7 @@ MODULE_PATH = os.path.dirname(os.path.abspath(__file__))
KNOWN_EXTENSIONS = ['.txt', '.edi', '.pla']
DATE_FORMAT = '%Y%m%d'
def to_date(value):
if value is None or value == '':
return None
@ -25,6 +26,7 @@ def to_date(value):
return
return datetime.strptime(value, DATE_FORMAT)
def to_decimal(value, digits=2):
if value is None or value == '':
return None
@ -202,11 +204,13 @@ class EdiShipmentInLine(ModelSQL, ModelView):
'Marking Instructions', readonly=True)
expiration_date = fields.Date('Expiration Date', readonly=True)
packing_date = fields.Date('Packing Date', readonly=True)
planned_date = fields.Date('Planned Date', readonly=True)
quantities = fields.One2Many('edi.shipment.in.line.qty',
'edi_shipment_line', 'Quantities')
references = fields.One2Many('edi.shipment.in.reference',
'edi_shipment_in_line', 'References')
edi_shipment = fields.Many2One('edi.shipment.in', 'Shipment', readonly=True)
edi_shipment = fields.Many2One('edi.shipment.in', 'Shipment',
readonly=True)
product = fields.Many2One('product.product', 'Product')
def read_LIN(self, message):
@ -287,6 +291,10 @@ class EdiShipmentInLine(ModelSQL, ModelView):
self.quantities = []
self.quantities += (qty, )
def read_DTMLIN(self, message):
if message:
self.planned_date = to_date(message.pop(0))
def read_MOALIN(self, message):
# Not implemented
pass
@ -351,8 +359,8 @@ class EdiShipmentInLineQty(ModelSQL, ModelView):
('BP', 'Partial Shipment'),
('CP', 'Partial Shipment but Complete')],
'Difference', readonly=True)
edi_shipment_line = fields.Many2One('edi.shipment.in.line', 'Shipment Line',
readonly=True)
edi_shipment_line = fields.Many2One('edi.shipment.in.line',
'Shipment Line', readonly=True)
class EdiShipmentIn(ModelSQL, ModelView):
@ -473,8 +481,8 @@ class EdiShipmentIn(ModelSQL, ModelView):
def get_quantity(line):
for qty in line.quantities:
if qty.type_ == '12':
return float(qty.quantity)
if qty.type_ == '12':
return float(qty.quantity)
@classmethod
def import_edi_file(cls, shipments, data):
@ -654,6 +662,7 @@ class EdiShipmentIn(ModelSQL, ModelView):
move.shipment = shipment
move.quantity = quantity
move.lot = cls._get_new_lot(cls, line, quantity)
move.planned_date = line.planned_date
move_to_save.append(move)
else:
quantity = cls.get_quantity(line)
@ -661,6 +670,7 @@ class EdiShipmentIn(ModelSQL, ModelView):
move.shipment = shipment
move.quantity = quantity
move.lot = cls._get_new_lot(cls, line, quantity)
move.planned_date = line.planned_date
move_to_save.append(move)
edi_shipment.save()

View File

@ -114,6 +114,10 @@ msgctxt "field:edi.shipment.in.line,packing_date:"
msgid "Packing Date"
msgstr "Data dembalatge"
msgctxt "field:edi.shipment.in.line,planned_date:"
msgid "Planned Date"
msgstr "Data estimada"
msgctxt "field:edi.shipment.in.line,product:"
msgid "Product"
msgstr "Producte"

View File

@ -114,6 +114,10 @@ msgctxt "field:edi.shipment.in.line,packing_date:"
msgid "Packing Date"
msgstr "Fecha de embalaje"
msgctxt "field:edi.shipment.in.line,planned_date:"
msgid "Planned Date"
msgstr "Fecha estimada"
msgctxt "field:edi.shipment.in.line,product:"
msgid "Product"
msgstr "Producto"

View File

@ -21,6 +21,8 @@
<field name="expiration_date"/>
<label name="packing_date"/>
<field name="packing_date"/>
<label name="planned_date"/>
<field name="planned_date"/>
<field name="references" colspan="2"/>
<field name="quantities" colspan="2"/>
</form>