-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] New module grap_custom_import_product
- Loading branch information
1 parent
ed1cac0
commit 1473e22
Showing
13 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright (C) 2019 - Today: GRAP (http://www.grap.coop) | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
"name": "GRAP - Custom Import Product Module", | ||
"summary": "Extra GRAP Tools to import data for product module", | ||
"version": "16.0.1.0.0", | ||
"category": "Tools", | ||
"author": "GRAP", | ||
"website": "https://github.com/grap/grap-odoo-import", | ||
"license": "AGPL-3", | ||
"depends": ["grap_custom_import_base", "product"], | ||
"auto_install": True, | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import product_product |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ResPartner(models.Model): | ||
_name = "product.product" | ||
_inherit = ["product.product", "custom.import.mixin"] | ||
|
||
def _custom_import_prevent_duplicate_fields(self): | ||
res = super()._custom_import_prevent_duplicate_fields() | ||
res += ["name", "barcode"] | ||
return res | ||
|
||
grap_import_supplier_name = fields.Char( | ||
string="Supplier Name (For import)", store=False | ||
) | ||
grap_import_supplier_product_code = fields.Char( | ||
string="Product Code - Supplier (For import)", store=False | ||
) | ||
grap_import_supplier_product_name = fields.Char( | ||
string="Product Name - Supplier (For import)", store=False | ||
) | ||
grap_import_supplier_min_qty = fields.Monetary( | ||
string="Product Min Quantity - Supplier (For import)", store=False | ||
) | ||
grap_import_supplier_gross_price = fields.Monetary( | ||
string="Product Gross Price - Supplier (For import)", store=False | ||
) | ||
|
||
# pylint: disable=missing-return | ||
def _custom_import_hook_vals(self, old_vals, new_vals): | ||
super()._custom_import_hook_vals(old_vals, new_vals) | ||
self._custom_import_handle_supplierinfo_vals(old_vals, new_vals) | ||
|
||
def _custom_import_handle_supplierinfo_vals(self, old_vals, new_vals): | ||
supplier = self._custom_import_get_or_create( | ||
"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), | ||
) | ||
] | ||
|
||
def _custom_import_prepare_supplierinfo_vals(self, partner, vals): | ||
return { | ||
"partner_id": partner.id, | ||
"price": vals.get("grap_import_supplier_gross_price"), | ||
"product_code": vals.get("grap_import_supplier_product_code"), | ||
"product_name": vals.get("grap_import_supplier_product_name"), | ||
"min_qty": vals.get("grap_import_supplier_min_qty"), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Sylvain LE GAL <https://twitter.com/legalsylvain> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
This module improve the "import" features provided by Odoo. | ||
|
||
It provides generic tools for that purpose, and improve imports for some models. | ||
|
||
* ``product.product``: | ||
|
||
* Prevent to create duplicates regarding ``name`` and ``barcode`` fields. | ||
|
||
* Allow to create main ``seller_ids``, based on supplier information fields. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_module |
4 changes: 4 additions & 0 deletions
4
grap_custom_import_product/tests/templates/product.product/product.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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 | ||
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,,,, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo.tests import tagged | ||
|
||
from odoo.addons.grap_custom_import_base.tests.test_module import TestModuleBase | ||
|
||
|
||
@tagged("post_install", "-at_install") | ||
class TestModuleProduct(TestModuleBase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.ProductProduct = cls.env["product.product"] | ||
|
||
def test_01_import_product(self): | ||
products, messages = self._test_import_file( | ||
"grap_custom_import_product", "product.product", "product.csv" | ||
) | ||
self.assertFalse(messages) | ||
self.assertEqual(len(products), 3) | ||
self.assertIn("Coca Cola (Import)", products.mapped("name")) |
1 change: 1 addition & 0 deletions
1
setup/grap_custom_import_product/odoo/addons/grap_custom_import_product
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../grap_custom_import_product |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |