diff --git a/fiscal_company_product/README.rst b/fiscal_company_product/README.rst index 14c047e..e69de29 100644 --- a/fiscal_company_product/README.rst +++ b/fiscal_company_product/README.rst @@ -1,83 +0,0 @@ -============= -CAE - Product -============= - -.. - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! This file is generated by oca-gen-addon-readme !! - !! changes will be overwritten. !! - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:d3db2ab38cb55d96485d2b22ddb080cc5e0c6272d0b6e4d647044ee548b6d51f - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png - :target: https://odoo-community.org/page/development-status - :alt: Beta -.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html - :alt: License: AGPL-3 -.. |badge3| image:: https://img.shields.io/badge/github-grap%2Fodoo--addons--cae-lightgray.png?logo=github - :target: https://github.com/grap/odoo-addons-cae/tree/12.0/fiscal_company_product - :alt: grap/odoo-addons-cae - -|badge1| |badge2| |badge3| - -This module extend Odoo functionnalities, regarding companies features to -manage CAE (Coopearatives of Activities and Employment) that is a special -status for french companies. - -This module is a glue module for the Odoo Product module. - -**Features** - -* User in mother company can see product of all child company -* User in fiscal company can see but not update / delete product - of mother company -* Add a field ```cae_administrative_ok``` on ```product.product```. if checked - the product will not be updatable by non 'CAE Manager' users - -**Table of contents** - -.. contents:: - :local: - -Bug Tracker -=========== - -Bugs are tracked on `GitHub Issues `_. -In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. - -Do not contact contributors directly about support or help with technical issues. - -Credits -======= - -Authors -~~~~~~~ - -* GRAP - -Contributors -~~~~~~~~~~~~ - -* Julien WESTE -* Sylvain LE GAL - -Other credits -~~~~~~~~~~~~~ - -The development of this module has been financially supported by: - -* GRAP, Groupement Régional Alimentaire de Proximité (http://www.grap.coop) - -Porting from odoo V8 to odoo V10 has been funded by : - * BABEL.COOP, leverage cooperation through the digital age () - -Maintainers -~~~~~~~~~~~ - -This module is part of the `grap/odoo-addons-cae `_ project on GitHub. - -You are welcome to contribute. diff --git a/fiscal_company_product/__manifest__.py b/fiscal_company_product/__manifest__.py index f59b01b..035a2e9 100644 --- a/fiscal_company_product/__manifest__.py +++ b/fiscal_company_product/__manifest__.py @@ -4,25 +4,13 @@ { "name": "CAE - Product", - "version": "12.0.1.1.1", + "version": "16.0.1.0.0", "category": "CAE", "summary": "Glue Module between CAE and Product modules", "author": "GRAP", "website": "https://github.com/grap/odoo-addons-cae", "license": "AGPL-3", "depends": ["fiscal_company_base", "product"], - "data": [ - "security/res_groups.xml", - "security/ir.model.access.csv", - "security/ir_rule.xml", - "views/view_product_template.xml", - ], - "demo": [ - "demo/res_groups.xml", - "demo/product_pricelist.xml", - "demo/product_template.xml", - "demo/product_product.xml", - ], "installable": True, "auto_install": True, } diff --git a/fiscal_company_product/demo/product_pricelist.xml b/fiscal_company_product/demo/product_pricelist.xml deleted file mode 100644 index 7c41289..0000000 --- a/fiscal_company_product/demo/product_pricelist.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - CH1 - Main Sale Pricelist - - - - - CH2 - Main Sale Pricelist - - - - diff --git a/fiscal_company_product/demo/product_product.xml b/fiscal_company_product/demo/product_product.xml deleted file mode 100644 index dc9184a..0000000 --- a/fiscal_company_product/demo/product_product.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - CAE - Mother Product Variant - - - - - - CH1 - Child 1 Product Variant - - - - - diff --git a/fiscal_company_product/demo/product_template.xml b/fiscal_company_product/demo/product_template.xml deleted file mode 100644 index 87ef00f..0000000 --- a/fiscal_company_product/demo/product_template.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - CAE - Mother Product Template - - - - - - CH1 - Child 1 Product Template - - - - - - CAE - Administrative Mother Product Template - - - - - - diff --git a/fiscal_company_product/demo/res_groups.xml b/fiscal_company_product/demo/res_groups.xml deleted file mode 100644 index 42800be..0000000 --- a/fiscal_company_product/demo/res_groups.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/fiscal_company_product/i18n/fr.po b/fiscal_company_product/i18n/fr.po index 9e71512..e69de29 100644 --- a/fiscal_company_product/i18n/fr.po +++ b/fiscal_company_product/i18n/fr.po @@ -1,104 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * fiscal_company_product -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-26 14:34+0000\n" -"PO-Revision-Date: 2019-09-26 14:34+0000\n" -"Last-Translator: <>\n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: \n" - -#. module: fiscal_company_product -#: model:product.template,name:fiscal_company_product.product_template_administrative -msgid "CAE - Administrative Mother Product Template" -msgstr "CAE - Produit administratif de la société mère" - -#. module: fiscal_company_product -#: model:product.template,name:fiscal_company_product.product_template_child -msgid "CH1 - Child 1 Product Template" -msgstr "CAE - Article de la société CH1" - -#. module: fiscal_company_product -#: model:product.product,name:fiscal_company_product.product_product_child -#: model:product.template,name:fiscal_company_product.product_product_child_product_template -msgid "CH1 - Child 1 Product Variant" -msgstr "CH1 - Variante d'article de la société CH1" - -#. module: fiscal_company_product -#: model:product.template,name:fiscal_company_product.product_template_mother -msgid "CAE - Mother Product Template" -msgstr "CAE - Article de la société mère" - -#. module: fiscal_company_product -#: model:product.product,name:fiscal_company_product.product_product_mother -#: model:product.template,name:fiscal_company_product.product_product_mother_product_template -msgid "CAE - Mother Product Variant" -msgstr "CAE - Variante d'article de la société mère" - -#. module: fiscal_company_product -#: model:product.pricelist,name:fiscal_company_product.sale_product_pricelist_CH1 -msgid "CH1 - Main Sale Pricelist" -msgstr "CH1 - Liste de prix par défaut" - -#. module: fiscal_company_product -#: model:product.pricelist,name:fiscal_company_product.sale_product_pricelist_CH2 -msgid "CH2 - Main Sale Pricelist" -msgstr "CH2 - Liste de prix par défaut" - -#. module: fiscal_company_product -#: model:ir.model.fields,help:fiscal_company_product.field_product_product__cae_administrative_ok -#: model:ir.model.fields,help:fiscal_company_product.field_product_template__cae_administrative_ok -msgid "If checked, this product will be readonly for users and updatable only by specific group" -msgstr "Si cette case est cochée, cet article sera en lecture seul pour les utilisateurs, et modifiable seulement par les membres d'un groupe spécifique" - -#. module: fiscal_company_product -#: model:ir.model.fields,field_description:fiscal_company_product.field_product_product__cae_administrative_ok -#: model:ir.model.fields,field_description:fiscal_company_product.field_product_template__cae_administrative_ok -msgid "Is CAE Administrative" -msgstr "Est administratif" - -#. module: fiscal_company_product -#: model:res.groups,name:fiscal_company_product.product_creation -msgid "Product Creation" -msgstr "Création d'articles" - -#. module: fiscal_company_product -#: model:ir.model,name:fiscal_company_product.model_product_template -msgid "Product Template" -msgstr "Modèle d'article" - -#. module: fiscal_company_product -#: model:product.product,uom_name:fiscal_company_product.product_product_child -#: model:product.product,uom_name:fiscal_company_product.product_product_mother -#: model:product.template,uom_name:fiscal_company_product.product_product_child_product_template -#: model:product.template,uom_name:fiscal_company_product.product_product_mother_product_template -#: model:product.template,uom_name:fiscal_company_product.product_template_administrative -#: model:product.template,uom_name:fiscal_company_product.product_template_child -#: model:product.template,uom_name:fiscal_company_product.product_template_mother -msgid "Unit(s)" -msgstr "Unité(s)" - -#. module: fiscal_company_product -#: code:addons/fiscal_company_product/models/product_template.py:43 -#, python-format -msgid "You have no right to create or update an administrative product" -msgstr "Nous n'avez pas le droit de créer ou de modifier un produit de type Administratif CAE" - -#. module: fiscal_company_product -#: model:product.product,weight_uom_name:fiscal_company_product.product_product_child -#: model:product.product,weight_uom_name:fiscal_company_product.product_product_mother -#: model:product.template,weight_uom_name:fiscal_company_product.product_product_child_product_template -#: model:product.template,weight_uom_name:fiscal_company_product.product_product_mother_product_template -#: model:product.template,weight_uom_name:fiscal_company_product.product_template_administrative -#: model:product.template,weight_uom_name:fiscal_company_product.product_template_child -#: model:product.template,weight_uom_name:fiscal_company_product.product_template_mother -msgid "kg" -msgstr "kg" - diff --git a/fiscal_company_product/models/__init__.py b/fiscal_company_product/models/__init__.py index e8fa8f6..98b218e 100644 --- a/fiscal_company_product/models/__init__.py +++ b/fiscal_company_product/models/__init__.py @@ -1 +1,2 @@ from . import product_template +from . import product_pricelist diff --git a/fiscal_company_product/models/product_pricelist.py b/fiscal_company_product/models/product_pricelist.py new file mode 100644 index 0000000..403e944 --- /dev/null +++ b/fiscal_company_product/models/product_pricelist.py @@ -0,0 +1,12 @@ +# 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 ProductPricelist(models.Model): + _name = "product.pricelist" + _inherit = ["product.pricelist", "fiscal.company.check.company.mixin"] + + _fiscal_company_forbid_fiscal_type = ["group", "fiscal_mother"] diff --git a/fiscal_company_product/models/product_template.py b/fiscal_company_product/models/product_template.py index 73f2e40..047f725 100644 --- a/fiscal_company_product/models/product_template.py +++ b/fiscal_company_product/models/product_template.py @@ -1,61 +1,12 @@ -# Copyright (C) 2014-Today: GRAP (http://www.grap.coop) +# 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 _, api, fields, models -from odoo.exceptions import ValidationError +from odoo import models class ProductTemplate(models.Model): - _inherit = "product.template" + _name = "product.template" + _inherit = ["product.template", "fiscal.company.check.company.mixin"] - # Columns Section - cae_administrative_ok = fields.Boolean( - string="Is CAE Administrative", - help="If checked, this product will be readonly for users and" - " updatable only by specific group", - ) - - # Overload Section - @api.model - def create(self, vals): - if vals.get("cae_administrative_ok", False): - self._check_administrative_access() - return super().create(vals) - - @api.multi - def write(self, vals): - forbidden_fields = [ - key - for key in vals.keys() - if key not in self._allowed_fields_cae_administrative() - ] - if forbidden_fields and ( - vals.get("cae_administrative_ok", False) - or any(self.mapped("cae_administrative_ok")) - ): - self._check_administrative_access() - return super().write(vals) - - @api.multi - def unlink(self): - if any(self.mapped("cae_administrative_ok")): - self._check_administrative_access() - return super().unlink() - - # Custom Section - @api.model - def _check_administrative_access(self): - if not self.env.user.has_group("fiscal_company_base.fiscal_company_manager"): - raise ValidationError( - _("You have no right to create or update an" " administrative product") - ) - - def _allowed_fields_cae_administrative(self): - return [ - "seller_ids", - "print_category_id", - "lst_price", - "to_print", - "standard_price", - ] + _fiscal_company_forbid_fiscal_type = ["group", "fiscal_mother"] diff --git a/fiscal_company_product/readme/CREDITS.rst b/fiscal_company_product/readme/CREDITS.rst deleted file mode 100644 index 26111c6..0000000 --- a/fiscal_company_product/readme/CREDITS.rst +++ /dev/null @@ -1,6 +0,0 @@ -The development of this module has been financially supported by: - -* GRAP, Groupement Régional Alimentaire de Proximité (http://www.grap.coop) - -Porting from odoo V8 to odoo V10 has been funded by : - * BABEL.COOP, leverage cooperation through the digital age () diff --git a/fiscal_company_product/readme/DESCRIPTION.rst b/fiscal_company_product/readme/DESCRIPTION.rst index f39c20f..e005e1c 100644 --- a/fiscal_company_product/readme/DESCRIPTION.rst +++ b/fiscal_company_product/readme/DESCRIPTION.rst @@ -6,8 +6,5 @@ This module is a glue module for the Odoo Product module. **Features** -* User in mother company can see product of all child company -* User in fiscal company can see but not update / delete product - of mother company -* Add a field ```cae_administrative_ok``` on ```product.product```. if checked - the product will not be updatable by non 'CAE Manager' users +* Add constrains on ``product.product``, ``product.pricelist`` + to create such items on a fiscal mother company or a group. diff --git a/fiscal_company_product/security/ir.model.access.csv b/fiscal_company_product/security/ir.model.access.csv deleted file mode 100644 index c501842..0000000 --- a/fiscal_company_product/security/ir.model.access.csv +++ /dev/null @@ -1,6 +0,0 @@ -id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -,,,,,,, -access_pricelist_manager,pricelist CAE manager,product.model_product_pricelist,fiscal_company_base.fiscal_company_manager,1,1,1,1 -access_pricelist_item_manager,pricelist Item CAE manager,product.model_product_pricelist_item,fiscal_company_base.fiscal_company_manager,1,1,1,1 -access_product_product_maganer,access_product_product_maganer,product.model_product_product,fiscal_company_product.product_creation,1,1,1,1 -access_product_template_maganer,access_product_template_maganer,product.model_product_template,fiscal_company_product.product_creation,1,1,1,1 diff --git a/fiscal_company_product/security/ir_rule.xml b/fiscal_company_product/security/ir_rule.xml deleted file mode 100644 index daaef47..0000000 --- a/fiscal_company_product/security/ir_rule.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - product.template CAE company - - [ - '|', '|', - ('company_id', '=', False), - ('company_id', 'child_of', [user.company_id.id]), - ('company_id', '=', user.company_id.fiscal_company_id.id), - ] - - - diff --git a/fiscal_company_product/security/res_groups.xml b/fiscal_company_product/security/res_groups.xml deleted file mode 100644 index 224c917..0000000 --- a/fiscal_company_product/security/res_groups.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - Product Creation - - - - diff --git a/fiscal_company_product/tests/__init__.py b/fiscal_company_product/tests/__init__.py deleted file mode 100644 index d9b96c4..0000000 --- a/fiscal_company_product/tests/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import test_module diff --git a/fiscal_company_product/tests/test_module.py b/fiscal_company_product/tests/test_module.py deleted file mode 100644 index caff96b..0000000 --- a/fiscal_company_product/tests/test_module.py +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (C) 2018 - 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.exceptions import ValidationError -from odoo.tests.common import TransactionCase - - -class TestModule(TransactionCase): - """Tests for 'CAE - Product' Module""" - - # Overload Section - def setUp(self): - super().setUp() - self.ProductProduct = self.env["product.product"] - self.user_accountant = self.env.ref("fiscal_company_base.user_accountant") - self.user_worker = self.env.ref("fiscal_company_base.user_worker") - self.child_company = self.env.ref("fiscal_company_base.company_fiscal_child_1") - self.product_categ = self.env.ref("product.product_category_1") - - # Dirty Hack: - # Accountant can create a product, but can't create a product.history. - # (ugly Odoo ORM !) - # So, we set a correct setting for that model for our tests. - self.access = self.env.ref("product.access_product_price_history_employee") - self.access.perm_create = True - - # Test Section - def test_01_administrative_product_creation(self): - """[Functional Test] Test constraint again Administrative product""" - - # Try to create an administrative product with user that is - # CAE manager, should success - product = self._create_administrative_product(self.user_accountant) - - # Try to create an administrative product with user that is not - # CAE manager, should fail - with self.assertRaises(ValidationError): - self._create_administrative_product(self.user_worker) - - # Try to write on administrative product with user that is not - # CAE manager should fail if the field is protected - with self.assertRaises(ValidationError): - product.sudo(self.user_worker).write({"name": "New name"}) - - # Try to write on administrative product with user that is not - # CAE manager should success if the field is not protected - with self.assertRaises(ValidationError): - product.sudo(self.user_worker).write({"lst_price": 5.0}) - - def _create_administrative_product(self, user): - product_vals = { - "name": "Product Test", - "company_id": self.child_company.id, - "categ_id": self.product_categ.id, - "cae_administrative_ok": True, - } - user.company_id = self.child_company.id - return ( - self.ProductProduct.sudo(user) - .with_context(mail_create_nosubscribe=True, mail_create_nolog=True) - .create(product_vals) - ) diff --git a/fiscal_company_product/views/view_product_template.xml b/fiscal_company_product/views/view_product_template.xml deleted file mode 100644 index 258970d..0000000 --- a/fiscal_company_product/views/view_product_template.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - product.template - - - - - - - - -