-
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] fermente_custom_import_product_label
- Loading branch information
1 parent
f4bd6eb
commit 5b4cbf5
Showing
14 changed files
with
126 additions
and
0 deletions.
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 Product Import - Product Label Module", | ||
"summary": "Extra GRAP Tools to import product data for" " Product Label module", | ||
"version": "16.0.1.0.0", | ||
"category": "Tools", | ||
"author": "GRAP", | ||
"website": "https://github.com/grap/grap-odoo-import", | ||
"license": "AGPL-3", | ||
"depends": ["fermente_custom_import_product", "product_label"], | ||
"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,2 @@ | ||
from . import custom_import_product_mixin | ||
from . import product_template |
24 changes: 24 additions & 0 deletions
24
fermente_custom_import_product_label/models/custom_import_product_mixin.py
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,24 @@ | ||
# 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 models | ||
|
||
|
||
class CustomImportProductMixin(models.AbstractModel): | ||
_name = "custom.import.product.mixin" | ||
_inherit = ["custom.import.product.mixin"] | ||
|
||
# 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_product_label_vals(old_vals, new_vals) | ||
|
||
def _custom_import_handle_product_label_vals(self, old_vals, new_vals): | ||
label_ids = [] | ||
for x in range(1, 4): | ||
field_name = f"grap_import_label_{x}" | ||
if old_vals.get(field_name, False): | ||
label_ids.append(old_vals[field_name]) | ||
new_vals["label_ids"] = [(6, 0, label_ids)] | ||
# new_vals["label_ids"] = [Command.link(label_ids)] |
21 changes: 21 additions & 0 deletions
21
fermente_custom_import_product_label/models/product_template.py
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,21 @@ | ||
# 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 ProductTemplate(models.Model): | ||
_inherit = "product.template" | ||
|
||
grap_import_label_1 = fields.Many2one( | ||
comodel_name="product.label", string="Label 1 (For import)", store=False | ||
) | ||
|
||
grap_import_label_2 = fields.Many2one( | ||
comodel_name="product.label", string="Label 2 (For import)", store=False | ||
) | ||
|
||
grap_import_label_3 = fields.Many2one( | ||
comodel_name="product.label", string="Label 3 (For import)", store=False | ||
) |
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,5 @@ | ||
This module improve the "import" features provided by Odoo. | ||
|
||
* ``product.product``: | ||
|
||
* Allow to recover ``discount`` field in the supplier info level. |
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 |
3 changes: 3 additions & 0 deletions
3
fermente_custom_import_product_label/tests/templates/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,3 @@ | ||
name,uom_id,categ_id,grap_import_label_1,grap_import_label_2,grap_import_label_3 | ||
Product 1,Units,All / Saleable,Organic Food,Gluten Free, | ||
Product 2,Units,All / Saleable,,,Max Havelaar |
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,44 @@ | ||
# 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.fermente_custom_import_product.tests.test_module import ( | ||
TestModuleProduct, | ||
) | ||
|
||
|
||
@tagged("post_install", "-at_install") | ||
class TestModulePurchaseDiscount(TestModuleProduct): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.ProductProduct = cls.env["product.product"] | ||
cls.label_organic = cls.env.ref("product_label.label_agriculture_biologique") | ||
cls.label_gluten_free = cls.env.ref("product_label.label_gluten_free") | ||
cls.label_max_havelaar = cls.env.ref("product_label.label_max_havelaar") | ||
|
||
def _test_import_product_label(self, model): | ||
products, messages = self._test_import_file( | ||
"fermente_custom_import_product_label", | ||
model, | ||
"product.csv", | ||
folder="product", | ||
) | ||
self.assertFalse(messages) | ||
self.assertEqual(len(products), 2) | ||
|
||
product_1 = products.filtered(lambda x: x.name == "Product 1") | ||
self.assertEqual( | ||
product_1.label_ids, self.label_organic | self.label_gluten_free | ||
) | ||
|
||
product_2 = products.filtered(lambda x: x.name == "Product 2") | ||
self.assertEqual(product_2.label_ids, self.label_max_havelaar) | ||
|
||
def test_01_import_product_label_product(self): | ||
self._test_import_product_label("product.product") | ||
|
||
def test_02_import_product_label_template(self): | ||
self._test_import_product_label("product.template") |
1 change: 1 addition & 0 deletions
1
setup/fermente_custom_import_product_label/odoo/addons/fermente_custom_import_product_label
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 @@ | ||
../../../../fermente_custom_import_product_label |
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, | ||
) |