diff --git a/equipment.py b/equipment.py index ecf9127..46acf12 100644 --- a/equipment.py +++ b/equipment.py @@ -100,17 +100,37 @@ class OpticalEquipment(DeactivableMixin, Workflow, ModelSQL, ModelView): states=_states,) maintenance_frequency = fields.Selection(_MAINTENANCE_FREQUENCY, "Maintenance Frequency", - depends=['propietary']) - + depends=['propietary'] + ) purchase_origin = fields.Reference("Purchase Origin", selection='get_origin',select=True, - states={'readonly': True}) - + states={'readonly': True} + ) sale_destination = fields.Reference("Sale Destination", selection='get_destination',select=True, - states={'readonly': True}) - + states={'readonly': True} + ) + shipment_destination = fields.Reference("Stock Move", selection='get_shipment', select=True) del _states_serial, _states, _depends + @staticmethod + def _get_shipment(): + 'Return list of Model names for shipment Reference' + return [ + 'stock.shipment.in', + 'stock.shipment.out', + 'stock.shipment.out.return', + 'stock.shipment.in.return', + 'stock.shipment.internal', + ] + + @classmethod + def get_shipment(cls): + IrModel = Pool().get('ir.model') + get_name = IrModel.get_name + models = cls._get_shipment() + + return [(None, '')] + [(m, get_name(m)) for m in models] + @classmethod def _get_origin(cls): 'Return list of Model names for origin Reference' @@ -119,13 +139,6 @@ class OpticalEquipment(DeactivableMixin, Workflow, ModelSQL, ModelView): return [Purchase.__name__] - - @property - def origin_name(self): - if isinstance(self.origin, self.__class__): - return self.origin.invoice.rec_name - return self.origin.rec_name if self.origin else None - @classmethod def get_origin(cls): Model = Pool().get('ir.model') diff --git a/move.py b/move.py index cc003df..5b0fab7 100644 --- a/move.py +++ b/move.py @@ -1,11 +1,38 @@ -from trytond.model import fields +from trytond.model import fields, ModelSQL, ModelView, Workflow, dualmethod +from trytond.modules.company.model import employee_field, set_employee from trytond.pool import Pool, PoolMeta +from trytond.pyson import Eval, If + class Move(metaclass=PoolMeta): "Stock Move" __name__ = "stock.move" - serial = fields.Char('Serial') + equipment = fields.Many2One('optical_equipment.equipment', "Equipment", + domain=[('state', '=', 'registred'), + ('product','=', Eval('product')) + ], + states={'invisible': If(~Eval('product_equipment'), True)},) + + equipment_serial = fields.Char('Serial',states={'readonly': True}) + + + @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 + + + + def on_change_equipment(self): + if self.equipment: + self.product = self.equipment.product.id + self.equipment_serial = self.equipment.serial + + else: + self.equipment_serial = None @@ -13,6 +40,46 @@ class ShipmentOut(metaclass=PoolMeta): "Customer Shipment" __name__ = 'stock.shipment.out' + + @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') + + + pool = Pool() + Equipments = pool.get('optical_equipment.equipment') + + for shipment in shipments: + for move in shipment.moves: + if move.product.equipment: + equipment=move.serial + equipment.propietary=shipment.customer.id + equipment.propietary_address= shipment.delivery_address.id + equipment.state="uncontrated" + equipment.shipment_destination = move + equipment.maintenance_frequency = "6" if sale.party.client_type == "ips" else "12" + equipment.save() + + 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, + }) + def _get_inventory_move(self, move): 'Return inventory move for the outgoing move if necessary' pool = Pool() @@ -34,7 +101,6 @@ class ShipmentOut(metaclass=PoolMeta): from_location=self.warehouse_storage, to_location=move.from_location, product=move.product, - serial=move.serial, uom=move.uom, quantity=quantity, shipment=self, diff --git a/product.py b/product.py index 8c4da01..65edd2d 100644 --- a/product.py +++ b/product.py @@ -286,10 +286,10 @@ class Template(metaclass=PoolMeta): def default_refurbish(): return False + @fields.depends('software_required', 'software_version') - def on_change_sotfware_required(self): - if self.software_required: - self.software_version = None + def on_change_with_sotfware_required(self): + self.software_version = None @fields.depends('d_resolution', 'analog_resolution', 'a_factor_resolution') def on_change_resolution_type(self): diff --git a/report/cv.fods b/report/cv.fods index ad2e9ae..8adc2dc 100644 --- a/report/cv.fods +++ b/report/cv.fods @@ -1,20 +1,20 @@ - 2022-08-10T10:58:31.2601834272022-08-15T13:50:42.372740894PT5H41M3S65LibreOffice/7.2.7.2$Linux_X86_64 LibreOffice_project/20$Build-2 + 2022-08-10T10:58:31.2601834272022-08-19T13:56:37.618632316PT6H17M10S80LibreOffice/7.2.7.2$Linux_X86_64 LibreOffice_project/20$Build-2 - 0 + 199 199 - 21856 - 27042 + 23677 + 28792 view1 - 0 - 0 + 1 + 26 0 0 0 @@ -23,10 +23,10 @@ 0 0 0 - 40 + 19 0 180 - 60 + 180 true false @@ -35,8 +35,8 @@ 1845 0 180 - 60 - false + 180 + true true true true @@ -95,7 +95,7 @@ false Generic Printer false - pAH+/0dlbmVyaWMgUHJpbnRlcgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAU0dFTlBSVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWAAMAxQAAAAAAAAAIAFZUAAAkbQAASm9iRGF0YSAxCnByaW50ZXI9R2VuZXJpYyBQcmludGVyCm9yaWVudGF0aW9uPVBvcnRyYWl0CmNvcGllcz0xCmNvbGxhdGU9ZmFsc2UKbWFyZ2luYWRqdXN0bWVudD0wLDAsMCwwCmNvbG9yZGVwdGg9MjQKcHNsZXZlbD0wCnBkZmRldmljZT0xCmNvbG9yZGV2aWNlPTAKUFBEQ29udGV4dERhdGEKUGFnZVNpemU6TGV0dGVyAER1cGxleDpOb25lAAASAENPTVBBVF9EVVBMRVhfTU9ERQ8ARHVwbGV4TW9kZTo6T2Zm + pAH+/0dlbmVyaWMgUHJpbnRlcgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAU0dFTlBSVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWAAMAxQAAAAAAAAAIAFZUAAAkbQAASm9iRGF0YSAxCnByaW50ZXI9R2VuZXJpYyBQcmludGVyCm9yaWVudGF0aW9uPVBvcnRyYWl0CmNvcGllcz0xCmNvbGxhdGU9ZmFsc2UKbWFyZ2luYWRqdXN0bWVudD0wLDAsMCwwCmNvbG9yZGVwdGg9MjQKcHNsZXZlbD0wCnBkZmRldmljZT0xCmNvbG9yZGV2aWNlPTAKUFBEQ29udGV4dERhdGEKRHVwbGV4Ok5vbmUAUGFnZVNpemU6TGV0dGVyAAASAENPTVBBVF9EVVBMRVhfTU9ERQ8ARHVwbGV4TW9kZTo6T2Zm false 1000 1000 @@ -590,7 +590,7 @@ - + @@ -602,12 +602,9 @@ - - - - + @@ -617,15 +614,18 @@ - + - + + + + @@ -769,10 +769,15 @@ + + + + + - + @@ -784,7 +789,7 @@ - + @@ -809,6 +814,11 @@ + + + + + @@ -824,27 +834,22 @@ - + - - - - - - - - - - + + + + + @@ -854,7 +859,7 @@ - + @@ -876,17 +881,22 @@ - + + + + + + - + - + @@ -916,6 +926,10 @@ + + + + @@ -925,6 +939,11 @@ + + + + + @@ -969,11 +988,6 @@ - - - - - @@ -990,11 +1004,6 @@ - - - - - @@ -1005,12 +1014,17 @@ + + + + + - + @@ -1025,7 +1039,7 @@ - + @@ -1050,7 +1064,7 @@ - + @@ -1122,7 +1136,7 @@ ???(???) - 00/00/0000, 00:00:00 + 00/00/0000, 00:00:00 @@ -1138,13 +1152,13 @@ - + - + - + /9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoM DAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsN @@ -1675,33 +1689,38 @@ - + + + + + + - - - - - - + + + + + + + for each="equipment in records" - - - + + - + - + @@ -1717,6 +1736,11 @@ + + + + + @@ -1729,18 +1753,16 @@ HOJA DE VIDA DISPOSITIVOS BIOMEDICOS - - - + + - - - + + @@ -1748,14 +1770,14 @@ Código Equipo - equipment.code + equipment.code Salida de Equipo - + @@ -1763,9 +1785,8 @@ - - - + + @@ -1773,9 +1794,8 @@ INFORMACION DEL PROPIETARIO - - - + + @@ -1800,9 +1820,9 @@ Documento: - equipment.propietary.tax_identifier.code + equipment.propietary.tax_identifier.code - + @@ -1825,25 +1845,32 @@ - + Dirección: - equipment.propietary_address.street + equipment.propietary_address.street + + + + + Telefono: - equipment.propietary.phone + equipment.propietary.phone - - + + + + - + choose test="" @@ -1852,12 +1879,12 @@ - + - + when test="equipment.propietary_address.party_related" @@ -1866,7 +1893,7 @@ - + @@ -1878,7 +1905,7 @@ equipment.propietary_address.party_related.name - + @@ -1898,126 +1925,136 @@ - + /choose - - + - + - - + - + INFORMACION DEL DISPOSITIVO - - - + + - + - + Nombre Dispositivo: - equipment.product.name + equipment.product.name - - - - Nuevo / Usado + + + + + + + + + + Restaurado: - "SI" if equipment.refurbish else "NO" + "SI" if equipment.refurbish else "NO" + + + + - + Marca: - equipment.mark_category.name + equipment.mark_category.name - + Modelo: - equipment.model_category.name + equipment.model_category.name - + - + Referencia: - equipment.reference_category.name + equipment.reference_category.name - + País Origen: - equipment.origin_country.name + equipment.origin_country.name - + - + - + Registro Invima - equipment.health_register + equipment.health_register - + Software Version - equipment.software_version + equipment.software_version if equipment.software_version != "" else "No Aplica" - - + + - + - - Fabricante - - - - + Serial: - equipment.serial + equipment.serial - - + + + + + Clase de Riesgo: + + equipment.product.risk + + + - + Tipo: @@ -2025,44 +2062,38 @@ equipment.equipment_type - - - Clase de Riesgo: - - equipment.risk - - - - - - - - - - Uso: - - equipment.use - - - + Clase Biomedica: equipment.biomedical_class - - - - + + + + + + + + Uso: + + equipment.use + + + + + + + - + Garantía: - equipment.warranty Meses + equipment.warranty Meses @@ -2070,37 +2101,36 @@ Vida útil: - equipment.useful_life Meses + equipment.useful_life Meses - + - + - + - + CARACTERISTICAS TECNICAS - - - + + - + Caracteristicas Físicas @@ -2109,7 +2139,7 @@ Peso - str(equipment.product.weight) + " "+ equipment.product.weight_uom.symbol + str(equipment.product.weight) + " "+ equipment.product.weight_uom.symbol @@ -2137,7 +2167,7 @@ Voltaje (VAC) - str(equipment.product.voltageAC) + " "+ equipment.product.voltageAC_uom.symbol + str(equipment.product.voltageAC) + " "+ equipment.product.voltageAC_uom.symbol @@ -2150,7 +2180,7 @@ Voltaje (VDC) - str(equipment.product.voltageDC) + " "+ equipment.product.voltageDC_uom.symbol + str(equipment.product.voltageDC) + " "+ equipment.product.voltageDC_uom.symbol @@ -2165,7 +2195,7 @@ Temperatura Min Uso - str(equipment.product.temperature_min) + " "+ equipment.product.temperature_uom.symbol + str(equipment.product.temperature_min) + " "+ equipment.product.temperature_uom.symbol @@ -2178,7 +2208,7 @@ Temperatura Max Uso - str(equipment.product.temperature_max) + " "+ equipment.product.temperature_uom.symbol + str(equipment.product.temperature_max) + " "+ equipment.product.temperature_uom.symbol @@ -2191,7 +2221,7 @@ Humedad Min Uso - str(equipment.product.moisture_min) + " "+ equipment.product.moisture_uom.symbol + str(equipment.product.moisture_min) + " "+ equipment.product.moisture_uom.symbol @@ -2204,7 +2234,7 @@ Humedad Max Uso - str(equipment.product.moisture_max) + " "+ equipment.product.moisture_uom.symbol + str(equipment.product.moisture_max) + " "+ equipment.product.moisture_uom.symbol @@ -2216,7 +2246,7 @@ - + MANTENIMIENTO @@ -2237,22 +2267,20 @@ - + - + Frecuencia de Mantenimiento Preventivo: - equipment.maintenance_frequency Meses + equipment.maintenance_frequency Meses - - Frecuencia de Calibración del Equipo: - - - - + + + + @@ -2264,115 +2292,115 @@ - + Imagen - - + - + - - + + - - - + + + + - - - + + + + - - - + + + + - - - + + + + - - - + + + + - - - + + + + - - - + + + + - - - + + + + - + + - - - - - - - - - - + + - + Responsable: diff --git a/sale.py b/sale.py index 561a8f5..3bed1ff 100644 --- a/sale.py +++ b/sale.py @@ -18,6 +18,7 @@ class Sale(metaclass=PoolMeta): 'Sale' __name__ = 'sale.sale' + """ @classmethod @ModelView.button @Workflow.transition('confirmed') @@ -47,7 +48,8 @@ class Sale(metaclass=PoolMeta): queue_name='sale', queue_scheduled_at=config.sale_process_after): cls.__queue__.process(sales) - + """ + class SaleLine(metaclass=PoolMeta): 'SaleLine' __name__ = 'sale.line' @@ -106,9 +108,10 @@ class SaleLine(metaclass=PoolMeta): if self.product_equipment == False: self.equipment = None self.on_change_equipment() + """ else: self.quantity = 1 - + """ @fields.depends('product', 'unit', 'quantity', 'sale', diff --git a/view/move_form.xml b/view/move_form.xml index d470067..a9e6d2c 100644 --- a/view/move_form.xml +++ b/view/move_form.xml @@ -4,7 +4,9 @@ this repository contains the full copyright notices and license terms. --> - diff --git a/view/move_list_shipment.xml b/view/move_list_shipment.xml index d189157..0e42c39 100644 --- a/view/move_list_shipment.xml +++ b/view/move_list_shipment.xml @@ -3,6 +3,7 @@ - + + diff --git a/view/optical_equipment_form.xml b/view/optical_equipment_form.xml index 294d42f..eafeba6 100644 --- a/view/optical_equipment_form.xml +++ b/view/optical_equipment_form.xml @@ -64,6 +64,8 @@ + +