add maintenanceService Unique
This commit is contained in:
parent
0cb98f7622
commit
0a60a455cf
@ -1489,7 +1489,7 @@ msgstr "Cronograma de Mantenimiento"
|
|||||||
|
|
||||||
msgctxt "model:ir.action,name:report_service"
|
msgctxt "model:ir.action,name:report_service"
|
||||||
msgid "Service"
|
msgid "Service"
|
||||||
msgstr "Servicio"
|
msgstr "Registro de Mantenimiento Preventivo"
|
||||||
|
|
||||||
msgctxt "model:ir.action,name:report_equipment"
|
msgctxt "model:ir.action,name:report_equipment"
|
||||||
msgid "Equipment"
|
msgid "Equipment"
|
||||||
|
43
move.py
43
move.py
@ -100,7 +100,7 @@ class ShipmentOut(metaclass=PoolMeta):
|
|||||||
equipment = Equipments.search(['id', '=',Id])[0]
|
equipment = Equipments.search(['id', '=',Id])[0]
|
||||||
equipment.propietary = shipment.customer.id
|
equipment.propietary = shipment.customer.id
|
||||||
equipment.propietary_address= shipment.delivery_address.id
|
equipment.propietary_address= shipment.delivery_address.id
|
||||||
equipment.location = Locations.search(['name', '=', 'Customer'])[0].id
|
equipment.location = Locations.search(['name', '=', 'Cliente'])[0].id
|
||||||
equipment.state="uncontrated"
|
equipment.state="uncontrated"
|
||||||
equipment.shipment_destination = shipment
|
equipment.shipment_destination = shipment
|
||||||
equipment.sale_destination = shipment.outgoing_moves[count].origin
|
equipment.sale_destination = shipment.outgoing_moves[count].origin
|
||||||
@ -135,31 +135,38 @@ class ShipmentOut(metaclass=PoolMeta):
|
|||||||
Equipments = pool.get('optical_equipment.equipment')
|
Equipments = pool.get('optical_equipment.equipment')
|
||||||
|
|
||||||
for shipment in shipments:
|
for shipment in shipments:
|
||||||
sale_origin = shipment.outgoing_moves[0].origin.sale.id
|
|
||||||
# saleLine = SaleLine(
|
|
||||||
# type='line',
|
|
||||||
# quantity=1,
|
|
||||||
# unit_price=0,
|
|
||||||
# sale=sale_origin)
|
|
||||||
# saleLine.save()
|
|
||||||
#raise UserError(str((shipment.get_origins(name))))
|
|
||||||
maintenanceService = MaintenanceService(
|
|
||||||
sale_date=shipment.outgoing_moves[0].origin.sale.sale_date,
|
|
||||||
sale_origin=shipment.outgoing_moves[0].origin.sale,
|
|
||||||
maintenance_type='initial',
|
|
||||||
propietary=shipment.customer.id,
|
|
||||||
propietary_address=shipment.delivery_address.id,
|
|
||||||
state='draft')
|
|
||||||
maintenanceService.save()
|
|
||||||
|
|
||||||
serial = False
|
serial = False
|
||||||
|
number_equipments = 0
|
||||||
|
maintenance_required = 0
|
||||||
for move in shipment.inventory_moves:
|
for move in shipment.inventory_moves:
|
||||||
if move.product_equipment and move.equipment:
|
if move.product_equipment and move.equipment:
|
||||||
serial = True
|
serial = True
|
||||||
|
number_equipments +=1
|
||||||
|
if move.equipment.product.maintenance_required:
|
||||||
|
maintenance_required +=1
|
||||||
elif not move.product_equipment:
|
elif not move.product_equipment:
|
||||||
serial = True
|
serial = True
|
||||||
else:
|
else:
|
||||||
serial = False
|
serial = False
|
||||||
|
|
||||||
|
if number_equipments < 1 or maintenance_required < 1:
|
||||||
|
raise UserError(str("No se generó un mantenimiento inicial dado que los equipos no requiren mantenimiento, ó no se encontró ningún
|
||||||
|
producto de tipo equipo en este envío."))
|
||||||
|
break
|
||||||
|
|
||||||
|
sale_origin = shipment.outgoing_moves[0].origin.sale
|
||||||
|
maintenanceService = MaintenanceService.search(['sale_origin', '=', sale_origin])
|
||||||
|
if maintenanceService == []:
|
||||||
|
maintenanceService = MaintenanceService(
|
||||||
|
sale_date=shipment.outgoing_moves[0].origin.sale.sale_date,
|
||||||
|
sale_origin=shipment.outgoing_moves[0].origin.sale,
|
||||||
|
maintenance_type='initial',
|
||||||
|
propietary=shipment.customer.id,
|
||||||
|
propietary_address=shipment.delivery_address.id,
|
||||||
|
state='draft')
|
||||||
|
maintenanceService.save()
|
||||||
|
else:
|
||||||
|
maintenanceService = maintenanceService[0]
|
||||||
|
|
||||||
if serial == True:
|
if serial == True:
|
||||||
for move in shipment.inventory_moves:
|
for move in shipment.inventory_moves:
|
||||||
|
Loading…
Reference in New Issue
Block a user