From 007a47f8f79670bf395541cea4a5a14f9b4bc549 Mon Sep 17 00:00:00 2001 From: Jared Kipe Date: Mon, 2 Aug 2021 08:46:26 -0700 Subject: [PATCH] [IMP] connector_opencart: import comments, add group for comment review --- .../data/connector_opencart_data.xml | 5 +++++ .../models/sale_order/importer.py | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/connector_opencart/data/connector_opencart_data.xml b/connector_opencart/data/connector_opencart_data.xml index b575ec5d..bc703882 100644 --- a/connector_opencart/data/connector_opencart_data.xml +++ b/connector_opencart/data/connector_opencart_data.xml @@ -32,4 +32,9 @@ Check your taxes and fiscal positions configuration and correct them if necessar + + + Opencart Order Comment Reviewer + + diff --git a/connector_opencart/models/sale_order/importer.py b/connector_opencart/models/sale_order/importer.py index 312e9e11..7d7945a5 100644 --- a/connector_opencart/models/sale_order/importer.py +++ b/connector_opencart/models/sale_order/importer.py @@ -61,6 +61,7 @@ class SaleOrderImportMapper(Component): direct = [('order_id', 'external_id'), ('store_id', 'store_id'), + ('comment', 'note'), ] children = [('products', 'opencart_order_line_ids', 'opencart.sale.order.line'), @@ -367,12 +368,29 @@ class SaleOrderImporter(Component): **kwargs ) + def _order_comment_review(self, binding): + review_group = self.env.ref('connector_opencart.group_order_comment_review', raise_if_not_found=False) + if review_group and binding.note: + activity_type = self.env.ref('mail.mail_activity_data_todo', raise_if_not_found=False) + activity_type_id = activity_type.id if activity_type else False + for user in review_group.users: + self.env['mail.activity'].create({ + 'activity_type_id': activity_type_id, + 'summary': 'Order Comment Review', + 'note': '

' + binding.note + '

', # field is HTML, note is expected to be escaped + 'user_id': user.id, + 'res_id': binding.odoo_id.id, + 'res_model_id': self.env.ref('sale.model_sale_order').id, + }) + def _create(self, data): binding = super(SaleOrderImporter, self)._create(data) # Without this, it won't map taxes with the fiscal position. if binding.fiscal_position_id: binding.odoo_id._compute_tax_id() + self._order_comment_review(binding) + return binding def _import_dependencies(self):