class MyMapper(Component): _name = "my.mapper" _inherit = "base.import.mapper" direct = [ (none(convert("in_f", bool)), "out_f"), (none(convert("in_t", bool)), "out_t"), ]
class MyMapper(Component): _name = 'my.mapper' _inherit = 'base.export.mapper' direct = [('field', 'field2'), ('no_field', 'no_field2'), (convert('name', int), 'out_name')]
class SaleOrderLineImportMapper(Component): _name = 'ambugest.sale.order.line.import.mapper' _inherit = 'ambugest.import.mapper' _apply_on = 'ambugest.sale.order.line' direct = [ ('EMPRESA', 'ambugest_empresa'), ('Fecha_Servicio', 'ambugest_fecha_servicio'), ('Codigo_Servicio', 'ambugest_codigo_servicio'), ('Servicio_Dia', 'ambugest_servicio_dia'), ('Servicio_Ano', 'ambugest_servicio_ano'), ('Articulo', 'ambugest_articulo'), (convert('Cantidad', float), 'product_uom_qty'), ] @only_create @mapping def backend_id(self, record): return {'backend_id': self.backend_record.id} @mapping def product(self, record): external_id = (record['EMPRESA'], record['Articulo']) binder = self.binder_for('ambugest.product.product') product = binder.to_internal(external_id, unwrap=True) assert product, ("product_id %s should have been imported in " "ProductProductImporter._import_dependencies" % (external_id, )) return {'product_id': product.id}
class MyMapper(Component): _name = "my.mapper" _inherit = "base.export.mapper" direct = [ ("field", "field2"), ("no_field", "no_field2"), (convert("name", int), "out_name"), ]
class MyMapper(Component): _name = 'my.mapper' _inherit = 'base.export.mapper' direct = [('street', 'out_street'), (none('in_t'), 'out_t'), (none(convert('in_f', bool)), 'out_f')] @changed_by('name', 'city') @mapping def name(self): pass @changed_by('email') @mapping def email(self): pass def no_decorator(self): pass
class SaleOrderLineImportMapper(Component): _name = 'oxigesti.sale.order.line.import.mapper' _inherit = 'oxigesti.import.mapper' _apply_on = 'oxigesti.sale.order.line' direct = [ (convert('Cantidad', float), 'product_uom_qty'), ] @only_create @mapping def backend_id(self, record): return {'backend_id': self.backend_record.id} @only_create @mapping def external_id(self, record): adapter = self.component(usage='backend.adapter') external_id = [record[f] for f in adapter._id] return {'external_id': external_id} @mapping def product(self, record): oxigesti_articulo = record['CodigoArticulo'] binding = self.env['oxigesti.product.product'].with_context( active_test=False).search([ ('company_id', '=', self.backend_record.company_id.id), ('default_code', '=', oxigesti_articulo), ]) if not binding: raise AssertionError("Product %s should have been exported in " "SaleOrderLineExporter._sync_dependencies" % (oxigesti_articulo, )) if len(binding) > 1: raise AssertionError("Found more than 1 products (%i) with " "the same code (%s) in Odoo: %s" % (len(binding), oxigesti_articulo, binding.mapped('odoo_id.id'))) return {'product_id': binding.odoo_id.id}
class MyMapper(Component): _name = "my.mapper" _inherit = "base.export.mapper" direct = [ ("street", "out_street"), (none("in_t"), "out_t"), (none(convert("in_f", bool)), "out_f"), ] @changed_by("name", "city") @mapping def name(self): pass @changed_by("email") @mapping def email(self): pass def no_decorator(self): pass
class HelpScoutConversationImportMapper(Component): _name = 'helpscout.import.mapper.conversation' _inherit = 'helpscout.import.mapper' _apply_on = 'helpscout.conversation' direct = [ (none('type'), 'helpscout_type'), (convert('number', str), 'code'), (none('subject'), 'name'), ] @mapping @only_create def odoo_id(self, record): conversation = self.env['project.task'].search([ ('code', '=', str(record.number)), ]) if conversation: return {'odoo_id': conversation.id} @mapping def helpscout_folder_id(self, record): folder = self.env['helpscout.helpscout.folder'].search([ ('external_id', '=', record.folder_id), ]) if folder: return {'helpscout_folder_id': folder.id} @mapping def partner_id(self, record): customer = self.env['helpscout.customer'].search([ ('external_id', '=', record.customer.id), ]) partner = customer.odoo_id return {'partner_id': partner.id} @mapping def project_id(self, record): mailbox = self.env['helpscout.mailbox'].search([ ('external_id', '=', record.mailbox.id), ]) project = mailbox.odoo_id if project: return {'project_id': project.id} @mapping def stage_id(self, record): stage = self.env.ref('connector_helpscout.status_%s' % record.status) if stage: return {'stage_id': stage.id} @mapping def tag_ids(self, record): tag_bindings = self.env['helpscout.tag'].search([ ('name', 'in', record.tags), ('backend_id', '=', self.backend_record.id), ]) if len(tag_bindings) != len(record.tags): self.env['helpscout.tag'].import_batch(self.backend_record) return self.tag_ids(record) tags = tag_bindings.mapped('odoo_id') if tags: return {'tag_ids': [(6, 0, tags.ids)]} @mapping def user_id(self, record): try: owner = self.env['helpscout.user'].search([ ('external_id', '=', record.owner.id), ]) except AttributeError: # in case a user/owner has not been assigned to the ticket return {'user_id': False} user = owner.odoo_id return {'user_id': user.id}
class MyMapper(Component): _name = "my.mapper" _inherit = "base.import.mapper" direct = [(convert("name", int), "out_name")]
class MyMapper(Component): _name = 'my.mapper' _inherit = 'base.import.mapper' direct = [(none(convert('in_f', bool)), 'out_f'), (none(convert('in_t', bool)), 'out_t')]
class MyMapper(Component): _name = 'my.mapper' _inherit = 'base.import.mapper' direct = [(convert('name', int), 'out_name')]