diff --git a/locale/es.po b/locale/es.po
index e957e9b..132bab2 100644
--- a/locale/es.po
+++ b/locale/es.po
@@ -358,6 +358,10 @@ msgctxt "field:purchase.purchase,equipment_create:"
msgid "Equipments Creates"
msgstr "Equipos Creados"
+msgctxt "model:ir.model.button,string:purchase_create_equipments"
+msgid "Create Equipments"
+msgstr "Crear Equipos"
+
msgctxt "field:purchase.line,product_equipment:"
msgid "Product Equipment"
msgstr "Es Equipo"
diff --git a/maintenance.py b/maintenance.py
index 1f6cd14..e8e7d59 100644
--- a/maintenance.py
+++ b/maintenance.py
@@ -13,7 +13,7 @@ from trytond.modules.product import price_digits
import datetime
from datetime import timedelta
-#from scipy.stats import t
+from scipy.stats import t
import matplotlib.pyplot as plt
import numpy as np
import math as mt
@@ -42,7 +42,8 @@ class MaintenanceService(Workflow, ModelSQL, ModelView):
sale_origin = fields.Reference("Sale Origin", selection='get_origin', select=True,
states={'readonly': True})
company = fields.Many2One('company.company', "Company", readonly=True)
- maintenance_type = fields.Selection([('preventive', 'Preventive'),
+ maintenance_type = fields.Selection([('initial','Initial'),
+ ('preventive', 'Preventive'),
('corrective', 'Corrective')
], "Maintenance Type", states=_states)
propietary = fields.Many2One('party.party', "Propietary", required=True, states=_states)
@@ -179,9 +180,9 @@ class Maintenance(Workflow, ModelSQL, ModelView):
states=_states)
code = fields.Char(
"Code", select=True,states={'readonly': True })
- maintenance_type = fields.Selection([('preventive', 'Preventive'),
- ('corrective', 'Corrective')
- ], "Maintenance Type", states=_states)
+ maintenance_type = fields.Selection([('initial', 'initial'),
+ ('preventive', 'Preventive'),
+ ('corrective', 'Corrective')], "Maintenance Type", states=_states)
state = fields.Selection([('draft', "Draft"),
('finished', "Finished")
], "State", readonly=True, sort=False,
@@ -220,17 +221,17 @@ class Maintenance(Workflow, ModelSQL, ModelView):
description_activity = fields.Char('Activity')
next_maintenance = fields.Function(fields.Date('Next Maintenance'), 'get_next_maintenance')
- temperature_min = fields.Float("Temp Min", required=True)
- temperature_max = fields.Float("Temp Max", required=True)
- temperature_uom = fields.Many2One('product.uom', 'Temperature UOM',required=True,
+ temperature_min = fields.Float("Temp Min")
+ temperature_max = fields.Float("Temp Max")
+ temperature_uom = fields.Many2One('product.uom', 'Temperature UOM',
domain=[('category', '=', Id('optical_equipment', "uom_cat_temperature"))],
states={'invisible': If(Eval('temperature_min') == None, True),
'readonly' : (Eval('state') == 'finished')},
depends=['itemperature_min']
)
- moisture_min = fields.Float("Moisture Min", required=True)
- moisture_max = fields.Float("Moisture Max", required=True)
- moisture_uom = fields.Many2One('product.uom', "Moisture UOM", required=True,
+ moisture_min = fields.Float("Moisture Min")
+ moisture_max = fields.Float("Moisture Max")
+ moisture_uom = fields.Many2One('product.uom', "Moisture UOM",
domain=[('category', '=', Id('optical_equipment', 'uom_cat_relative_humedity'))],
states={'invisible' : If(Eval('moisture_min') == None, True),
'readonly': Eval('state') == 'finished'},
@@ -432,8 +433,12 @@ class Maintenance(Workflow, ModelSQL, ModelView):
y = errors
if equipment_risk == 'dosB':
- top = 6
- bottom = -6
+ if sum(errors) == 0:
+ top = 1.5
+ bottom = -1.5
+ else:
+ top = 2
+ bottom = -2
else:
top = 0.60
bottom = -0.60
@@ -838,6 +843,7 @@ class CreateContractInitial(ModelView, ModelSQL):
'Create Contract Inicial'
__name__ = 'optical_equipment_create.contract'
+ currency = fields.Many2One('currency.currency', 'Currency', required=True)
company = fields.Many2One(
'company.company', "Company", readonly=True, required=True, select=True,
states={
@@ -865,7 +871,8 @@ class CreateContractInitial(ModelView, ModelSQL):
datetime.date.min)),
('end_date', '=', None),
])
-
+ unit_price = Monetary(
+ "Unit Price", digits=price_digits, currency='currency')
@staticmethod
def default_company():
return Transaction().context.get('company')
diff --git a/move.py b/move.py
index ced0657..743f0ef 100644
--- a/move.py
+++ b/move.py
@@ -10,8 +10,7 @@ from trytond.transaction import Transaction
class Move(metaclass=PoolMeta):
"Stock Move"
__name__ = "stock.move"
-
-
+
equipment = fields.Many2One('optical_equipment.equipment', "Equipment",
domain=[('state', '=', 'registred'),
('product','=', Eval('product'))
@@ -25,7 +24,8 @@ class Move(metaclass=PoolMeta):
depends=['product_equipment']),
'get_equipment_serial')
product_equipment = fields.Function(fields.Boolean("It Equipment"),'get_product_equipment')
-
+
+
@fields.depends('product')
def get_product_equipment(self, product):
if self.product.equipment:
@@ -60,6 +60,13 @@ class ShipmentOut(metaclass=PoolMeta):
"Customer Shipment"
__name__ = 'stock.shipment.out'
+ service_maintenance_initial = fields.Boolean('Maintenance Initial', states={'readonly': True})
+
+ @classmethod
+ def __setup__(cls):
+ super(ShipmentOut, cls).__setup__()
+ cls._buttons.update({
+ 'maintenance_initial': {'invisible': If(Eval('service_maintenance_initial') == True, True)}})
def get_outgoing_moves(self, name):
moves = []
@@ -73,6 +80,7 @@ class ShipmentOut(metaclass=PoolMeta):
moves.append(move.id)
return moves
+
@classmethod
def view_attributes(cls):
return super(ShipmentOut, cls).view_attributes() + [
@@ -80,15 +88,13 @@ class ShipmentOut(metaclass=PoolMeta):
'invisible': False,
}),]
-
@classmethod
@ModelView.button
- @Workflow.transition('done')
- @set_employee('done_by')
- def done(cls, shipments):
+ def maintenance_initial(cls, shipments):
pool = Pool()
- Move = pool.get('stock.move')
- Date = pool.get('ir.date')
+ MaintenanceService = pool.get('optical_equipment_maintenance.service')
+ Maintenance = pool.get('optical_equipment.maintenance')
+ SaleLine = pool.get('sale.line')
Equipments = pool.get('optical_equipment.equipment')
@@ -111,20 +117,42 @@ class ShipmentOut(metaclass=PoolMeta):
else:
count+=1
- Move.delete([
- m for s in shipments for m in s.outgoing_moves
- if m.state == 'staging'])
+ 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()
+ maintenanceService = MaintenanceService(
+ sale_date=shipment.outgoing_moves[0].origin.sale.sale_date,
+ sale_origin=saleLine,
+ maintenance_type='initial',
+ propietary=shipment.customer.id,
+ propietary_address=shipment.delivery_address.id)
+ maintenanceService.save()
+
+ serial = False
+ for move in shipment.inventory_moves:
+ if move.product_equipment and move.equipment:
+ serial = True
+ else:
+ serial = False
- Move.do([m for s in shipments for m in s.outgoing_moves])
- for company, c_shipments in groupby(
- shipments, key=lambda s: s.company):
- with Transaction().set_context(company=company.id):
-
- today = Date.today()
-
- cls.write([s for s in c_shipments if not s.effective_date], {
- 'effective_date': today,
- })
+ if serial == True:
+ for move in shipment.inventory_moves:
+ if move.product_equipment and move.equipment:
+ maintenance = Maintenance(
+ service_maintenance=maintenanceService.id,
+ maintenance_type='initial',
+ propietary=shipment.customer.id,
+ propietary_address=shipment.delivery_address.id,
+ equipment=move.equipment.id)
+ maintenance.save()
+ shipment.service_maintenance_initial = True
+ else:
+ raise UserError(str('Por favor Primero debe Asignar un serial a todos los Equipos.'))
def _get_inventory_move(self, move):
'Return inventory move for the outgoing move if necessary'
diff --git a/move.xml b/move.xml
index 83318ed..a92fe9c 100644
--- a/move.xml
+++ b/move.xml
@@ -12,6 +12,11 @@ this repository contains the full copyright notices and license terms. -->
move_form
+
+ maintenance_initial
+ Maintenance Initial
+
+
Acta Entrega
stock.shipment.out
diff --git a/tryton.cfg b/tryton.cfg
index 5e76a38..42816ab 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -31,5 +31,4 @@ xml:
message.xml
diary.xml
maintenance.xml
-
-
\ No newline at end of file
+ shipment.xml
\ No newline at end of file