# -*- coding: utf-8 -*- from openerp import models, fields, api class RepairWorkorder(models.Model): _inherit = 'repair.workorderimproved' @api.model def getRepairWorkorder(self,domain): RepairWorkorder = self.env['repair.workorderimproved'].search(domain) values = [] for workorder in RepairWorkorder: try: street = workorder.partner_id.street except Exception as e: street = '' values.append({ # ID 'id': workorder.id, # WORKORDER INFO 'name': workorder.name or "", 'user_name': workorder.user_id.name or "", 'responsable': workorder.responsable or "", 'movil': workorder.movil or "", 'name_obra': workorder.name_obra or "", 'nro_factura': workorder.nro_factura or "", 'name_local': workorder.name_local or "", 'contacto_obra': workorder.contacto_obra or "", 'causes': workorder.causes or "", 'order_date': workorder.order_date or "", 'planned_start_date': workorder.planned_start_date or "", 'planned_end_date': workorder.planned_end_date or "", 'recommendations': workorder.recommendations or "", 'emergente': workorder.emergente or "", 'actions': workorder.actions or "", 'date_service': workorder.date_service or "", # PARTNER INFO 'partner_id': workorder.partner_id.id or "", 'partner_name': workorder.partner_id.name or "", 'partner_ruc': workorder.partner_id.ruc or "", 'partner_address': street or "", 'partner_phone': workorder.partner_id.phone or "", 'partner_mobile': workorder.partner_id.mobile or "", # COMPANY INFO 'company_id': workorder.user_id.company_id.id or "", 'company_name': workorder.user_id.company_id.name or "", 'company_logo': workorder.user_id.company_id.logo or "", 'company_address': workorder.user_id.company_id.street2 or "", 'company_phone': workorder.user_id.company_id.phone or "", 'vat': workorder.user_id.company_id.vat or "", }) return values class RepairWorkorderLine(models.Model): _inherit = 'repair.workorderimproved.line' @api.model def getRepairWorkorderLine(self,domain): RepairWorkorderLine = self.env['repair.workorderimproved.line'].search(domain) values = [] for line in RepairWorkorderLine: values.append({ # ID 'id': line.id, # LINE INFO 'workorder_id': line.workorder_id.id, 'description': line.description or "", 'quantity': line.quantity or "", 'brand': line.brand or "", 'number': line.number or "", }) return values class RepairPedidosorderLine(models.Model): _inherit = 'repair.pedidosorderimproved.line' @api.model def getRepairPedidosorderLine(self,domain): RepairPedidosorderLine = self.env['repair.pedidosorderimproved.line'].search(domain) values = [] for line in RepairPedidosorderLine: values.append({ # ID 'id': line.id, # LINE INFO 'workorder_id': line.workorder_id.id, 'description': line.description or "", 'quantity': line.quantity or "", 'brand': line.brand or "", 'number': line.number or "", }) return values class RepairResumenorderLine(models.Model): _inherit = 'repair.resumenorderimproved.line' @api.model def getRepairResumenorderLine(self,domain): RepairResumenorderLine = self.env['repair.resumenorderimproved.line'].search(domain) values = [] for line in RepairResumenorderLine: values.append({ # ID 'id': line.id, # LINE INFO 'workorder_id': line.workorder_id.id, 'description': line.description or "", }) return values class RepairCalidadorderLine(models.Model): _inherit = 'repair.calidadorderimproved.line' @api.model def getRepairCalidadorderLine(self,domain): RepairCalidadorderLine = self.env['repair.calidadorderimproved.line'].search(domain) values = [] for line in RepairCalidadorderLine: values.append({ # ID 'id': line.id, # LINE INFO 'workorder_id': line.workorder_id.id, 'description': line.description or "", 'brand': line.brand or "", 'number': line.number or "", }) return values class RepairSugerenciaorderLine(models.Model): _inherit = 'repair.sugerenciaorderimproved.line' @api.model def getRepairSugerenciaorderLine(self,domain): RepairSugerenciaorderLine = self.env['repair.sugerenciaorderimproved.line'].search(domain) values = [] for line in RepairSugerenciaorderLine: values.append({ # ID 'id': line.id, # LINE INFO 'workorder_id': line.workorder_id.id, 'description': line.description or "", }) return values class RepairProblemasorderLine(models.Model): _inherit = 'repair.problemasorderimproved.line' @api.model def getRepairProblemasorderLine(self,domain): RepairProblemasorderLine = self.env['repair.problemasorderimproved.line'].search(domain) values = [] for line in RepairProblemasorderLine: values.append({ # ID 'id': line.id, # LINE INFO 'workorder_id': line.workorder_id.id, 'description': line.description or "", }) return values class RepairWorkorderConsumed(models.Model): _inherit = 'repair.workorderimproved.consumed' @api.model def getRepairWorkorderConsumed(self,domain): RepairWorkorderConsumed = self.env['repair.workorderimproved.consumed'].search(domain) values = [] for line in RepairWorkorderConsumed: values.append({ # ID 'id': line.id, # LINE INFO 'workorder_id': line.workorder_id.id, 'product_id':[ line.product_id.id, line.product_id.name, ], 'description': line.description or "", 'quantity': line.quantity or "", 'price_unit': line.price_unit or "", 'subtotal': line.subtotal or "", }) return values