Skip to content

Commit

Permalink
[FIX] edi_voxel_sale_order_import: Search products from customerinfo
Browse files Browse the repository at this point in the history
Use the same technique for qualifying the product (but reversed) than
used on pickings:

- See if there's a product with the reference.
- If not, check for a customerinfo record with such code, first on
  the order partner, and if not found yet, on the commercial entity.

Note that here the CustomerSKU/SupplierSKU seems to be swapped from
their normal use in pickings/invoices according to empirical samples.

TT30469

Co-Authored-By: Pedro M. Baeza <[email protected]>
  • Loading branch information
sergio-teruel and pedrobaeza committed Jan 15, 2024
1 parent 0590350 commit 6b98ae4
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion edi_voxel_sale_order_import/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Voxel sale order",
"summary": "Import sale order from Voxel.",
"version": "13.0.1.0.2",
"version": "13.0.1.0.3",
"category": "Sale",
"author": "Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/edi",
Expand Down
22 changes: 21 additions & 1 deletion edi_voxel_sale_order_import/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,30 @@ def _parse_product_voxel(self, line_vals, line_element):
supplier_sku = product_data.get("SupplierSKU")
item = product_data.get("Item")
domains = []
product = self.env["res.partner"]
product = self.env["product.product"].browse()
if supplier_sku:
domains.append([("default_code", "=", supplier_sku)])
product = self.env["product.product"].search(domains[0])
if not product:
partner = (
self.env["sale.order"].browse(line_vals["order_id"]).partner_id
)
customerinfo = self.env["product.customerinfo"].search(
[("name", "=", partner.id), ("product_code", "=", supplier_sku)],
limit=1,
)
if not customerinfo:
customerinfo = self.env["product.customerinfo"].search(
[
("name", "=", partner.commercial_partner_id.id),
("product_code", "=", supplier_sku),
],
limit=1,
)
product = (
customerinfo.product_id
or customerinfo.product_tmpl_id.product_variant_ids[:1]
)
if len(product) != 1:
if item:
domains.append([("name", "=", item)])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def setUpClass(cls):
"zip": "43111",
"state_id": cls.env.ref("base.state_es_t").id,
"country_id": cls.env.ref("base.es").id,
"currency_id": pricelist_test.id,
"currency_id": pricelist_test.currency_id.id,
"vat": "ESA12345674",
}
)
Expand All @@ -37,11 +37,21 @@ def setUpClass(cls):
"ref": "F111",
"state_id": cls.env.ref("base.state_es_t").id,
"country_id": cls.env.ref("base.es").id,
"property_product_pricelist": pricelist_test.id,
}
)
cls.product_test_1 = cls.env["product.product"].create(
{"default_code": "111111", "name": "PRODUCT TEST"}
)
cls.supplierinfo_product_test_1 = cls.env["product.customerinfo"].create(
{
"name": cls.customer_test.id,
"product_tmpl_id": cls.product_test_1.product_tmpl_id.id,
"product_id": cls.product_test_1.id,
"product_code": "SP11111",
"product_name": "SUPPLIER PRODUCT TEST",
}
)
cls.product_test_2 = cls.env["product.product"].create(
{"default_code": "222222", "name": "PRODUCT TEST 2"}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</Customers>
<ProductList>
<Product
SupplierSKU="111111"
SupplierSKU="SP11111"
CustomerSKU="005555"
Item="PRODUCT TEST"
Qty="2.0"
Expand Down

0 comments on commit 6b98ae4

Please sign in to comment.