Skip to content

Commit

Permalink
fixup! [ADD] New module grap_custom_import_product
Browse files Browse the repository at this point in the history
  • Loading branch information
legalsylvain committed Jan 19, 2024
1 parent 684586d commit 26e285c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
26 changes: 19 additions & 7 deletions grap_custom_import_product/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,22 @@ def _custom_import_handle_supplierinfo_vals(self, old_vals, new_vals):
"res.partner", "name", old_vals, "grap_import_supplier_name"
)
if supplier:
new_vals["seller_ids"] = [
(
0,
False,
self._custom_import_prepare_supplierinfo_vals(supplier, old_vals),
)
]
new_vals.update(
{
"seller_ids": [
(
0,
False,
self._custom_import_prepare_supplierinfo_vals(
supplier, old_vals
),
)
],
"standard_price": self._custom_import_prepare_standard_price(
old_vals
),
}
)

def _custom_import_prepare_supplierinfo_vals(self, partner, vals):
return {
Expand All @@ -56,3 +65,6 @@ def _custom_import_prepare_supplierinfo_vals(self, partner, vals):
"product_name": vals.get("grap_import_supplier_product_name"),
"min_qty": vals.get("grap_import_supplier_min_qty"),
}

def _custom_import_prepare_standard_price(self, vals):
return vals.get("grap_import_supplier_gross_price")
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name,uom_id,categ_id,barcode,list_price,grap_import_supplier_name,grap_import_supplier_product_code,grap_import_supplier_product_name,grap_import_supplier_gross_price
Coca Cola (Import),Units,All / Saleable / Office Furniture,5000112602791,4.12,Ready Mat,CC,BOTTLE 33CL,3.33
Coca Cola (Import),Units,All / Saleable / Office Furniture,5000112602791,4.12,Coke Corp,CC,BOTTLE 33CL,3.33
Produit B,Units,All / Saleable / Office Furniture,,8.00,Supplier From Product Import,PB,product_B,6.00
Produit C,Units,All / Saleable,,2.30,,,,
7 changes: 6 additions & 1 deletion grap_custom_import_product/tests/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@ def test_01_import_product(self):
)
self.assertFalse(messages)
self.assertEqual(len(products), 3)
self.assertIn("Coca Cola (Import)", products.mapped("name"))
coca_cola = products.filtered(lambda x: x.name == "Coca Cola (Import)")
self.assertEqual(len(coca_cola), 1)
self.assertEqual(coca_cola.standard_price, 3.33)
self.assertEqual(coca_cola.mapped("seller_ids.partner_id.name"), ["Coke Corp"])
self.assertEqual(coca_cola.mapped("seller_ids.product_code"), ["CC"])
self.assertEqual(coca_cola.mapped("seller_ids.product_name"), ["BOTTLE 33CL"])

0 comments on commit 26e285c

Please sign in to comment.