Skip to content

Commit 376c88f

Browse files
[MIG] edi_voxel_sale_order_import_oca: Migration to 18.0
TT54159
1 parent 38e192b commit 376c88f

10 files changed

Lines changed: 54 additions & 55 deletions

File tree

edi_voxel_sale_order_import_oca/README.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Note:
6060

6161
This module enqueue the imports in jobs in the background. To do that it
6262
uses queue_job module, so a configuration is required according to that.
63-
The jobs for impots are queued in the channel ``root.voxel_import``.
63+
The jobs for imports are queued in the channel ``root.voxel_import``.
6464

6565
Usage
6666
=====
@@ -98,6 +98,7 @@ Contributors
9898
- Ernesto Tejeda
9999
- Pedro M. Baeza
100100
- Sergio Teruel
101+
- Juan Carlos Oñate
101102

102103
Maintainers
103104
-----------

edi_voxel_sale_order_import_oca/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "Voxel sale order oca",
66
"summary": "Import sale order from Voxel.",
7-
"version": "15.0.1.0.1",
7+
"version": "18.0.1.0.0",
88
"category": "Sale",
99
"author": "Tecnativa, Odoo Community Association (OCA)",
1010
"website": "https://github.com/OCA/edi",

edi_voxel_sale_order_import_oca/data/ir_cron_data.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,5 @@
1010
<field name="user_id" ref="base.user_root" />
1111
<field name="interval_number">10</field>
1212
<field name="interval_type">minutes</field>
13-
<field name="numbercall">-1</field>
14-
<field eval="False" name="doall" />
1513
</record>
1614
</odoo>

edi_voxel_sale_order_import_oca/models/sale_order.py

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from lxml import etree
99

10-
from odoo import _, api, fields, models
10+
from odoo import api, fields, models
1111
from odoo.exceptions import UserError
1212
from odoo.osv import expression
1313

@@ -53,18 +53,17 @@ def create_document_from_xml(self, xml_content, voxel_filename, company):
5353
xml_content, voxel_filename, error_msgs, company
5454
)
5555
# Add internal note to the created sale order
56-
create_msg = _("Created automatically via voxel import (%s).") % voxel_filename
56+
create_msg = (
57+
self.env._("Created automatically via voxel import (%s).") % voxel_filename
58+
)
5759
if error_msgs:
5860
str_error_msgs = ""
5961
for error_msg in error_msgs:
60-
str_error_msgs += "<li>%s</li>" % error_msg
61-
create_msg += (
62-
_(
63-
"<br/><span style='font-weight: bold;'>"
64-
"The following errors were found:</span><br/>"
65-
"<ul>%s</ul>"
66-
)
67-
% str_error_msgs
62+
str_error_msgs += f"<li>{error_msg}</li>"
63+
create_msg += self.env._(
64+
"<br/><span style='font-weight: bold;'>"
65+
"The following errors were found:</span><br/>"
66+
f"<ul>{str_error_msgs}</ul>"
6867
)
6968
order.message_post(body=create_msg)
7069
return order
@@ -77,15 +76,20 @@ def _parse_voxel_order(self, order_file, order_filename, error_msgs, company):
7776
try:
7877
xml_root = etree.fromstring(order_file)
7978
except Exception as exc:
80-
raise UserError(_("This XML file is not XML-compliant")) from exc
79+
raise UserError(
80+
self.env._("This XML file is not XML-compliant")
81+
) from exc
8182
else:
82-
raise UserError(_("'%s' is not recognised as an XML file") % order_filename)
83-
_logger.debug("Starting to import:%s" % (order_filename))
83+
raise UserError(
84+
self.env._(f"'{order_filename}' is not recognised as an XML file")
85+
)
86+
_logger.debug(f"Starting to import:{order_filename}")
8487
try:
8588
return self._parse_xml_order(xml_root, error_msgs, company)
8689
except Exception as exc:
8790
raise UserError(
88-
_("Error creating the order") + f"\n\nFile contents:\n{order_file}"
91+
self.env._("Error creating the order")
92+
+ f"\n\nFile contents:\n{order_file}"
8993
) from exc
9094

9195
def _parse_xml_order(self, xml_root, error_msgs, company):
@@ -150,13 +154,12 @@ def _parse_supplier_data_voxel(self, vals, xml_root, error_msgs):
150154
# Add error message to error_msgs list
151155
msg_fields = self._get_voxel_msg_fields("res.partner", partner_data)
152156
error_msgs.append(
153-
_(
157+
self.env._(
154158
"Couldn't find any <b>Company</b> corresponding to "
155159
"the following information extracted from the Voxel "
156160
"document:<br/>"
157-
"<ul>%s</ul>"
161+
f"<ul>{msg_fields}</ul>"
158162
)
159-
% (msg_fields)
160163
)
161164

162165
def _parse_client_data_voxel(self, vals, xml_root, error_msgs):
@@ -199,13 +202,12 @@ def _parse_customers_data_voxel(self, vals, xml_root, error_msgs):
199202
# Add error message to error_msgs list
200203
msg_fields = self._get_voxel_msg_fields("res.partner", partner_data)
201204
error_msgs.append(
202-
_(
205+
self.env._(
203206
"Couldn't find any <b>Delivery Address</b> "
204207
"corresponding to the following information extracted "
205208
"from the Voxel document:<br/>"
206-
"<ul>%s</ul>"
209+
f"<ul>{msg_fields}</ul>"
207210
)
208-
% (msg_fields)
209211
)
210212

211213
def _parse_partner_data_voxel(self, data, raise_error=True):
@@ -236,7 +238,7 @@ def _parse_partner_data_voxel(self, data, raise_error=True):
236238
return partner # return the unique partner matching
237239
if raise_error:
238240
raise UserError(
239-
_(
241+
self.env._(
240242
"Can't find a suitable partner for this data:\n\n%(data)s"
241243
"\nResults: %(partner_count)s",
242244
data=data,
@@ -283,13 +285,16 @@ def _parse_product_voxel(self, line_vals, line_element):
283285
self.env["sale.order"].browse(line_vals["order_id"]).partner_id
284286
)
285287
customerinfo = self.env["product.customerinfo"].search(
286-
[("name", "=", partner.id), ("product_code", "=", supplier_sku)],
288+
[
289+
("partner_id", "=", partner.id),
290+
("product_code", "=", supplier_sku),
291+
],
287292
limit=1,
288293
)
289294
if not customerinfo:
290295
customerinfo = self.env["product.customerinfo"].search(
291296
[
292-
("name", "=", partner.commercial_partner_id.id),
297+
("partner_id", "=", partner.commercial_partner_id.id),
293298
("product_code", "=", supplier_sku),
294299
],
295300
limit=1,
@@ -306,11 +311,9 @@ def _parse_product_voxel(self, line_vals, line_element):
306311
product = self.env["product.product"].search(domain)
307312
if len(product) != 1:
308313
raise UserError(
309-
_(
310-
"Can't find a suitable product for this data:\n\n%(product_data)s"
311-
"\nResults: %(product_count)s",
312-
product_data=product_data,
313-
product_count=len(product),
314+
self.env._(
315+
f"Can't find a suitable product for this data:\n\n{product_data}"
316+
f"\nResults: {len(product)}",
314317
)
315318
)
316319
line_vals.update(product_id=product.id)
@@ -322,11 +325,10 @@ def _parse_qty_uom_voxel(self, line_vals, line_element):
322325
product_uom = self.env["uom.uom"].search([("voxel_code", "=", mu)])
323326
if len(product_uom) != 1:
324327
raise UserError(
325-
_(
326-
"Can't find a suitable Unit of Measure for this data:\n\n%(product_data)s"
327-
"\nResults: %(product_uom_count)s",
328-
product_data=product_data,
329-
product_uom_count=len(product_uom),
328+
self.env._(
329+
"Can't find a suitable Unit of Measure for this data:"
330+
f"\n\n{product_data}"
331+
f"\nResults: {len(product_uom)}"
330332
)
331333
)
332334
line_vals.update(product_uom_qty=qty, product_uom=product_uom.id)
@@ -360,13 +362,12 @@ def _parse_taxes_product_voxel(self, line_vals, line_element, error_msgs):
360362
tax_data = {"voxel_tax_code": voxel_tax_code, "amount": amount}
361363
msg_fields = self._get_voxel_msg_fields("account.tax", tax_data)
362364
error_msgs.append(
363-
_(
365+
self.env._(
364366
"Couldn't find any <b>Tax</b> corresponding to "
365367
"the following information extracted from the Voxel "
366368
"document:<br/>"
367-
"<ul>%s</ul>"
369+
f"<ul>{msg_fields}</ul>"
368370
)
369-
% (msg_fields)
370371
)
371372

372373
def _get_partner_data_voxel(self, data):

edi_voxel_sale_order_import_oca/readme/CONFIGURE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ Note:
1919

2020
This module enqueue the imports in jobs in the background. To do that it
2121
uses queue_job module, so a configuration is required according to that.
22-
The jobs for impots are queued in the channel `root.voxel_import`.
22+
The jobs for imports are queued in the channel `root.voxel_import`.

edi_voxel_sale_order_import_oca/readme/CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
- Ernesto Tejeda
33
- Pedro M. Baeza
44
- Sergio Teruel
5+
- Juan Carlos Oñate

edi_voxel_sale_order_import_oca/static/description/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
408408
<p>Note:</p>
409409
<p>This module enqueue the imports in jobs in the background. To do that it
410410
uses queue_job module, so a configuration is required according to that.
411-
The jobs for impots are queued in the channel <tt class="docutils literal">root.voxel_import</tt>.</p>
411+
The jobs for imports are queued in the channel <tt class="docutils literal">root.voxel_import</tt>.</p>
412412
</div>
413413
<div class="section" id="usage">
414414
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
@@ -441,6 +441,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
441441
<li>Ernesto Tejeda</li>
442442
<li>Pedro M. Baeza</li>
443443
<li>Sergio Teruel</li>
444+
<li>Juan Carlos Oñate</li>
444445
</ul>
445446
</li>
446447
</ul>

edi_voxel_sale_order_import_oca/tests/test_voxel_sale_order_import.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
from datetime import date, datetime
66

77
from odoo.modules.module import get_module_path
8-
from odoo.tests.common import TransactionCase
98

9+
from odoo.addons.base.tests.common import BaseCommon
1010

11-
class TestVoxelSaleOrderImportCommon(TransactionCase):
11+
12+
class TestVoxelSaleOrderImportCommon(BaseCommon):
1213
@classmethod
1314
def setUpClass(cls):
1415
super().setUpClass()
@@ -33,7 +34,7 @@ def setUpClass(cls):
3334
)
3435
cls.supplierinfo_product_test_1 = cls.env["product.customerinfo"].create(
3536
{
36-
"name": cls.customer_test.id,
37+
"partner_id": cls.customer_test.id,
3738
"product_tmpl_id": cls.product_test_1.product_tmpl_id.id,
3839
"product_id": cls.product_test_1.id,
3940
"product_code": "SP11111",

edi_voxel_sale_order_import_oca/views/res_config_settings_views.xml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@
66
<field name="name">res.config.settings.view.form.voxel.invoice</field>
77
<field name="model">res.config.settings</field>
88
<field name="inherit_id" ref="edi_voxel_oca.res_config_settings_view_form" />
9-
<field
10-
name="groups_id"
11-
eval="[(4, ref('edi_voxel_oca.group_voxel_manager'))]"
12-
/>
139
<field name="arch" type="xml">
1410
<xpath expr="//div[@name='voxel_login_config']" position="inside">
1511
<div class="row mt16">
1612
<label
1713
for="voxel_sale_order_login_id"
1814
class="col-lg-3 o_light_label"
1915
/>
20-
<field name="voxel_sale_order_login_id" />
16+
<field
17+
name="voxel_sale_order_login_id"
18+
groups="edi_voxel_oca.group_voxel_manager"
19+
/>
2120
</div>
2221
</xpath>
2322
</field>

edi_voxel_sale_order_import_oca/views/sale_order_views.xml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,13 @@
66
<field name="name">sale.order.view.form</field>
77
<field name="model">sale.order</field>
88
<field name="inherit_id" ref="sale.view_order_form" />
9-
<field
10-
name="groups_id"
11-
eval="[(4, ref('edi_voxel_oca.group_voxel_manager'))]"
12-
/>
139
<field name="arch" type="xml">
1410
<notebook>
1511
<page
1612
string="Voxel"
1713
name="page_voxel"
18-
attrs="{'invisible': [('voxel_xml_report', '=', False)]}"
14+
invisible="not voxel_xml_report"
15+
groups="edi_voxel_oca.group_voxel_manager"
1916
>
2017
<group name="group_voxel">
2118
<group>

0 commit comments

Comments
 (0)