add reports

This commit is contained in:
sinergia 2023-04-03 13:50:50 -05:00
parent 35c74076b5
commit b387f2b10b
18 changed files with 33251 additions and 0 deletions

1440
locale/es.po Normal file

File diff suppressed because it is too large Load Diff

255
move.py Normal file
View File

@ -0,0 +1,255 @@
from trytond.model import fields, ModelSQL, ModelView, Workflow, dualmethod
from trytond.modules.company import CompanyReport
from trytond.modules.company.model import employee_field, set_employee
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval, If
from trytond.exceptions import UserError
from itertools import groupby
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'))
],
states={'invisible': If(~Eval('product_equipment'), True),
'readonly': (Eval('state').in_(['cancelled', 'done'])),},
depends=['product_equipment'])
equipment_serial = fields.Function(fields.Char('Serial',
states={'readonly': True,
'invisible': If(~Eval('product_equipment'), True)},
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:
return True
else:
return False
@fields.depends('equipment')
def get_equipment_serial(self, equipment):
if self.equipment:
return self.equipment.serial
else:
return None
@fields.depends('product', 'equipment', 'uom')
def on_change_product(self):
if self.product:
if (not self.uom
or self.uom.category != self.product.default_uom.category):
self.uom = self.product.default_uom
@fields.depends(methods=['get_equipment_serial'])
def on_change_equipment(self):
if self.equipment:
self.product = self.equipment.product.id
self.equipment_serial = self.get_equipment_serial(self.equipment)
else:
self.equipment_serial = None
class ShipmentOut(metaclass=PoolMeta):
"Customer Shipment"
__name__ = 'stock.shipment.out'
service_maintenance_initial = fields.Boolean('Maintenance Initial', states={'readonly': True})
sale_type = fields.Char('Type sale origin')
@classmethod
def __setup__(cls):
super(ShipmentOut, cls).__setup__()
cls._buttons.update({
'maintenance_initial': {
'invisible': ((Eval('service_maintenance_initial',True))
| (Eval('sale_type').in_(['maintenance', 'replaces'])))}
})
@classmethod
def view_attributes(cls):
return super(ShipmentOut, cls).view_attributes() + [
('//page[@name="inventory_moves"]', 'states', {
'invisible': False,
}),]
@classmethod
@ModelView.button
@Workflow.transition('done')
@set_employee('done_by')
def done(cls, shipments):
pool = Pool()
Move = pool.get('stock.move')
Date = pool.get('ir.date')
Equipments = pool.get('optical_equipment.equipment')
for shipment in shipments:
for move in shipment.inventory_moves:
count = 0
if move.equipment:
equipment = move.equipment
Id = equipment.id
equipment = Equipments.search(['id', '=',Id])[0]
equipment.propietary = shipment.customer.id
equipment.propietary_address= shipment.delivery_address.id
equipment.state="uncontrated"
equipment.shipment_destination = shipment
equipment.sale_destination = shipment.outgoing_moves[count].origin
equipment.propietarys += (shipment.customer,)
equipment.maintenance_frequency = "6" if shipment.customer.client_type == "ips" else "12"
count+=1
equipment.save()
else:
count+=1
Move.delete([
m for s in shipments for m in s.outgoing_moves
if m.state == 'staging'])
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,
})
@classmethod
@ModelView.button
def maintenance_initial(cls, shipments):
pool = Pool()
MaintenanceService = pool.get('optical_equipment_maintenance.service')
Maintenance = pool.get('optical_equipment.maintenance')
SaleLine = pool.get('sale.line')
Equipments = pool.get('optical_equipment.equipment')
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,
state='draft')
maintenanceService.save()
serial = False
for move in shipment.inventory_moves:
if move.product_equipment and move.equipment:
serial = True
elif not move.product_equipment:
serial = True
else:
serial = False
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,
equipment_calibrate= True if move.equipment.product.calibration else False,
propietary_address=shipment.delivery_address.id,
equipment=move.equipment.id,
initial_operation = move.equipment.product.initial_operation,
check_equipment = move.equipment.product.template.check_equipment,
check_electric_system = move.equipment.product.template.check_electric_system,
clean_int_ext = move.equipment.product.template.clean_int_ext,
clean_eyes = move.equipment.product.template.clean_eyes,
check_calibration = move.equipment.product.template.check_calibration,
temperature_min = maintenanceService.temperature_min,
temperature_max = maintenanceService.temperature_max,
temperature_uom = maintenanceService.temperature_uom.id,
moisture_min = maintenanceService.moisture_min,
moisture_max = maintenanceService.moisture_max,
moisture_uom = maintenanceService.moisture_uom.id)
maintenance.save()
shipment.service_maintenance_initial = True
shipment.save()
else:
raise UserError(str('Por favor Primero debe Asignar un serial a todos los Equipos.'))
class ShipmentInternal(metaclass=PoolMeta):
'Shipment Interncal'
__name__ = 'stock.shipment.internal'
@classmethod
@ModelView.button
@Workflow.transition('done')
@set_employee('done_by')
def done(cls, shipments):
pool = Pool()
Move = pool.get('stock.move')
Date = pool.get('ir.date')
for shipment in shipments:
for move in shipment.moves:
if move.equipment:
move.equipment.location = shipment.to_location
move.equipment.save()
Move.do([m for s in shipments for m in s.incoming_moves])
cls.write([s for s in shipments if not s.effective_date], {
'effective_date': Date.today(),})
class ShipmentOutReturn(metaclass=PoolMeta):
"Customer Shipment Return"
__name__ = 'stock.shipment.out.return'
service_maintenance_initial = fields.Boolean('Maintenance Initial', states={'readonly': True})
sale_type = fields.Char('Type sale origin')
class PickingListDeliveryReport(CompanyReport):
__name__ = 'stock.shipment.out.picking_list1'
@classmethod
def execute(cls, ids, data):
with Transaction().set_context(address_with_party=True):
return super(PickingListDeliveryReport, cls).execute(ids, data)
@classmethod
def get_context(cls, records, header, data):
pool = Pool()
Date = pool.get('ir.date')
context = super().get_context(records, header, data)
context['today'] = Date.today()
return context
class CapacitationReport(CompanyReport):
__name__ = 'stock.shipment.out.capacitation_note'
@classmethod
def execute(cls, ids, data):
with Transaction().set_context(address_with_party=True):
return super(CapacitationReport, cls).execute(ids, data)
@classmethod
def get_context(cls, records, header, data):
pool = Pool()
Date = pool.get('ir.date')
context = super().get_context(records, header, data)
context['today'] = Date.today()
return context

42
move.xml Normal file
View File

@ -0,0 +1,42 @@
<?xml version="1.0"?>
<!--This file file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<record model="ir.ui.view" id="move_view_list_shipment">
<field name="model">stock.move</field>
<field name="inherit" ref="stock.move_view_list_shipment"/>
<field name="name">move_list_shipment</field>
</record>
<record model="ir.ui.view" id="move_view_form">
<field name="model">stock.move</field>
<field name="inherit" ref="stock.move_view_form"/>
<field name="name">move_form</field>
</record>
<record model="ir.model.button" id="maintenance_initial_button">
<field name="name">maintenance_initial</field>
<field name="string">Maintenance Initial</field>
<field name="model" search="[('model', '=', 'stock.shipment.out')]"/>
</record>
<record model="ir.action.report" id="report_shipment_out_picking_list1">
<field name="name">Acta Entrega</field>
<field name="model">stock.shipment.out</field>
<field name="report_name">stock.shipment.out.picking_list1</field>
<field name="report">optical_equipment/report/Delivery_Certificated.fodt</field>
</record>
<record model="ir.action.keyword" id="report_shipment_out_picking_list1_keyword">
<field name="keyword">form_print</field>
<field name="model">stock.shipment.out,-1</field>
<field name="action" ref="report_shipment_out_picking_list1"/>
</record>
<record model="ir.action.report" id="report_capacitation">
<field name="name">Capacitation</field>
<field name="model">stock.shipment.out</field>
<field name="report_name">stock.shipment.out.picking_list1</field>
<field name="report">optical_equipment/report/Capacitation.fodt</field>
</record>
<record model="ir.action.keyword" id="report_capacitation_keyword">
<field name="keyword">form_print</field>
<field name="model">stock.shipment.out,-1</field>
<field name="action" ref="report_capacitation"/>
</record>
</tryton>

1606
report/CV_Equipment.fodt Normal file

File diff suppressed because it is too large Load Diff

1944
report/Calibration.fodt Normal file

File diff suppressed because it is too large Load Diff

1170
report/Capacitation.fodt Normal file

File diff suppressed because it is too large Load Diff

4943
report/Contract.fodt Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1596
report/Purchase.fodt Normal file

File diff suppressed because it is too large Load Diff

5221
report/Sale.fodt Normal file

File diff suppressed because it is too large Load Diff

5698
report/Sale_Internal.fodt Normal file

File diff suppressed because it is too large Load Diff

10
shipment.xml Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!--This file file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<record model="ir.ui.view" id="shipment_out_view_form">
<field name="model">stock.shipment.out</field>
<field name="inherit" ref="stock.shipment_out_view_form"/>
<field name="name">shipment_out_form</field>
</record>
</tryton>

12
view/move_form.xml Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="/form/field[@name='product']" position="after">
<newline/>
<label name="equipment"/>
<field name="equipment"/>
<label name="equipment_serial"/>
<field name="equipment_serial"/>
</xpath>
</data>

View File

@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<data>
<xpath
expr="//field[@name='product']" position="after">
<field name="equipment"/>
<field name="equipment_serial"/>
</xpath>
</data>

View File

@ -0,0 +1,14 @@
<?xml version="1.0"?>
<!--This file file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. -->
<data>
<xpath
expr="//field[@name='warehouse']" position="after">
<newline/>
<label name="service_maintenance_initial"/>
<field name="service_maintenance_initial"/>
</xpath>
<xpath
expr="//button[@name='wait']" position="after">
<button name="maintenance_initial"/>
</xpath>
</data>