changes finished

This commit is contained in:
sinergia 2022-10-06 00:26:24 -05:00
parent 4767cc94c7
commit 221c887cb6
9 changed files with 311 additions and 60 deletions

View File

@ -16,3 +16,6 @@ class Configuration(ModelSingleton, ModelSQL, ModelView):
agended_sequence = fields.Many2One('ir.sequence', "Agended Sequence",
domain=[('sequence_type', '=', Id('optical_equipment', 'sequence_type_agended'))
])
contract_sequence = fields.Many2One('ir.sequence', "Contract Sequence",
domain=[('sequence_type', '=', Id('optical_equipment', 'sequence_type_contract'))
])

View File

@ -15,12 +15,12 @@ import datetime
from datetime import timedelta
class Contract(ModelSQL, ModelView):
class Contract(Workflow, ModelSQL, ModelView):
'Contracts'
__name__ = 'optical_equipment.contract'
company = fields.Many2One(
'company.company', "Company", readonly=True, required=True, select=True,
'company.company', "Company", required=True, select=True,
states={
'readonly': (Eval('state') != 'draft') | Eval('party', True),
},help="Make the subscription belong to the company.")
@ -35,30 +35,34 @@ class Contract(ModelSQL, ModelView):
'readonly': Eval('state') != 'draft',
})
party = fields.Many2One(
'party.party', "Party", readonly=True, required=True,
help="The party who subscribes.")
contact = fields.Many2One('party.contact_mechanism', "Contact", readonly=True)
invoice_address = fields.Many2One('party.address', 'Invoice Address', readonly=True,
required=True, domain=[('party', '=', Eval('party'))])
start_date = fields.Date("Start Date", readonly=True, required=False,)
end_date = fields.Date(
"End Date", readonly=True,
domain=['OR',
('end_date', '>=', If(
Bool(Eval('start_date')),
Eval('start_date', datetime.date.min),
datetime.date.min)),
('end_date', '=', None),
],
'party.party', "Party", required=True,
states={
'readonly': Eval('state') != 'draft',
}
)
'readonly': (Eval('state') != 'draft') | Eval('party', True),
},help="The party who subscribes.")
contact = fields.Many2One('party.contact_mechanism', "Contact", readonly=True, required=True)
invoice_address = fields.Many2One('party.address', 'Invoice Address',
required=True, domain=[('party', '=', Eval('party'))],
states={
'readonly': (Eval('state') != 'draft') | Eval('party', True),
})
start_date = fields.Date("Start Date", required=True,)
end_date = fields.Date("End Date",
domain=['OR',
('end_date', '>=', If(
Bool(Eval('start_date')),
Eval('start_date', datetime.date.min),
datetime.date.min)),
('end_date', '=', None),
],
states={
'readonly': Eval('state') != 'draft',
})
maintenance_services = fields.Many2Many('optical_equipment_maintenance.service-equipment.contract',
'contract', 'maintenance_services', "Prorogues")
equipments = fields.Many2Many('optical_equipment.contract-optical_equipment.equipment', 'contract', 'equipment')
#equipments = fields.One2Many('optical_equipment.equipment', "contract_history", "Equipments")
state = fields.Selection([
('draft', "Draft"),
('quotation', "Quotation"),
('running', "Running"),
('closed', "Closed"),
('cancelled', "Cancelled"),
@ -69,6 +73,16 @@ class Contract(ModelSQL, ModelView):
@classmethod
def __setup__(cls):
super(Contract, cls).__setup__()
cls._transitions = ({
('draft', 'running'),
('running', 'closed'),
('running', 'cancelled'),
})
cls._buttons.update({
'running': {'invisible': Eval('state').in_(['cancelled', 'running'])},
'cancelled': {'invisible': Eval('state').in_(['draft', 'cancelled'])}
})
@staticmethod
def default_company():
@ -78,6 +92,18 @@ class Contract(ModelSQL, ModelView):
def default_state():
return 'draft'
@classmethod
@ModelView.button
@Workflow.transition('running')
def running(cls, contracts):
pass
@classmethod
@ModelView.button
@Workflow.transition('cancelled')
def cancelled(cls, contracts):
pass
class ContractMaintenanceServices(ModelSQL):

View File

@ -35,15 +35,6 @@
<field name="count" eval="True"/>
<field name="act_window" ref="act_contract_form"/>
</record>
<record model="ir.action.act_window.domain"
id="act_contract_form_domain_quotation">
<field name="name">Quotation</field>
<field name="sequence" eval="20"/>
<field name="domain" eval="[('state', '=', 'quotation')]"
pyson="1"/>
<field name="count" eval="True"/>
<field name="act_window" ref="act_contract_form"/>
</record>
<record model="ir.action.act_window.domain"
id="act_contract_form_domain_running">
<field name="name">Running</field>
@ -93,7 +84,42 @@
<field name="string">Quotation</field>
<field name="confirm">Are you sure you want to quote these subscription?</field>
<field name="model" search="[('model', '=', 'optical_equipment.contract')]"/>
</record> -->
</record> -->
<record model="ir.model.button" id="contrac_running_button">
<field name="name">running</field>
<field name="string">Run</field>
<field name="model" search="[('model', '=', 'optical_equipment.contract')]"/>
</record>
<record model="ir.model.button" id="contract_cancelled_button">
<field name="name">cancelled</field>
<field name="string">Cancel</field>
<field name="model" search="[('model', '=', 'optical_equipment.contract')]"/>
</record>
<record model="res.group" id="group_contract_admin">
<field name="name">Contract Administration</field>
</record>
<record model="res.user-res.group"
id="user_admin_group_contract_admin">
<field name="user" ref="res.user_admin"/>
<field name="group" ref="group_contract_admin"/>
</record>
<record model="ir.sequence.type" id="sequence_type_contract">
<field name="name">Contract</field>
</record>
<record model="ir.sequence.type-res.group"
id="sequence_type_contract_group_admin">
<field name="sequence_type" ref="sequence_type_contract"/>
<field name="group" ref="res.group_admin"/>
</record>
<record model="ir.sequence.type-res.group"
id="sequence_type_contract_group_contract_admin">
<field name="sequence_type" ref="sequence_type_contract"/>
<field name="group" ref="group_contract_admin"/>
</record>
<record model="ir.sequence" id="sequence_contract">
<field name="name">Contract</field>
<field name="sequence_type" ref="sequence_type_contract"/>
</record>
<menuitem
parent="menu_equipment"
name="Contracts Management"

View File

@ -14,6 +14,7 @@ from trytond.model.exceptions import AccessError
_MAINTENANCE_FREQUENCY = [("none", ''),
("6", 'Seis Meses'),
("12", 'Doce Meses')]
class OpticalEquipment(DeactivableMixin, Workflow, ModelSQL, ModelView):
'Optical Equipment'
__name__ = 'optical_equipment.equipment'
@ -92,7 +93,6 @@ class OpticalEquipment(DeactivableMixin, Workflow, ModelSQL, ModelView):
#subscription_history = fields.Many2Many('sale.subscription-optical_equipment.equipment',
# 'equipment','subscription', "Subscriptions",
# states={'readonly': True})
contract_history = fields.Many2Many('optical_equipment.contract-optical_equipment.equipment',
'equipment', 'contract')

View File

@ -24,7 +24,7 @@ msgstr "Medidas del Equipo"
msgctxt "view:product.template:"
msgid "Enviromental Working Conditions"
msgstr "Condciones Ambientales de Trabajo"
msgstr "Condiciones Ambientales de Trabajo"
msgctxt "view:product.template:"
msgid "Electrical Conditions"
@ -362,7 +362,6 @@ msgctxt "field:purchase.line,health_register:"
msgid "Health Register"
msgstr "Registro Invima"
msgctxt "model:ir.ui.menu,name:menu_contracts"
msgid "Contracts Management"
msgstr "Gestión de Contratos"
@ -379,7 +378,6 @@ msgctxt "model:ir.ui.menu,name:menu_contract_form"
msgid "Contracts"
msgstr "Contratos"
msgctxt "field:optical_equipment.contract,company:"
msgid "Company"
msgstr "Compañia"
@ -477,7 +475,6 @@ msgctxt "selection:optical_equipment.contract,state:"
msgid "Cancelled"
msgstr "Cancelado"
msgctxt "model:ir.action.act_window.domain,name:act_contract_form_domain_draft"
msgid "Draft"
msgstr "Borrador"
@ -493,3 +490,187 @@ msgstr "En Ejecución"
msgctxt "model:ir.action.act_window.domain,name:act_contract_form_domain_all"
msgid "All"
msgstr "Todo"
msgctxt "model:ir.ui.menu,name:menu_diary"
msgid "Diary"
msgstr "Agendas"
msgctxt "model:ir.ui.menu,name:menu_agenda_form"
msgid "Calendar"
msgstr "Calendario"
msgctxt "model:ir.ui.menu,name:menu_agended_list_form"
msgid "Agended"
msgstr "Agenda"
msgctxt "model:ir.ui.menu,name:menu_assing_agended_form"
msgid "Assing Agended"
msgstr "Asignar Agenda"
msgctxt "model:ir.ui.menu,name:menu_reassing_agended_form"
msgid "ReAssing Agended"
msgstr "Reagendar"
msgctxt "model:ir.action.act_window.domain,name:act_agended_list_form_domain_draft"
msgid "Draft"
msgstr "Borrador"
msgctxt "model:ir.action.act_window.domain,name:act_agended_list_form_domain_agended"
msgid "Agended"
msgstr "Agendados"
msgctxt "model:ir.action.act_window.domain,name:act_agended_list_form_domain_in_progress"
msgid "In Progress"
msgstr "En Proceso"
msgctxt "model:ir.action.act_window.domain,name:act_agended_list_form_domain_failed"
msgid "Failed"
msgstr "Fallido"
msgctxt "model:ir.action.act_window.domain,name:act_agended_list_form_domain_finished"
msgid "Finished"
msgstr "Finalizado"
msgctxt "model:ir.action.act_window.domain,name:act_agended_list_form_domain_all"
msgid "All"
msgstr "Todo"
msgctxt "field:optical_equipment_maintenance.diary,code:"
msgid "Code"
msgstr "Código"
msgctxt "field:optical_equipment_maintenance.diary,date_expected:"
msgid "Expected Date"
msgstr "Fecha Esperada"
msgctxt "field:optical_equipment_maintenance.diary,date_estimated:"
msgid "Estimated Date"
msgstr "Fecha Estimada"
msgctxt "field:optical_equipment_maintenance.diary,date_end:"
msgid "Date End"
msgstr "Fecha Efectiva"
msgctxt "field:optical_equipment_maintenance.diary,maintenance_service:"
msgid "Maintenance Service"
msgstr "Servicio de Mantenimiento"
msgctxt "field:optical_equipment_maintenance.diary,technical:"
msgid "Technical"
msgstr "Técnico"
msgctxt "field:optical_equipment_maintenance.diary,state:"
msgid "State"
msgstr "Estado"
msgctxt "selection:optical_equipment_maintenance.diary,state:"
msgid "Draft"
msgstr "Borrador"
msgctxt "selection:optical_equipment_maintenance.diary,state:"
msgid "Agended"
msgstr "Agendado"
msgctxt "selection:optical_equipment_maintenance.diary,state:"
msgid "In Progress"
msgstr "En Proceso"
msgctxt "selection:optical_equipment_maintenance.diary,state:"
msgid "Failed"
msgstr "Fallido"
msgctxt "selection:optical_equipment_maintenance.diary,state:"
msgid "Finished"
msgstr "Finalizado"
msgctxt "model:ir.ui.menu,name:menu_maintenance_service_form"
msgid "Services Maintenance"
msgstr "Servicios de Mantenimiento"
msgctxt "model:ir.action.act_window.domain,name:act_maintenance_service_form_domain_draft"
msgid "Draft"
msgstr "Borrador"
msgctxt "model:ir.action.act_window.domain,name:act_maintenance_service_form_domain_agended"
msgid "Agended"
msgstr "Agendado"
msgctxt "model:ir.action.act_window.domain,name:act_maintenance_service_form_domain_in_progress"
msgid "In Progress"
msgstr "En Proceso"
msgctxt "model:ir.action.act_window.domain,name:act_maintenance_service_form_domain_failed"
msgid "Failed"
msgstr "Fallido"
msgctxt "model:ir.action.act_window.domain,name:act_maintenance_service_form_domain_finished"
msgid "Finished"
msgstr "Finalizado"
msgctxt "model:ir.action.act_window.domain,name:act_maintenance_service_form_domain_all"
msgid "All"
msgstr "Todo"
msgctxt "field:optical_equipment_maintenance.service,code:"
msgid "Code"
msgstr "Código"
msgctxt "field:optical_equipment_maintenance.service,reference:"
msgid "Reference"
msgstr "Referencia"
msgctxt "field:optical_equipment_maintenance.service,description:"
msgid "Description"
msgstr "Descripción"
msgctxt "field:optical_equipment_maintenance.service,sale_date:"
msgid "Sale Date"
msgstr "Fecha de Venta"
msgctxt "field:optical_equipment_maintenance.service,contract_origin:"
msgid "Contract Base"
msgstr "Contrato Base"
msgctxt "field:optical_equipment_maintenance.service,sale_origin:"
msgid "Sale Origin"
msgstr "Origen de la Venta"
msgctxt "field:optical_equipment_maintenance.service,company:"
msgid "Company"
msgstr "Empresa"
msgctxt "field:optical_equipment_maintenance.service,maintenance_type:"
msgid "Maintenance Type"
msgstr "Tipo de Mantenimiento"
msgctxt "field:optical_equipment_maintenance.service,propietary:"
msgid "Propietary"
msgstr "Propietario"
msgctxt "field:optical_equipment_maintenance.service,propietary_address:"
msgid "Propietary Address"
msgstr "Dirección del Propietario"
msgctxt "field:optical_equipment_maintenance.service,lines:"
msgid "Lines"
msgstr "Líneas"
msgctxt "field:optical_equipment_maintenance.service,estimated_agended:"
msgid "Date Maintenance"
msgstr "Fecha de Mantenimiento"
msgctxt "field:optical_equipment_maintenance.service,history_agended:"
msgid "History Agended"
msgstr "Agenda Historica"
msgctxt "field:optical_equipment_maintenance.service,state_agended:"
msgid "State Agenda"
msgstr "Estado de la Agenda"
msgctxt "field:optical_equipment_maintenance.service,technical:"
msgid "Technical"
msgstr "Técnico"
msgctxt "field:optical_equipment_maintenance.service,state:"
msgid "State"
msgstr "Estado"

View File

@ -156,29 +156,33 @@ class Maintenance(Workflow, ModelSQL, ModelView):
'Equipment Maintenance'
__name__ = 'optical_equipment.maintenance'
_states={'required': True}
service_maintenance = fields.Many2One('optical_equipment_maintenance.service', "Maintenance Service",
ondelete='CASCADE', select=True)
code = fields.Char(
"Code", select=True,states={'readonly': True })
maintenance_type = fields.Selection([('preventive', 'Preventive'),
('corrective', 'Corrective')
], "Maintenance Type")
], "Maintenance Type", states=_states)
state = fields.Selection([('draft', "Draft"),
('finished', "Finished")
], "State",required=True, readonly=True, sort=False)
], "State", readonly=True, sort=False,
states=_states)
company = fields.Many2One('company.company', "Company", readonly=True)
propietary = fields.Many2One('party.party', "Propietary",
propietary = fields.Many2One('party.party', "Propietary", states=_states,
depends=['service_maintenance'])
propietary_address = fields.Many2One('party.address', "Propietary Address",
states=_states,
domain=[('party', '=', Eval('propietary'))],
depends=['service_maintenance'])
equipment = fields.Many2One('optical_equipment.equipment', "Equipment", required=True,
equipment = fields.Many2One('optical_equipment.equipment', "Equipment",
domain=[('propietary', '=', Eval('propietary'))],
states=_states,
depends=['service_maintenance'])
#when the maintenance is in agended status
diary = fields.One2Many('optical_equipment_maintenance.diary', 'diary')
diary = fields.One2Many('optical_equipment_maintenance.diary', 'diary',
states=_states)
#estimated_agended = fields.DateTime("Date Maintenance")
#state_agended = fields.Selection([('no_agenda', "No agenda"),
# ('agended', "Agended"),
@ -195,7 +199,7 @@ class Maintenance(Workflow, ModelSQL, ModelView):
clean_eyes = fields.Boolean("Limpieza de lentes y espejos")
optical = fields.Boolean("Optical")
check_calibration = fields.Boolean("Verificar Calibración")
maintenance_activity = fields.One2Many('optical_equipment_maintenance.activity', 'maintenance', "Maintenance Activitys")
maintenance_activity = fields.One2Many('optical_equipment_maintenance.activity', 'maintenance', "Maintenance Activitys", states=_states)
#Calibration
patterns_equipments = fields.Char("K Pattern", states={'readonly': True},
depends=['equipment'])
@ -230,7 +234,7 @@ class Maintenance(Workflow, ModelSQL, ModelView):
cls._buttons.update({
'in_progress': {'invisible': Eval('state').in_(['draft', 'in_progress', 'finished'])},
'finished': {'invisible': Eval('state').in_(['finished'])},
'calibrate': {'invisible': Eval('lines_calibration') == () | Eval('state') == 'finished'}
'calibrate': {'invisible': (Eval('lines_calibration') == () | Eval('state').in_(['finished']),)}
})
@classmethod
@ -699,12 +703,18 @@ class CreateContract(Wizard):
dates = self._subscription_start
prorogues = (maintenance_service,)
equipments = []
for equipment in maintenance_service.lines:
equipments.append(equipment.id)
contract = Contract(party=dates['party'],
invoice_address=dates['invoice_address'],
contact=dates['contact'],
start_date=dates['start_date'],
end_date=dates['end_date'],
maintenance_services=prorogues
maintenance_services=prorogues,
equipments=equipments
)
contract.save()

View File

@ -156,27 +156,31 @@ class Template(metaclass=PoolMeta):
warranty = fields.Integer("Warranty")
#### calibration parameters
MEP = fields.Float("MEP")
uncertainy_pattern = fields.Float("Uncertainy Pattern",
MEP = fields.Float("MEP", states={'required': Eval('calibration', False)},)
uncertainy_pattern = fields.Float("Uncertainy Pattern", states={'required': Eval('calibration', True)},
help="Agregar valores separados por ',' Ej:-5,+5,-10,+10")
k_pattern = fields.Char("K Pattern",
k_pattern = fields.Char("K Pattern",states={'required': Eval('calibration', False)},
help="Agregar valores separados por ',' Ej:-5,+5,-10,+10")
k_pattern_list = fields.One2Many('optical_equipment.product_pattern', 'product', "List of patterns K")
k_pattern_list = fields.One2Many('optical_equipment.product_pattern', 'product', "List of patterns K",
states={'required': Eval('calibration', False)},)
resolution_type = fields.Selection([('',""),
('analoga', "Analoga"),
('digital', "Digital")], "Resolution Type",
states={'required': Eval('calibration', False)},
depends=['calibration'])
d_resolution = fields.Float("Resolution d",
states={'invisible': If(Eval('resolution_type') != 'digital', True)},
states={'invisible': If(Eval('resolution_type') != 'digital', True),
'required': Eval('calibration', False)},
depends=['resolution_type'])
analog_resolution = fields.Float("Analog resolution",
states={'invisible': If(Eval('resolution_type') != 'analoga', True)},
states={'invisible': If(Eval('resolution_type') != 'analoga', True),
'required': Eval('calibration', False)},
depends=['resolution_type'])
a_factor_resolution = fields.Float("(a) Resolution",
states={'invisible': If(Eval('resolution_type') != 'analoga', True)},
states={'invisible': If(Eval('resolution_type') != 'analoga', True),
'required': Eval('calibration', False)},
depends=['resolution_type'])
Usubi = fields.Integer("Usub i")
Usubi = fields.Integer("Usub i",states={'required': Eval('calibration', False)},)
@classmethod

View File

@ -25,22 +25,20 @@ this repository contains the full copyright notices and license terms. -->
<field name="maintenance_services"/>
</page>
<page string="Equipments" id="equipments">
<!--
<field name="equipments"/>
-->
<field name="equipments"/>
</page>
<page string="Other Info" id="other">
<label name="company"/>
<field name="company"/>
</page>
</page>
</notebook>
<label name="state"/>
<field name="state"/>
<group col="2" colspan="2" id="button">
<!--<button name="draft"/> -->
<!--
<button name="quotation"/>
<button name="run"/>
<button name="cancelled"/>
<button name="running"/>
-->
</group>
</form>

View File

@ -12,5 +12,8 @@ this repository contains the full copyright notices and license terms. -->
<newline/>
<label name="agended_sequence"/>
<field name="agended_sequence"/>
<newline/>
<label name="contract_sequence"/>
<field name="contract_sequence"/>
</form>