From fb72ed971fc4f07b005e28303584e16d0aad5739 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Mon, 16 Jul 2018 13:05:14 +0200 Subject: [PATCH 01/22] [REF][WIP] rename modules --- fiscal_company_product/README.rst | 41 +++++++ fiscal_company_product/__init__.py | 2 + fiscal_company_product/__manifest__.py | 34 ++++++ .../demo/product_pricelist.xml | 23 ++++ .../demo/product_product.xml | 23 ++++ .../demo/product_template.xml | 30 +++++ fiscal_company_product/demo/res_company.xml | 16 +++ fiscal_company_product/demo/res_groups.xml | 23 ++++ fiscal_company_product/i18n/fr.po | 104 ++++++++++++++++++ fiscal_company_product/models/__init__.py | 6 + .../models/product_pricelist.py | 30 +++++ .../models/product_product.py | 27 +++++ .../models/product_template.py | 45 ++++++++ fiscal_company_product/models/res_company.py | 68 ++++++++++++ .../models/res_company_create_wizard.py | 39 +++++++ .../security/ir.model.access.csv | 4 + fiscal_company_product/security/ir_rule.xml | 24 ++++ .../static/description/icon.png | Bin 0 -> 6273 bytes fiscal_company_product/tests/__init__.py | 2 + .../tests/test_product_fiscal_company.py | 48 ++++++++ .../views/view_product_pricelist.xml | 30 +++++ .../views/view_product_pricelist_item.xml | 30 +++++ .../views/view_product_template.xml | 31 ++++++ 23 files changed, 680 insertions(+) create mode 100644 fiscal_company_product/README.rst create mode 100644 fiscal_company_product/__init__.py create mode 100644 fiscal_company_product/__manifest__.py create mode 100644 fiscal_company_product/demo/product_pricelist.xml create mode 100644 fiscal_company_product/demo/product_product.xml create mode 100644 fiscal_company_product/demo/product_template.xml create mode 100644 fiscal_company_product/demo/res_company.xml create mode 100644 fiscal_company_product/demo/res_groups.xml create mode 100644 fiscal_company_product/i18n/fr.po create mode 100644 fiscal_company_product/models/__init__.py create mode 100644 fiscal_company_product/models/product_pricelist.py create mode 100644 fiscal_company_product/models/product_product.py create mode 100644 fiscal_company_product/models/product_template.py create mode 100644 fiscal_company_product/models/res_company.py create mode 100644 fiscal_company_product/models/res_company_create_wizard.py create mode 100644 fiscal_company_product/security/ir.model.access.csv create mode 100644 fiscal_company_product/security/ir_rule.xml create mode 100644 fiscal_company_product/static/description/icon.png create mode 100644 fiscal_company_product/tests/__init__.py create mode 100644 fiscal_company_product/tests/test_product_fiscal_company.py create mode 100644 fiscal_company_product/views/view_product_pricelist.xml create mode 100644 fiscal_company_product/views/view_product_pricelist_item.xml create mode 100644 fiscal_company_product/views/view_product_template.xml diff --git a/fiscal_company_product/README.rst b/fiscal_company_product/README.rst new file mode 100644 index 0000000..a60e674 --- /dev/null +++ b/fiscal_company_product/README.rst @@ -0,0 +1,41 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +========================================================== +Manage Cooperatives of Activities and Employment - Product +========================================================== + + +This module extend Odoo functionnalities, regarding companies features to +manage CAE (Coopearatives of Activities and Employment) that is a special +status for french companies. + +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 + +Company Creation Wizard +----------------------- + +* Create a Sale Pricelist and the according property to + ```property_product_pricelist``` + +Installation +============ + +Normal installation. + +Credits +======= + +Contributors +------------ + +* Julien WESTE +* Sylvain LE GAL diff --git a/fiscal_company_product/__init__.py b/fiscal_company_product/__init__.py new file mode 100644 index 0000000..4213b8b --- /dev/null +++ b/fiscal_company_product/__init__.py @@ -0,0 +1,2 @@ +# -*- encoding: utf-8 -*- +from . import models diff --git a/fiscal_company_product/__manifest__.py b/fiscal_company_product/__manifest__.py new file mode 100644 index 0000000..34e1a4a --- /dev/null +++ b/fiscal_company_product/__manifest__.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2014-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': 'CAE - Product Fiscal Company', + 'version': '10.0.1.0.0', + 'category': 'CIS', + 'summary': 'Glue Module between CIS and product', + 'author': 'GRAP', + 'website': 'http://www.grap.coop', + 'license': 'AGPL-3', + 'depends': [ + 'base_fiscal_company', + 'product', + ], + 'data': [ + 'security/ir.model.access.csv', + 'security/ir_rule.xml', + 'views/view_product_template.xml', + 'views/view_product_pricelist.xml', + 'views/view_product_pricelist_item.xml', + ], + 'demo': [ + 'demo/res_groups.xml', + 'demo/product_pricelist.xml', + 'demo/product_template.xml', + 'demo/product_product.xml', + 'demo/res_company.xml', + ], + 'installable': True, + 'auto_install': True, +} diff --git a/fiscal_company_product/demo/product_pricelist.xml b/fiscal_company_product/demo/product_pricelist.xml new file mode 100644 index 0000000..bd2faf8 --- /dev/null +++ b/fiscal_company_product/demo/product_pricelist.xml @@ -0,0 +1,23 @@ + + + + + + + + + + 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 new file mode 100644 index 0000000..ad213f3 --- /dev/null +++ b/fiscal_company_product/demo/product_product.xml @@ -0,0 +1,23 @@ + + + + + + CAE - Mother Product Variant + + + + + + CAE - Child 1 Product Variant + + + + + + + diff --git a/fiscal_company_product/demo/product_template.xml b/fiscal_company_product/demo/product_template.xml new file mode 100644 index 0000000..93c75cd --- /dev/null +++ b/fiscal_company_product/demo/product_template.xml @@ -0,0 +1,30 @@ + + + + + + CAE - Mother Product Template + + + + + + CAE - Child 1 Product Template + + + + + + CAE - Administrative Mother Product Template + + + + + + + + diff --git a/fiscal_company_product/demo/res_company.xml b/fiscal_company_product/demo/res_company.xml new file mode 100644 index 0000000..1431c16 --- /dev/null +++ b/fiscal_company_product/demo/res_company.xml @@ -0,0 +1,16 @@ + + + + + + + + diff --git a/fiscal_company_product/demo/res_groups.xml b/fiscal_company_product/demo/res_groups.xml new file mode 100644 index 0000000..3c35399 --- /dev/null +++ b/fiscal_company_product/demo/res_groups.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + diff --git a/fiscal_company_product/i18n/fr.po b/fiscal_company_product/i18n/fr.po new file mode 100644 index 0000000..2712175 --- /dev/null +++ b/fiscal_company_product/i18n/fr.po @@ -0,0 +1,104 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_fiscal_company +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-02-13 09:53+0000\n" +"PO-Revision-Date: 2018-02-13 09:53+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: product_fiscal_company +#: code:addons/product_fiscal_company/models/res_company_create_wizard.py:27 +#, python-format +msgid "%s - Default Public Pricelist" +msgstr "%s - Default Public Pricelist" + +#. module: product_fiscal_company +#: code:addons/product_fiscal_company/models/res_company_create_wizard.py:39 +#, python-format +msgid "%s - Default Public Pricelist Line" +msgstr "%s - Default Public Pricelist Line" + +#. module: product_fiscal_company +#: code:addons/product_fiscal_company/models/res_company_create_wizard.py:34 +#, python-format +msgid "%s - Default Public Pricelist Version" +msgstr "%s - Default Public Pricelist Version" + +#. module: product_fiscal_company +#: model:product.pricelist,name:product_fiscal_company.sale_product_pricelist_CH1 +msgid "CH1 - Main Sale Pricelist" +msgstr "CH1 - Main Sale Pricelist" + +#. module: product_fiscal_company +#: model:product.pricelist.version,name:product_fiscal_company.sale_product_pricelist_version_CH1 +msgid "CH1 - Main Sale Pricelist Version" +msgstr "CH1 - Main Sale Pricelist Version" + +#. module: product_fiscal_company +#: model:ir.model,name:product_fiscal_company.model_res_company +msgid "Companies" +msgstr "Sociétés" + +#. module: product_fiscal_company +#: field:pricelist.partnerinfo,company_id:0 +msgid "Company" +msgstr "Société" + +#. module: product_fiscal_company +#: model:product.template,name:product_fiscal_company.administrative_product_product_template +msgid "Global Administrative Product" +msgstr "Article Administratif Global" + +#. module: product_fiscal_company +#: help:product.product,administrative_ok:0 +#: help:product.template,administrative_ok:0 +msgid "If checked, this product will be readonly for users and updatable only by specific group" +msgstr "Si la case est cochée, ce produit sera en lecture seule pour les utilisateurs, et modifiable seulement par les membres d'un groupe spécifique" + +#. module: product_fiscal_company +#: field:product.product,administrative_ok:0 +#: field:product.template,administrative_ok:0 +msgid "Is Administrative" +msgstr "Est Administratif" + +#. module: product_fiscal_company +#: model:ir.model,name:product_fiscal_company.model_product_pricelist +msgid "Pricelist" +msgstr "Liste de prix" + +#. module: product_fiscal_company +#: model:ir.model,name:product_fiscal_company.model_product_product +msgid "Product" +msgstr "Article" + +#. module: product_fiscal_company +#: model:product.template,name:product_fiscal_company.product_A_CH1_product_template +msgid "Product A of CH1" +msgstr "Article A de CH1" + +#. module: product_fiscal_company +#: model:product.template,name:product_fiscal_company.product_B_CH1_product_template +msgid "Product B of CH1" +msgstr "Article B de CH1" + +#. module: product_fiscal_company +#: model:ir.model,name:product_fiscal_company.model_product_template +msgid "Product Template" +msgstr "Modèle d'article" + +#. module: product_fiscal_company +#: code:addons/product_fiscal_company/models/product_template.py:44 +#, python-format +msgid "You have no right to create or update an administrative product" +msgstr "Vous n'avez pas le droit de créer ou de mettre à jour un produit administratif" + + diff --git a/fiscal_company_product/models/__init__.py b/fiscal_company_product/models/__init__.py new file mode 100644 index 0000000..e23c4c7 --- /dev/null +++ b/fiscal_company_product/models/__init__.py @@ -0,0 +1,6 @@ +# coding: utf-8 +from . import product_pricelist +from . import product_product +from . import product_template +from . import res_company +from . import res_company_create_wizard diff --git a/fiscal_company_product/models/product_pricelist.py b/fiscal_company_product/models/product_pricelist.py new file mode 100644 index 0000000..112a519 --- /dev/null +++ b/fiscal_company_product/models/product_pricelist.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2014-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 lxml import etree + +from odoo import api, models + + +class ProductPricelist(models.Model): + _inherit = 'product.pricelist' + + # Overload Section + @api.model + def fields_view_get( + self, view_id=None, view_type='form', toolbar=False, + submenu=False): + """Add a required modifiers on the field company_id""" + res = super(ProductPricelist, self).fields_view_get( + view_id=view_id, view_type=view_type, toolbar=toolbar, + submenu=submenu) + if view_type in ('form', 'tree')\ + and 'company_id' in res['fields']: + res['fields']['required'] = True + doc = etree.XML(res['arch']) + node = doc.xpath("//field[@name='company_id']")[0] + node.set('modifiers', '{"required": true}') + res['arch'] = etree.tostring(doc) + return res diff --git a/fiscal_company_product/models/product_product.py b/fiscal_company_product/models/product_product.py new file mode 100644 index 0000000..3444433 --- /dev/null +++ b/fiscal_company_product/models/product_product.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2014-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, models + + +class ProductProduct(models.Model): + _inherit = 'product.product' + + # Overload Section + @api.model + def create(self, vals): + res = super(ProductProduct, self).create(vals) + res._set_default_code() + return res + + # Custom Section + @api.multi + def _set_default_code(self): + ir_sequence_obj = self.env['ir.sequence'] + for product in self: + if product.company_id and\ + product.company_id.use_default_code_sequence: + product.default_code = ir_sequence_obj.get( + 'product_product.default_code') diff --git a/fiscal_company_product/models/product_template.py b/fiscal_company_product/models/product_template.py new file mode 100644 index 0000000..17e7c37 --- /dev/null +++ b/fiscal_company_product/models/product_template.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2014-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, exceptions, fields, models + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + # 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(ProductTemplate, self).create(vals) + + @api.multi + def write(self, vals): + if vals.get('cae_administrative_ok', False) or\ + any(self.mapped('cae_administrative_ok')): + self._check_administrative_access() + return super(ProductTemplate, self).write(vals) + + @api.multi + def unlink(self): + if any(self.mapped('cae_administrative_ok')): + self._check_administrative_access() + return super(ProductTemplate, self).unlink() + + # Custom Section + @api.model + def _check_administrative_access(self): + if not self.env.user.has_group( + 'base_fiscal_company.fiscal_company_manager'): + raise exceptions.ValidationError(_( + "You have no right to create or update an" + " administrative product")) diff --git a/fiscal_company_product/models/res_company.py b/fiscal_company_product/models/res_company.py new file mode 100644 index 0000000..aae5c4e --- /dev/null +++ b/fiscal_company_product/models/res_company.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2017-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, exceptions, fields, models + + +class ResCompany(models.Model): + _inherit = 'res.company' + + # Column Section + product_default_code_sequence_id = fields.Many2one( + comodel_name='ir.sequence', readonly=True) + + use_default_code_sequence = fields.Boolean() + + # Constrains + @api.constrains('use_default_code_sequence', 'fiscal_code') + def _check_use_default_code_sequence(self): + for company in self: + if not company.fiscal_code and company.use_default_code_sequence: + raise exceptions.ValidationError(_( + "You should set fiscal_code if you want to use default" + " code sequence for products.")) + + # Overload Section + @api.model + def create(self, vals): + res = super(ResCompany, self).create(vals) + res._create_product_default_code_sequence() + return res + + @api.multi + def write(self, vals): + res = super(ResCompany, self).write(vals) + if 'fiscal_code' in vals: + self._create_product_default_code_sequence() + return res + + # Custom Section + @api.multi + def _create_product_default_code_sequence(self): + sequence_obj = self.env['ir.sequence'] + for company in self: + if company.fiscal_code: + vals = company._prepare_product_default_code_sequence() + if not company.product_default_code_sequence_id: + company.product_default_code_sequence_id =\ + sequence_obj.create(vals).id + else: + company.product_default_code_sequence_id.write({ + 'name': vals['name'], + 'prefix': vals['prefix'], + }) + + @api.multi + def _prepare_product_default_code_sequence(self): + self.ensure_one() + return { + 'name': '%s - Default Code for Products' % (self.fiscal_code), + 'code': 'product_product.default_code', + 'implementation': 'standard', + 'company_id': self.id, + 'prefix': '%s-' % (self.fiscal_code), + 'padding': 6, + } diff --git a/fiscal_company_product/models/res_company_create_wizard.py b/fiscal_company_product/models/res_company_create_wizard.py new file mode 100644 index 0000000..d3af0db --- /dev/null +++ b/fiscal_company_product/models/res_company_create_wizard.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2014 - 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, models + + +class ResCompanyCreateWizard(models.TransientModel): + _inherit = 'res.company.create.wizard' + + @api.multi + def _begin(self): + self.ensure_one() + super(ResCompanyCreateWizard, self)._begin() + pricelist_obj = self.env['product.pricelist'] + + # update just created pricelist, if exist or create one + pricelists = pricelist_obj.search( + [('name', '=', self.company_id.name)]) + if len(pricelists): + pricelist = pricelists[0] + pricelist.write(self._prepare_pricelist()) + else: + pricelist = pricelist_obj.create(self._prepare_pricelist()) + + @api.multi + def _prepare_pricelist(self): + self.ensure_one() + if self.company_id.fiscal_code: + code = self.company_id.fiscal_code + else: + code = "#%d" % self.company_id.id + return { + 'name': _('%s - Public Pricelist') % code, + 'currency_id': self.company_id.currency_id.id, + 'company_id': self.company_id.id, + } diff --git a/fiscal_company_product/security/ir.model.access.csv b/fiscal_company_product/security/ir.model.access.csv new file mode 100644 index 0000000..d6508b2 --- /dev/null +++ b/fiscal_company_product/security/ir.model.access.csv @@ -0,0 +1,4 @@ +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,base_fiscal_company.fiscal_company_manager,1,1,1,1 +access_pricelist_item_manager,pricelist Item CAE manager,product.model_product_pricelist_item,base_fiscal_company.fiscal_company_manager,1,1,1,1 diff --git a/fiscal_company_product/security/ir_rule.xml b/fiscal_company_product/security/ir_rule.xml new file mode 100644 index 0000000..416966b --- /dev/null +++ b/fiscal_company_product/security/ir_rule.xml @@ -0,0 +1,24 @@ + + + + + + + + product.template CAE company + + [ + '|', '|', '|', + ('company_id', '=', user.company_id.id), + ('company_id', '=', user.company_id.fiscal_company_id.id), + ('company_id', 'in', [c.id for c in user.company_id.fiscal_child_ids]), + ('company_id', '=', False), + ] + + + diff --git a/fiscal_company_product/static/description/icon.png b/fiscal_company_product/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..75a407d7b2d7a9e0547b4fd24254602ba935c8f0 GIT binary patch literal 6273 zcmY*e1yoc~yPcs2q(Qn%kOrj`21GiPZV{A_X6PKcLy+!LL5A)w3F&qurI8j15%E8~ z_tyH?yKCKiRd5@YBptgSskzJgB))+?d^;RrXUCJWZvP_ zwuPUZ_OWq6aO!*#yl_s!CrV0LC5gp$Em)ab*|t(SA|lpfqFe{;qVGg)wWrDx-NfJT z_Hiqdyg1Ez?qv2oS}8m;W)B=Gm|-}F%{$Hk`Z#byKy24fKyPp_&HWMyM}UaC{O zmTQ1_+<=+;zP?^p-2Y0HOEb5)tu4F1U*V0N9U48^ee_OcYHCVJNr{<@DzMhd^PjYgy>-gh~D%ZSHC?!_fX>`hZGbPfIG>_$)EW6NDd7R-J`(IyBj|a zgICTI0E9R8(Y4u9p7EKPw3(TiJ73XI_|zdgfZ3qMjayk+8M5Oh`MoO$lU^nuJHpQH z!))Hcg9jA3;ZG&!>XNN%HA`y9jQ3otx5 zRH&TSHZf5H_meO(juk$QdG=|R$ic@ax45PzN&kg^ifOCIa~&OauaR!a{gM|>rJJ}i-c>-+rqZC;+Hk`f+(=3PpP_u@DMCwWOp$;|vbIT@K; zK!CK6kP!JdH}}WgpJR;g@$eLW{1`d?LGw>GUK>9$HTCYY*E%5}vfSUsA2~Hq@$pv6 zZQg^Mt^mZ+va+95X{;$JDWVS_7V7Y1h&eGnfBswpy?d76dU^cv{9r**T|G`Ss_PSm zV1}C9)2G->{=Z0P7s_%Pl80XP_4i|#3sT!SI-b9aDf(Dh`N5$$jFgE<)61)AxA!$pCsT84t&<*xjA(sOsa4=L^$IPGAIZdU@z#^)9&(U za`tmq7X;$koZZz0Puo|2&yX#Fz-c%8-ZhbA8GiDTfiD5EU0szgRpN*B?0&n{0nl=?vSN@h6{GDvB#4SmTySu4KP)_GJSl^)lU+y- z`1tsgQ!1vYJe8B{ackL3?CX=);h}`6tE>O|C4N|bRkNxK4Gjw;JzeX|;Xb!#_vsAjxjyve3oAD_3}iBx3LG(>JY{78^1FAppht_npD-fh<3S`%_VbI2 zYA!B9R<$&73Qx?;7=0g^+-b|#OHNBubafS;uP|M|{(V|kSJy;$esv^QUAeekV5G$KMXa~^85j)8+?*slPljj9O0gD4F!~HyFZ&UgQ6a-n#*KxOHkYd*#Fxjt#HGH) zW8AIp-cf+ZDi5@)H)0I9e3{B?DEIt1DO2FJ&`O!7V>(SAx(odD`mWRwyMTa`PS~jM z_|X){_L_=jU`TK<#zV(z>=-J6EiM@sb#alPaXdI6)wgfoLI($x*4EbUwHv6Inlc<5 z8~|Z5_PtY-m!MFpLq!UhBh%BzCwAQc56y)$1ZkO= zn$P(+TqWMrXM#C$MKo4}*>^=CP|5oKgn4ddD3tm=Ztm~DcBkK^rA-5dYibgcMfFLp zKNJ&71GVvOO3H(mw0Ceqo|%}8G$Xb@f})2)5w@EppzS$DMc)CuK(g)b?(&+pyt}@> zb|DVn-Q3*li6ZA}a@$RE-x7{w3k5uRWo=#S_uCbW>>q$C(3G+kqz(l#6CNJkhPSQ#g-HDo_m>=EG;d`fm-bE?+?7o)t^5!^z^U1ywWEop4kyD(zLX+gx=f) z?2#RVfx!@{-Uczp#i|=VJPgFv2+O^Dkw_$DYa}B?p7r(v(7R%-Quo~^9Ucx=)*f3K zAi1o_uO~nl9@@TLQ*SeZi30Hk>M5CXTa$nM_+evX(`6%S@i0qSUH$2YX&7)J$;(|= zS3U)xIBjiN(bCbCmX=mm@Ceh!;RVA317&h@a{LzFQyq=3{a`58;s(zlTcSnEzz}DI z0-BSUo~|S(hcP-jD(B~ST^ukoGlM74{);S_Ie*e-@XHt1Z*z1b>Dqu!a_Z`Yv$L~0 z`uf_&#;U%)Ql_S+zs}BF4!%7Yu@bSWMQ38Zva+T8a_7zPwF_HSK% z{p8ZpC=hu}Ow3!@uCDqwApqY;w$^wTh8ZI*gYrBnMhGN8F*qay#gw52>=-8t%gaSB zVPUPQ*;$Tvsi{9}^Zv$yq6l&kModhl_}J1yNnM?TjSUl}r~2j%50Ei4s?V_-5JE!2 zo}0gaO3TZOD=OlFVFZ{6NlTyD=O6xE0`>&V+T^ZV&;80aIc;rnpq01J_wAdCu`!(t zb!k{@%;V?cYsA&nA7|gpym0rL3BfXe}sUk(89ArltngC+S13 zPxL^X!baD~2!wjvl8;Z&iuzK2a+24e3IZZhRE((CHCOe#(A+%?7kCdRN=iM?+h1;9 zIMvYXijBoqD$x?kT4dNwTAG+hte0j^QQOVuq3Q(q$baJR(9721n`n z{tb`&yq3m+yR)-n4hX2#Iyks=FGZzTYxj=VZaNJ)a+9+;xCE~XkC~IRe^1Pww;`Ze z3kz%`{7~S6nsu>aQJ7fR*xrMx7gcA&Q{$_#5QUap>jcOmH%3eDPR(6tcX#((&0Jbl z@n{m}trq#@X3y{o3MPL1_z}&5+}W{FHZjQ_j^T#diA>BRAf-Agfq|Xw-Ctgfl(9nk zHfK^_>sCxmP70M#uG(SX;p5j_y|%>`4|xh%))o zswe^>Ha523e+Mztolb*|9Mm;EJsVXq5>-m%0Sa^)VlQZ+1`Srv?@{m{jIJxc5=P&H z{yIOGbf5zUf&4Q%O%C$-@ng3*`;$Xe3_N1u#zU%!+1brHNMYeQ2`TCKDPA^Bp(2cD z_bBG*w(uJ;B4cCg4v9A$Kn@x|MQ*y0y;xOcK~}p%UXUWyIBTVq^rLT6t?@8~EB!z2SaMu|lu0-*l^=P>= zcxln~CJ?&4AVnZUL$O#{S)Khu8g>==(~S4nfDBRJk@29`EAWaRQRCB;{>=_L1g={q zs>6}Z%Pq$-0v(rmz~g*A(9)hc>^dP-@z zBj)W5=g3<}~}m4>XTnrP*jIpK;S(MXQpU8apd%aGGWgZT*H_%WV%z*|_`#xZt7T z;iBT=P|$uxBy(v>WU`P$|!azCM+ zVYLPJ#gZozZCp4xm&Wl{mQ&65nNr(}qaxi;UaLX4gX80hmGg+52^NjqN6PA>=dc64 zO6eYBr}jlL*{rDw_t`!DUKsO_}hEw@Yo1D;S^!3lQPGJ9t zoBigCzgt@V>)IO4LN_>M4ftpANQ=;y&%Qy`I!4FDG`sDR>FVlI-@yTD4NQLIC?&b76*VC?g#l+LkL5sa$WCu^UjeNWq(Ya6+aGbE8r zN2|#aT{h$=;w+jFa8iz}`$9`_2MyOP&`3iS$%V7aFu@XpOQ4t5&f>lb^ zzE)daS86DFdWr!9=JEMhsw4@l7y#{7(a5N%>fG1+0|`tr|FfX=--Ge;RT_Bu#x%hU^a!$o?Pqx^eNk%e zcICG0KF})8hOExxT=j4gms0mbV;w(Q&y%hD^j2-#59yVUXCM^ka&;nDaR)aIlBRgW zguj82DfBWphzfbl?Ym{I;LL&RMbH$uaXJo{JYMnW;ltW@%Ge#)PFEpy#=Io%s|n>$jQK!eaF)+Se&Cv!Cc@OJ~ip|S9}vJGr7f_FT!d|;$+(i`+c+0TP<-KC0~fn zd4gm-NzTcoUOH%My0If=(7%`UAVFRKAiW+vaewJ?$+(op1xT>1#vAPV6s>uJESdIQ zaOV+vkW-|HMzJQG*X%n1RQxnU2cn%r_7GR8_SAoy-9rY)b>B~*`uBx<-&#M79!p1D zBWs65!z0L}2SF(M%lm>G8};@swuoV&4QBkoPZ7B4Paz0oATHVdwcevB)aG{rIENr! z@y{>_qt$gU6MTed99kXO9NE8hL9v?9we)ZW+p^Pu`$_rqFHBEpqxxDU+ahI`$*MqX z;H8zhj5F;?ZgIk;wQ=bUiv`E^bMs#6KS$7p?YUpgyLn5j`P5#B4Fri$OkLW62|amQ zJ1ZQ{JMDlV=C%liR(yqZzE*4F>9?-ONOU0I3c%f^_BCHI_UMt&#-gt$@6T{HJ}{|d zNIzokh>Hz0{7}NwMSAFl1&ef=DHC!*lfz}=hxc`)z7Iry=?O%`{)CPm1y-H5wp(y4 zXozd#uj)$8|H%z$qW_LykmZXUeWLil(wJziDOh-X%+s1awEm)fZtLGU(UyeWcIz(T!FVr6?t&7YhGvy7K@?lJ8s-(;Cif5*Av=?Sky0UG^|Lz zyjVT7T`vj0=|?E>badk!j)snJLz>j$8gqI3kpnSvSpx{7eYw{8@ZgB)wDIxe;->r~ z{l&W4*F5Ua?sqha*M*<38sOP8o|=kUB-`*t*xv-sj2-<8{<>DRxsv@0^?GE*Hu7=o zU7bkv^`Uz;r%RP2VKxc%vE!%%hU~lRef5gpKiOgC;oLmhYHcK4_`OX^euddT@AEG~ z0H++D{b^!sN6cO5SfVOH;0lVL{cBIO2*Ch5z8Q4KMXG!F)eO7{a#axfqZ8>*|3~4P zPJVx(3DY3npt9vdHJj5h_rixVV&Q7rYp7w;Pr|vq#onS~P;Vj!-kyO|D6dKtJ2ou}f)@Wo(%gXW7^P?X&tNNsh zm;x+Y_#tcosmw%~=y;rO!c;D+2h*f4`nNR3<{WMp + + + + + + product.pricelist + + + + + + + + + + product.pricelist + + + + + + + + + diff --git a/fiscal_company_product/views/view_product_pricelist_item.xml b/fiscal_company_product/views/view_product_pricelist_item.xml new file mode 100644 index 0000000..5a9519a --- /dev/null +++ b/fiscal_company_product/views/view_product_pricelist_item.xml @@ -0,0 +1,30 @@ + + + + + + + product.pricelist.item + + + + + + + + + + product.pricelist.item + + + + + + + + + diff --git a/fiscal_company_product/views/view_product_template.xml b/fiscal_company_product/views/view_product_template.xml new file mode 100644 index 0000000..29a1572 --- /dev/null +++ b/fiscal_company_product/views/view_product_template.xml @@ -0,0 +1,31 @@ + + + + + + + product.template + + + + + + + + + + product.template + + + + + + + + + From 444eb778d233069beedbf287196535fb9e10f007 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Mon, 16 Jul 2018 13:07:20 +0200 Subject: [PATCH 02/22] [REF][WIP] rename module --- fiscal_company_product/__manifest__.py | 2 +- fiscal_company_product/demo/product_pricelist.xml | 4 ++-- fiscal_company_product/demo/product_product.xml | 4 ++-- fiscal_company_product/demo/product_template.xml | 6 +++--- fiscal_company_product/demo/res_company.xml | 6 +++--- fiscal_company_product/demo/res_groups.xml | 4 ++-- fiscal_company_product/models/product_template.py | 2 +- fiscal_company_product/security/ir.model.access.csv | 4 ++-- fiscal_company_product/tests/__init__.py | 2 +- .../{test_product_fiscal_company.py => test_module.py} | 10 +++++----- 10 files changed, 22 insertions(+), 22 deletions(-) rename fiscal_company_product/tests/{test_product_fiscal_company.py => test_module.py} (85%) diff --git a/fiscal_company_product/__manifest__.py b/fiscal_company_product/__manifest__.py index 34e1a4a..c6d1774 100644 --- a/fiscal_company_product/__manifest__.py +++ b/fiscal_company_product/__manifest__.py @@ -12,7 +12,7 @@ 'website': 'http://www.grap.coop', 'license': 'AGPL-3', 'depends': [ - 'base_fiscal_company', + 'fiscal_company_base', 'product', ], 'data': [ diff --git a/fiscal_company_product/demo/product_pricelist.xml b/fiscal_company_product/demo/product_pricelist.xml index bd2faf8..7c41289 100644 --- a/fiscal_company_product/demo/product_pricelist.xml +++ b/fiscal_company_product/demo/product_pricelist.xml @@ -12,12 +12,12 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). 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 index ad213f3..cea0bba 100644 --- a/fiscal_company_product/demo/product_product.xml +++ b/fiscal_company_product/demo/product_product.xml @@ -8,13 +8,13 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). CAE - Mother Product Variant - + CAE - Child 1 Product Variant - + diff --git a/fiscal_company_product/demo/product_template.xml b/fiscal_company_product/demo/product_template.xml index 93c75cd..30b3d23 100644 --- a/fiscal_company_product/demo/product_template.xml +++ b/fiscal_company_product/demo/product_template.xml @@ -8,19 +8,19 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). CAE - Mother Product Template - + CAE - Child 1 Product Template - + CAE - Administrative Mother Product Template - + diff --git a/fiscal_company_product/demo/res_company.xml b/fiscal_company_product/demo/res_company.xml index 1431c16..b64fcc9 100644 --- a/fiscal_company_product/demo/res_company.xml +++ b/fiscal_company_product/demo/res_company.xml @@ -9,8 +9,8 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + ref('fiscal_company_base.company_fiscal_child_1'), + ref('fiscal_company_base.company_fiscal_child_2'), + ref('fiscal_company_base.company_fiscal_mother')]]"/> diff --git a/fiscal_company_product/demo/res_groups.xml b/fiscal_company_product/demo/res_groups.xml index 3c35399..a2559a7 100644 --- a/fiscal_company_product/demo/res_groups.xml +++ b/fiscal_company_product/demo/res_groups.xml @@ -9,14 +9,14 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/fiscal_company_product/models/product_template.py b/fiscal_company_product/models/product_template.py index 17e7c37..d58a20d 100644 --- a/fiscal_company_product/models/product_template.py +++ b/fiscal_company_product/models/product_template.py @@ -39,7 +39,7 @@ def unlink(self): @api.model def _check_administrative_access(self): if not self.env.user.has_group( - 'base_fiscal_company.fiscal_company_manager'): + 'fiscal_company_base.fiscal_company_manager'): raise exceptions.ValidationError(_( "You have no right to create or update an" " administrative product")) diff --git a/fiscal_company_product/security/ir.model.access.csv b/fiscal_company_product/security/ir.model.access.csv index d6508b2..b9c8ecd 100644 --- a/fiscal_company_product/security/ir.model.access.csv +++ b/fiscal_company_product/security/ir.model.access.csv @@ -1,4 +1,4 @@ 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,base_fiscal_company.fiscal_company_manager,1,1,1,1 -access_pricelist_item_manager,pricelist Item CAE manager,product.model_product_pricelist_item,base_fiscal_company.fiscal_company_manager,1,1,1,1 +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 diff --git a/fiscal_company_product/tests/__init__.py b/fiscal_company_product/tests/__init__.py index 0054aa0..17b8206 100644 --- a/fiscal_company_product/tests/__init__.py +++ b/fiscal_company_product/tests/__init__.py @@ -1,2 +1,2 @@ # coding: utf-8 -from . import test_product_fiscal_company +from . import test_module diff --git a/fiscal_company_product/tests/test_product_fiscal_company.py b/fiscal_company_product/tests/test_module.py similarity index 85% rename from fiscal_company_product/tests/test_product_fiscal_company.py rename to fiscal_company_product/tests/test_module.py index be91344..637a95c 100644 --- a/fiscal_company_product/tests/test_product_fiscal_company.py +++ b/fiscal_company_product/tests/test_module.py @@ -5,21 +5,21 @@ from odoo.tests.common import TransactionCase -from odoo.addons.base_fiscal_company.fix_test import fix_required_field +from odoo.addons.fiscal_company_base.fix_test import fix_required_field -class TestProductFiscalCompany(TransactionCase): +class TestModule(TransactionCase): """Tests for 'Product Fiscal Company' Module""" # Overload Section def setUp(self): - super(TestProductFiscalCompany, self).setUp() + super(TestModule, self).setUp() self.pricelist_obj = self.env['product.pricelist'] self.wizard_obj = self.env['res.company.create.wizard'] self.mother_company = self.env.ref( - 'base_fiscal_company.company_fiscal_mother') + 'fiscal_company_base.company_fiscal_mother') self.user_accountant = self.env.ref( - 'base_fiscal_company.user_accountant') + 'fiscal_company_base.user_accountant') fix_required_field(self, 'DROP') def tearDown(self): From 1942c9505499058a625edc9c608193ebe636137d Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Mon, 16 Jul 2018 14:56:50 +0200 Subject: [PATCH 03/22] [FIX] flake8 + test --- fiscal_company_product/tests/test_module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fiscal_company_product/tests/test_module.py b/fiscal_company_product/tests/test_module.py index 637a95c..adc4fb4 100644 --- a/fiscal_company_product/tests/test_module.py +++ b/fiscal_company_product/tests/test_module.py @@ -25,7 +25,7 @@ def setUp(self): def tearDown(self): self.cr.rollback() fix_required_field(self, 'SET') - super(TestProductFiscalCompany, self).tearDown() + super(TestModule, self).tearDown() # Test Section def test_01_pricelist_creation(self): From c60160751b1a766f1a379b62ca40173d2dbe6101 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Mon, 6 Aug 2018 12:17:58 +0200 Subject: [PATCH 04/22] [WIP] refactor --- fiscal_company_product/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fiscal_company_product/__manifest__.py b/fiscal_company_product/__manifest__.py index c6d1774..1b1b789 100644 --- a/fiscal_company_product/__manifest__.py +++ b/fiscal_company_product/__manifest__.py @@ -29,6 +29,6 @@ 'demo/product_product.xml', 'demo/res_company.xml', ], - 'installable': True, + 'installable': False, 'auto_install': True, } From cb53e111e8f64b9852ea2c020f3819e42276f2fa Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Mon, 6 Aug 2018 13:18:38 +0200 Subject: [PATCH 05/22] [REF]fiscal_company_product + ADD tests --- fiscal_company_product/__manifest__.py | 14 ++-- fiscal_company_product/demo/res_company.xml | 16 ----- fiscal_company_product/demo/res_groups.xml | 11 ++- fiscal_company_product/models/__init__.py | 4 -- .../models/product_pricelist.py | 30 -------- .../models/product_product.py | 27 -------- .../models/product_template.py | 5 +- fiscal_company_product/models/res_company.py | 68 ------------------- .../models/res_company_create_wizard.py | 39 ----------- .../security/ir.model.access.csv | 2 + fiscal_company_product/security/ir_rule.xml | 7 +- .../security/res_groups.xml | 15 ++++ fiscal_company_product/tests/test_module.py | 62 ++++++++--------- .../views/view_product_pricelist.xml | 30 -------- .../views/view_product_pricelist_item.xml | 30 -------- .../views/view_product_template.xml | 10 --- 16 files changed, 69 insertions(+), 301 deletions(-) delete mode 100644 fiscal_company_product/demo/res_company.xml delete mode 100644 fiscal_company_product/models/product_pricelist.py delete mode 100644 fiscal_company_product/models/product_product.py delete mode 100644 fiscal_company_product/models/res_company.py delete mode 100644 fiscal_company_product/models/res_company_create_wizard.py create mode 100644 fiscal_company_product/security/res_groups.xml delete mode 100644 fiscal_company_product/views/view_product_pricelist.xml delete mode 100644 fiscal_company_product/views/view_product_pricelist_item.xml diff --git a/fiscal_company_product/__manifest__.py b/fiscal_company_product/__manifest__.py index 1b1b789..4010d51 100644 --- a/fiscal_company_product/__manifest__.py +++ b/fiscal_company_product/__manifest__.py @@ -1,13 +1,13 @@ -# -*- coding: utf-8 -*- +# coding: utf-8 # Copyright (C) 2014-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': 'CAE - Product Fiscal Company', + 'name': 'CAE - Product', 'version': '10.0.1.0.0', - 'category': 'CIS', - 'summary': 'Glue Module between CIS and product', + 'category': 'CAE', + 'summary': 'Glue Module between CAE and Product modules', 'author': 'GRAP', 'website': 'http://www.grap.coop', 'license': 'AGPL-3', @@ -16,19 +16,17 @@ 'product', ], 'data': [ + 'security/res_groups.xml', 'security/ir.model.access.csv', 'security/ir_rule.xml', 'views/view_product_template.xml', - 'views/view_product_pricelist.xml', - 'views/view_product_pricelist_item.xml', ], 'demo': [ 'demo/res_groups.xml', 'demo/product_pricelist.xml', 'demo/product_template.xml', 'demo/product_product.xml', - 'demo/res_company.xml', ], - 'installable': False, + 'installable': True, 'auto_install': True, } diff --git a/fiscal_company_product/demo/res_company.xml b/fiscal_company_product/demo/res_company.xml deleted file mode 100644 index b64fcc9..0000000 --- a/fiscal_company_product/demo/res_company.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - diff --git a/fiscal_company_product/demo/res_groups.xml b/fiscal_company_product/demo/res_groups.xml index a2559a7..987c8a2 100644 --- a/fiscal_company_product/demo/res_groups.xml +++ b/fiscal_company_product/demo/res_groups.xml @@ -4,7 +4,7 @@ Copyright (C) 2015 - 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). --> - + - + + + + + + diff --git a/fiscal_company_product/models/__init__.py b/fiscal_company_product/models/__init__.py index e23c4c7..2e87b71 100644 --- a/fiscal_company_product/models/__init__.py +++ b/fiscal_company_product/models/__init__.py @@ -1,6 +1,2 @@ # coding: utf-8 -from . import product_pricelist -from . import product_product from . import product_template -from . import res_company -from . import res_company_create_wizard diff --git a/fiscal_company_product/models/product_pricelist.py b/fiscal_company_product/models/product_pricelist.py deleted file mode 100644 index 112a519..0000000 --- a/fiscal_company_product/models/product_pricelist.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2014-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 lxml import etree - -from odoo import api, models - - -class ProductPricelist(models.Model): - _inherit = 'product.pricelist' - - # Overload Section - @api.model - def fields_view_get( - self, view_id=None, view_type='form', toolbar=False, - submenu=False): - """Add a required modifiers on the field company_id""" - res = super(ProductPricelist, self).fields_view_get( - view_id=view_id, view_type=view_type, toolbar=toolbar, - submenu=submenu) - if view_type in ('form', 'tree')\ - and 'company_id' in res['fields']: - res['fields']['required'] = True - doc = etree.XML(res['arch']) - node = doc.xpath("//field[@name='company_id']")[0] - node.set('modifiers', '{"required": true}') - res['arch'] = etree.tostring(doc) - return res diff --git a/fiscal_company_product/models/product_product.py b/fiscal_company_product/models/product_product.py deleted file mode 100644 index 3444433..0000000 --- a/fiscal_company_product/models/product_product.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2014-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, models - - -class ProductProduct(models.Model): - _inherit = 'product.product' - - # Overload Section - @api.model - def create(self, vals): - res = super(ProductProduct, self).create(vals) - res._set_default_code() - return res - - # Custom Section - @api.multi - def _set_default_code(self): - ir_sequence_obj = self.env['ir.sequence'] - for product in self: - if product.company_id and\ - product.company_id.use_default_code_sequence: - product.default_code = ir_sequence_obj.get( - 'product_product.default_code') diff --git a/fiscal_company_product/models/product_template.py b/fiscal_company_product/models/product_template.py index d58a20d..d793ad6 100644 --- a/fiscal_company_product/models/product_template.py +++ b/fiscal_company_product/models/product_template.py @@ -3,7 +3,8 @@ # @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, exceptions, fields, models +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError class ProductTemplate(models.Model): @@ -40,6 +41,6 @@ def unlink(self): def _check_administrative_access(self): if not self.env.user.has_group( 'fiscal_company_base.fiscal_company_manager'): - raise exceptions.ValidationError(_( + raise ValidationError(_( "You have no right to create or update an" " administrative product")) diff --git a/fiscal_company_product/models/res_company.py b/fiscal_company_product/models/res_company.py deleted file mode 100644 index aae5c4e..0000000 --- a/fiscal_company_product/models/res_company.py +++ /dev/null @@ -1,68 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2017-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, exceptions, fields, models - - -class ResCompany(models.Model): - _inherit = 'res.company' - - # Column Section - product_default_code_sequence_id = fields.Many2one( - comodel_name='ir.sequence', readonly=True) - - use_default_code_sequence = fields.Boolean() - - # Constrains - @api.constrains('use_default_code_sequence', 'fiscal_code') - def _check_use_default_code_sequence(self): - for company in self: - if not company.fiscal_code and company.use_default_code_sequence: - raise exceptions.ValidationError(_( - "You should set fiscal_code if you want to use default" - " code sequence for products.")) - - # Overload Section - @api.model - def create(self, vals): - res = super(ResCompany, self).create(vals) - res._create_product_default_code_sequence() - return res - - @api.multi - def write(self, vals): - res = super(ResCompany, self).write(vals) - if 'fiscal_code' in vals: - self._create_product_default_code_sequence() - return res - - # Custom Section - @api.multi - def _create_product_default_code_sequence(self): - sequence_obj = self.env['ir.sequence'] - for company in self: - if company.fiscal_code: - vals = company._prepare_product_default_code_sequence() - if not company.product_default_code_sequence_id: - company.product_default_code_sequence_id =\ - sequence_obj.create(vals).id - else: - company.product_default_code_sequence_id.write({ - 'name': vals['name'], - 'prefix': vals['prefix'], - }) - - @api.multi - def _prepare_product_default_code_sequence(self): - self.ensure_one() - return { - 'name': '%s - Default Code for Products' % (self.fiscal_code), - 'code': 'product_product.default_code', - 'implementation': 'standard', - 'company_id': self.id, - 'prefix': '%s-' % (self.fiscal_code), - 'padding': 6, - } diff --git a/fiscal_company_product/models/res_company_create_wizard.py b/fiscal_company_product/models/res_company_create_wizard.py deleted file mode 100644 index d3af0db..0000000 --- a/fiscal_company_product/models/res_company_create_wizard.py +++ /dev/null @@ -1,39 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2014 - 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, models - - -class ResCompanyCreateWizard(models.TransientModel): - _inherit = 'res.company.create.wizard' - - @api.multi - def _begin(self): - self.ensure_one() - super(ResCompanyCreateWizard, self)._begin() - pricelist_obj = self.env['product.pricelist'] - - # update just created pricelist, if exist or create one - pricelists = pricelist_obj.search( - [('name', '=', self.company_id.name)]) - if len(pricelists): - pricelist = pricelists[0] - pricelist.write(self._prepare_pricelist()) - else: - pricelist = pricelist_obj.create(self._prepare_pricelist()) - - @api.multi - def _prepare_pricelist(self): - self.ensure_one() - if self.company_id.fiscal_code: - code = self.company_id.fiscal_code - else: - code = "#%d" % self.company_id.id - return { - 'name': _('%s - Public Pricelist') % code, - 'currency_id': self.company_id.currency_id.id, - 'company_id': self.company_id.id, - } diff --git a/fiscal_company_product/security/ir.model.access.csv b/fiscal_company_product/security/ir.model.access.csv index b9c8ecd..c501842 100644 --- a/fiscal_company_product/security/ir.model.access.csv +++ b/fiscal_company_product/security/ir.model.access.csv @@ -2,3 +2,5 @@ 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 index 416966b..daaef47 100644 --- a/fiscal_company_product/security/ir_rule.xml +++ b/fiscal_company_product/security/ir_rule.xml @@ -13,11 +13,10 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). product.template CAE company [ - '|', '|', '|', - ('company_id', '=', user.company_id.id), - ('company_id', '=', user.company_id.fiscal_company_id.id), - ('company_id', 'in', [c.id for c in user.company_id.fiscal_child_ids]), + '|', '|', ('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 new file mode 100644 index 0000000..224c917 --- /dev/null +++ b/fiscal_company_product/security/res_groups.xml @@ -0,0 +1,15 @@ + + + + + + + Product Creation + + + + diff --git a/fiscal_company_product/tests/test_module.py b/fiscal_company_product/tests/test_module.py index adc4fb4..df2689c 100644 --- a/fiscal_company_product/tests/test_module.py +++ b/fiscal_company_product/tests/test_module.py @@ -4,45 +4,45 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo.tests.common import TransactionCase - -from odoo.addons.fiscal_company_base.fix_test import fix_required_field +from odoo.exceptions import ValidationError class TestModule(TransactionCase): - """Tests for 'Product Fiscal Company' Module""" + """Tests for 'CAE - Product' Module""" # Overload Section def setUp(self): super(TestModule, self).setUp() - self.pricelist_obj = self.env['product.pricelist'] - self.wizard_obj = self.env['res.company.create.wizard'] - self.mother_company = self.env.ref( - 'fiscal_company_base.company_fiscal_mother') + self.product_obj = self.env['product.product'] self.user_accountant = self.env.ref( 'fiscal_company_base.user_accountant') - fix_required_field(self, 'DROP') - - def tearDown(self): - self.cr.rollback() - fix_required_field(self, 'SET') - super(TestModule, self).tearDown() + 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') + self.employee_group = self.env.ref('base.group_user') # Test Section - def test_01_pricelist_creation(self): - """[Functional Test] creating a new company via wizard, - with user accountant, should create (or update) a pricelist""" - wizard = self.wizard_obj.sudo(self.user_accountant).create({ - 'company_name': 'Test Company Wizard', - 'fiscal_type': 'fiscal_child', - 'fiscal_code': 'WIZ', - 'parent_company_id': self.mother_company.id, - }) - wizard.button_begin() - wizard.button_finish() - pricelists = self.pricelist_obj.search([ - ('company_id', '=', wizard.company_id.id), - ('name', '=', 'WIZ - Public Pricelist'), - ]) - self.assertEqual( - len(pricelists), 1, - "Create a company by wizard should create a pricelist") + 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 + 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) + + 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 + self.product_obj.sudo(user).with_context( + mail_create_nosubscribe=True, + mail_create_nolog=True).create(product_vals) diff --git a/fiscal_company_product/views/view_product_pricelist.xml b/fiscal_company_product/views/view_product_pricelist.xml deleted file mode 100644 index c7ddafc..0000000 --- a/fiscal_company_product/views/view_product_pricelist.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - product.pricelist - - - - - - - - - - product.pricelist - - - - - - - - - diff --git a/fiscal_company_product/views/view_product_pricelist_item.xml b/fiscal_company_product/views/view_product_pricelist_item.xml deleted file mode 100644 index 5a9519a..0000000 --- a/fiscal_company_product/views/view_product_pricelist_item.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - product.pricelist.item - - - - - - - - - - product.pricelist.item - - - - - - - - - diff --git a/fiscal_company_product/views/view_product_template.xml b/fiscal_company_product/views/view_product_template.xml index 29a1572..b36b486 100644 --- a/fiscal_company_product/views/view_product_template.xml +++ b/fiscal_company_product/views/view_product_template.xml @@ -18,14 +18,4 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - - product.template - - - - - - - - From 9bfc013c203b7c1595ca2160fa2730f8574f355e Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Mon, 6 Aug 2018 13:27:04 +0200 Subject: [PATCH 06/22] [REF] move fiscal_mother_check_mixin from account to base module --- fiscal_company_product/demo/res_groups.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/fiscal_company_product/demo/res_groups.xml b/fiscal_company_product/demo/res_groups.xml index 987c8a2..89de5c2 100644 --- a/fiscal_company_product/demo/res_groups.xml +++ b/fiscal_company_product/demo/res_groups.xml @@ -24,6 +24,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). From 0698a645957c9ce73a88a1f4725c56c2852a7a8a Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Mon, 6 Aug 2018 13:42:48 +0200 Subject: [PATCH 07/22] [REF] sale moduole --- fiscal_company_product/tests/test_module.py | 1 - 1 file changed, 1 deletion(-) diff --git a/fiscal_company_product/tests/test_module.py b/fiscal_company_product/tests/test_module.py index df2689c..77a312a 100644 --- a/fiscal_company_product/tests/test_module.py +++ b/fiscal_company_product/tests/test_module.py @@ -20,7 +20,6 @@ def setUp(self): self.child_company = self.env.ref( 'fiscal_company_base.company_fiscal_child_1') self.product_categ = self.env.ref('product.product_category_1') - self.employee_group = self.env.ref('base.group_user') # Test Section def test_01_administrative_product_creation(self): From b9f63b7755aba3d70e989d0dc172e080a018d640 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Mon, 6 Aug 2018 13:49:55 +0200 Subject: [PATCH 08/22] [RESTORE] fiscal_company_account --- fiscal_company_product/README.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fiscal_company_product/README.rst b/fiscal_company_product/README.rst index a60e674..ddc46ca 100644 --- a/fiscal_company_product/README.rst +++ b/fiscal_company_product/README.rst @@ -39,3 +39,10 @@ Contributors * Julien WESTE * Sylvain LE GAL + +Funders +------- + +The development of this module has been financially supported by: + +* GRAP, Groupement Régional Alimentaire de Proximité () From 76bc534f3ec76d259f9d4ff3529d9f60b0e3df0b Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Mon, 6 Aug 2018 15:45:45 +0200 Subject: [PATCH 09/22] [IMP] add translation --- fiscal_company_product/i18n/fr.po | 103 +++++++----------------------- 1 file changed, 22 insertions(+), 81 deletions(-) diff --git a/fiscal_company_product/i18n/fr.po b/fiscal_company_product/i18n/fr.po index 2712175..3b0d34a 100644 --- a/fiscal_company_product/i18n/fr.po +++ b/fiscal_company_product/i18n/fr.po @@ -1,13 +1,13 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * product_fiscal_company +# * fiscal_company_product # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" +"Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-02-13 09:53+0000\n" -"PO-Revision-Date: 2018-02-13 09:53+0000\n" +"POT-Creation-Date: 2018-08-06 13:39+0000\n" +"PO-Revision-Date: 2018-08-06 13:39+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -15,90 +15,31 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" -#. module: product_fiscal_company -#: code:addons/product_fiscal_company/models/res_company_create_wizard.py:27 -#, python-format -msgid "%s - Default Public Pricelist" -msgstr "%s - Default Public Pricelist" - -#. module: product_fiscal_company -#: code:addons/product_fiscal_company/models/res_company_create_wizard.py:39 -#, python-format -msgid "%s - Default Public Pricelist Line" -msgstr "%s - Default Public Pricelist Line" - -#. module: product_fiscal_company -#: code:addons/product_fiscal_company/models/res_company_create_wizard.py:34 -#, python-format -msgid "%s - Default Public Pricelist Version" -msgstr "%s - Default Public Pricelist Version" - -#. module: product_fiscal_company -#: model:product.pricelist,name:product_fiscal_company.sale_product_pricelist_CH1 -msgid "CH1 - Main Sale Pricelist" -msgstr "CH1 - Main Sale Pricelist" - -#. module: product_fiscal_company -#: model:product.pricelist.version,name:product_fiscal_company.sale_product_pricelist_version_CH1 -msgid "CH1 - Main Sale Pricelist Version" -msgstr "CH1 - Main Sale Pricelist Version" - -#. module: product_fiscal_company -#: model:ir.model,name:product_fiscal_company.model_res_company -msgid "Companies" -msgstr "Sociétés" - -#. module: product_fiscal_company -#: field:pricelist.partnerinfo,company_id:0 -msgid "Company" -msgstr "Société" - -#. module: product_fiscal_company -#: model:product.template,name:product_fiscal_company.administrative_product_product_template -msgid "Global Administrative Product" -msgstr "Article Administratif Global" - -#. module: product_fiscal_company -#: help:product.product,administrative_ok:0 -#: help:product.template,administrative_ok:0 +#. 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 la case est cochée, ce produit sera en lecture seule pour les utilisateurs, et modifiable seulement par les membres d'un groupe spécifique" - -#. module: product_fiscal_company -#: field:product.product,administrative_ok:0 -#: field:product.template,administrative_ok:0 -msgid "Is Administrative" -msgstr "Est Administratif" +msgstr "Si la case est cochée, le produit sera en lecture seule pour les utilisateurs, et modifiable seulement par un groupe spécifique d'utilisateur" -#. module: product_fiscal_company -#: model:ir.model,name:product_fiscal_company.model_product_pricelist -msgid "Pricelist" -msgstr "Liste de prix" +#. 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 "Administratif CAE" -#. module: product_fiscal_company -#: model:ir.model,name:product_fiscal_company.model_product_product -msgid "Product" -msgstr "Article" +#. module: fiscal_company_product +#: model:res.groups,name:fiscal_company_product.product_creation +msgid "Product Creation" +msgstr "Création d'articles" -#. module: product_fiscal_company -#: model:product.template,name:product_fiscal_company.product_A_CH1_product_template -msgid "Product A of CH1" -msgstr "Article A de CH1" - -#. module: product_fiscal_company -#: model:product.template,name:product_fiscal_company.product_B_CH1_product_template -msgid "Product B of CH1" -msgstr "Article B de CH1" - -#. module: product_fiscal_company -#: model:ir.model,name:product_fiscal_company.model_product_template +#. module: fiscal_company_product +#: model:ir.model,name:fiscal_company_product.model_product_template msgid "Product Template" msgstr "Modèle d'article" -#. module: product_fiscal_company -#: code:addons/product_fiscal_company/models/product_template.py:44 +#. module: fiscal_company_product +#: code:addons/fiscal_company_product/models/product_template.py:44 #, python-format msgid "You have no right to create or update an administrative product" -msgstr "Vous n'avez pas le droit de créer ou de mettre à jour un produit administratif" - +msgstr "Nous n'avez pas le droit de créer ou de modifier un produit de type Administratif CAE" From 7523925a44ce116a67ce35408f01ab449855a14f Mon Sep 17 00:00:00 2001 From: Samir S Date: Thu, 14 Feb 2019 17:59:36 +0100 Subject: [PATCH 10/22] Update README.rst --- fiscal_company_product/README.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fiscal_company_product/README.rst b/fiscal_company_product/README.rst index ddc46ca..ff48a41 100644 --- a/fiscal_company_product/README.rst +++ b/fiscal_company_product/README.rst @@ -40,6 +40,10 @@ Contributors * Julien WESTE * Sylvain LE GAL +* Porting to odoo V10 has been funded by : + * BABEL.COOP, leverage cooperation through the digital age () + + Funders ------- From a2a4c703a940b423fc2aeb97b1e5045983a1e747 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Wed, 25 Sep 2019 13:48:12 +0200 Subject: [PATCH 11/22] [INIT] V12.0 : update Travis and disable modules --- fiscal_company_product/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fiscal_company_product/__manifest__.py b/fiscal_company_product/__manifest__.py index 4010d51..ecc7bc8 100644 --- a/fiscal_company_product/__manifest__.py +++ b/fiscal_company_product/__manifest__.py @@ -27,6 +27,6 @@ 'demo/product_template.xml', 'demo/product_product.xml', ], - 'installable': True, + 'installable': False, 'auto_install': True, } From 2fe7bf8a4be697651deb990e04e4a59b9a0118ce Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Wed, 25 Sep 2019 13:55:06 +0200 Subject: [PATCH 12/22] [WIP] migrate to V12. --- fiscal_company_product/README.rst | 80 ++++++++++++------ fiscal_company_product/__manifest__.py | 5 +- .../demo/product_product.xml | 2 +- .../demo/product_template.xml | 2 +- fiscal_company_product/demo/res_groups.xml | 6 +- fiscal_company_product/i18n/fr.po | 81 ++++++++++++++++--- fiscal_company_product/models/__init__.py | 1 - .../models/product_template.py | 7 +- .../readme/CONTRIBUTORS.rst | 2 + fiscal_company_product/readme/CREDITS.rst | 6 ++ fiscal_company_product/readme/DESCRIPTION.rst | 13 +++ fiscal_company_product/tests/__init__.py | 1 - fiscal_company_product/tests/test_module.py | 7 +- .../views/view_product_template.xml | 4 +- 14 files changed, 160 insertions(+), 57 deletions(-) create mode 100644 fiscal_company_product/readme/CONTRIBUTORS.rst create mode 100644 fiscal_company_product/readme/CREDITS.rst create mode 100644 fiscal_company_product/readme/DESCRIPTION.rst diff --git a/fiscal_company_product/README.rst b/fiscal_company_product/README.rst index ff48a41..ab86814 100644 --- a/fiscal_company_product/README.rst +++ b/fiscal_company_product/README.rst @@ -1,52 +1,80 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html - :alt: License: AGPL-3 - -========================================================== -Manage Cooperatives of Activities and Employment - Product -========================================================== - +============= +CAE - Product +============= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-odoo-cae%2Fodoo--addons--cae-lightgray.png?logo=github + :target: https://github.com/odoo-cae/odoo-addons-cae/tree/12.0/fiscal_company_product + :alt: odoo-cae/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. -Features --------- +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 +* 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 -Company Creation Wizard ------------------------ +**Table of contents** -* Create a Sale Pricelist and the according property to - ```property_product_pricelist``` +.. contents:: + :local: -Installation -============ +Bug Tracker +=========== -Normal installation. +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 smashing 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 -* Porting to odoo V10 has been funded by : - * BABEL.COOP, leverage cooperation through the digital age () +Other credits +~~~~~~~~~~~~~ +The development of this module has been financially supported by: -Funders -------- +* GRAP, Groupement Régional Alimentaire de Proximité (http://www.grap.coop) -The development of this module has been financially supported by: +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 `odoo-cae/odoo-addons-cae `_ project on GitHub. -* GRAP, Groupement Régional Alimentaire de Proximité () +You are welcome to contribute. diff --git a/fiscal_company_product/__manifest__.py b/fiscal_company_product/__manifest__.py index ecc7bc8..57d945d 100644 --- a/fiscal_company_product/__manifest__.py +++ b/fiscal_company_product/__manifest__.py @@ -1,11 +1,10 @@ -# coding: utf-8 # Copyright (C) 2014-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': 'CAE - Product', - 'version': '10.0.1.0.0', + 'version': '12.0.1.0.0', 'category': 'CAE', 'summary': 'Glue Module between CAE and Product modules', 'author': 'GRAP', @@ -27,6 +26,6 @@ 'demo/product_template.xml', 'demo/product_product.xml', ], - 'installable': False, + 'installable': True, 'auto_install': True, } diff --git a/fiscal_company_product/demo/product_product.xml b/fiscal_company_product/demo/product_product.xml index cea0bba..a850d48 100644 --- a/fiscal_company_product/demo/product_product.xml +++ b/fiscal_company_product/demo/product_product.xml @@ -13,7 +13,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - CAE - Child 1 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 index 30b3d23..19eb25c 100644 --- a/fiscal_company_product/demo/product_template.xml +++ b/fiscal_company_product/demo/product_template.xml @@ -13,7 +13,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - CAE - Child 1 Product Template + CH1 - Child 1 Product Template diff --git a/fiscal_company_product/demo/res_groups.xml b/fiscal_company_product/demo/res_groups.xml index 89de5c2..42800be 100644 --- a/fiscal_company_product/demo/res_groups.xml +++ b/fiscal_company_product/demo/res_groups.xml @@ -8,20 +8,20 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - + \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -16,16 +16,53 @@ msgstr "" "Plural-Forms: \n" #. 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 +#: 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 la case est cochée, le produit sera en lecture seule pour les utilisateurs, et modifiable seulement par un groupe spécifique d'utilisateur" +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 +#: 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 "Administratif CAE" +msgstr "Est administratif" #. module: fiscal_company_product #: model:res.groups,name:fiscal_company_product.product_creation @@ -38,8 +75,30 @@ msgid "Product Template" msgstr "Modèle d'article" #. module: fiscal_company_product -#: code:addons/fiscal_company_product/models/product_template.py:44 +#: 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 2e87b71..e8fa8f6 100644 --- a/fiscal_company_product/models/__init__.py +++ b/fiscal_company_product/models/__init__.py @@ -1,2 +1 @@ -# coding: utf-8 from . import product_template diff --git a/fiscal_company_product/models/product_template.py b/fiscal_company_product/models/product_template.py index d793ad6..13cc8b8 100644 --- a/fiscal_company_product/models/product_template.py +++ b/fiscal_company_product/models/product_template.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2014-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). @@ -21,20 +20,20 @@ class ProductTemplate(models.Model): def create(self, vals): if vals.get('cae_administrative_ok', False): self._check_administrative_access() - return super(ProductTemplate, self).create(vals) + return super().create(vals) @api.multi def write(self, vals): if vals.get('cae_administrative_ok', False) or\ any(self.mapped('cae_administrative_ok')): self._check_administrative_access() - return super(ProductTemplate, self).write(vals) + return super().write(vals) @api.multi def unlink(self): if any(self.mapped('cae_administrative_ok')): self._check_administrative_access() - return super(ProductTemplate, self).unlink() + return super().unlink() # Custom Section @api.model diff --git a/fiscal_company_product/readme/CONTRIBUTORS.rst b/fiscal_company_product/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..de2b331 --- /dev/null +++ b/fiscal_company_product/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Julien WESTE +* Sylvain LE GAL diff --git a/fiscal_company_product/readme/CREDITS.rst b/fiscal_company_product/readme/CREDITS.rst new file mode 100644 index 0000000..26111c6 --- /dev/null +++ b/fiscal_company_product/readme/CREDITS.rst @@ -0,0 +1,6 @@ +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 new file mode 100644 index 0000000..f39c20f --- /dev/null +++ b/fiscal_company_product/readme/DESCRIPTION.rst @@ -0,0 +1,13 @@ +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 diff --git a/fiscal_company_product/tests/__init__.py b/fiscal_company_product/tests/__init__.py index 17b8206..d9b96c4 100644 --- a/fiscal_company_product/tests/__init__.py +++ b/fiscal_company_product/tests/__init__.py @@ -1,2 +1 @@ -# coding: utf-8 from . import test_module diff --git a/fiscal_company_product/tests/test_module.py b/fiscal_company_product/tests/test_module.py index 77a312a..0783432 100644 --- a/fiscal_company_product/tests/test_module.py +++ b/fiscal_company_product/tests/test_module.py @@ -1,4 +1,3 @@ -# coding: utf-8 # 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). @@ -12,8 +11,8 @@ class TestModule(TransactionCase): # Overload Section def setUp(self): - super(TestModule, self).setUp() - self.product_obj = self.env['product.product'] + 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') @@ -42,6 +41,6 @@ def _create_administrative_product(self, user): 'cae_administrative_ok': True, } user.company_id = self.child_company.id - self.product_obj.sudo(user).with_context( + 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 index b36b486..258970d 100644 --- a/fiscal_company_product/views/view_product_template.xml +++ b/fiscal_company_product/views/view_product_template.xml @@ -5,7 +5,7 @@ Copyright (C) 2014-Today: GRAP (http://www.grap.coop) License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). --> - + product.template @@ -18,4 +18,4 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - + From d5fead2659b5d76e0aba5a70d252575dd3073da0 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Tue, 16 Feb 2021 15:25:48 +0100 Subject: [PATCH 13/22] [AUTOFIX] pre-commit --- fiscal_company_product/__init__.py | 1 - fiscal_company_product/demo/product_product.xml | 2 -- fiscal_company_product/demo/product_template.xml | 2 -- fiscal_company_product/tests/test_module.py | 2 +- 4 files changed, 1 insertion(+), 6 deletions(-) diff --git a/fiscal_company_product/__init__.py b/fiscal_company_product/__init__.py index 4213b8b..0650744 100644 --- a/fiscal_company_product/__init__.py +++ b/fiscal_company_product/__init__.py @@ -1,2 +1 @@ -# -*- encoding: utf-8 -*- from . import models diff --git a/fiscal_company_product/demo/product_product.xml b/fiscal_company_product/demo/product_product.xml index a850d48..dc9184a 100644 --- a/fiscal_company_product/demo/product_product.xml +++ b/fiscal_company_product/demo/product_product.xml @@ -19,5 +19,3 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - - diff --git a/fiscal_company_product/demo/product_template.xml b/fiscal_company_product/demo/product_template.xml index 19eb25c..87ef00f 100644 --- a/fiscal_company_product/demo/product_template.xml +++ b/fiscal_company_product/demo/product_template.xml @@ -26,5 +26,3 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - - diff --git a/fiscal_company_product/tests/test_module.py b/fiscal_company_product/tests/test_module.py index 0783432..40bc098 100644 --- a/fiscal_company_product/tests/test_module.py +++ b/fiscal_company_product/tests/test_module.py @@ -2,8 +2,8 @@ # @author Sylvain LE GAL (https://twitter.com/legalsylvain) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo.tests.common import TransactionCase from odoo.exceptions import ValidationError +from odoo.tests.common import TransactionCase class TestModule(TransactionCase): From c8236c35e8014a526271628198d0aa1cd8289023 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Tue, 16 Feb 2021 20:03:24 +0100 Subject: [PATCH 14/22] [BLACK] --- fiscal_company_product/__manifest__.py | 43 +++++++++---------- .../models/product_template.py | 25 +++++------ fiscal_company_product/tests/test_module.py | 24 +++++------ 3 files changed, 44 insertions(+), 48 deletions(-) diff --git a/fiscal_company_product/__manifest__.py b/fiscal_company_product/__manifest__.py index 57d945d..fa90bf8 100644 --- a/fiscal_company_product/__manifest__.py +++ b/fiscal_company_product/__manifest__.py @@ -3,29 +3,26 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { - 'name': 'CAE - Product', - 'version': '12.0.1.0.0', - 'category': 'CAE', - 'summary': 'Glue Module between CAE and Product modules', - 'author': 'GRAP', - 'website': 'http://www.grap.coop', - 'license': 'AGPL-3', - 'depends': [ - 'fiscal_company_base', - 'product', + "name": "CAE - Product", + "version": "12.0.1.0.0", + "category": "CAE", + "summary": "Glue Module between CAE and Product modules", + "author": "GRAP", + "website": "http://www.grap.coop", + "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", ], - '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", ], - 'demo': [ - 'demo/res_groups.xml', - 'demo/product_pricelist.xml', - 'demo/product_template.xml', - 'demo/product_product.xml', - ], - 'installable': True, - 'auto_install': True, + "installable": True, + "auto_install": True, } diff --git a/fiscal_company_product/models/product_template.py b/fiscal_company_product/models/product_template.py index 13cc8b8..561a264 100644 --- a/fiscal_company_product/models/product_template.py +++ b/fiscal_company_product/models/product_template.py @@ -7,39 +7,40 @@ class ProductTemplate(models.Model): - _inherit = 'product.template' + _inherit = "product.template" # Columns Section cae_administrative_ok = fields.Boolean( - string='Is CAE Administrative', + string="Is CAE Administrative", help="If checked, this product will be readonly for users and" - " updatable only by specific group") + " updatable only by specific group", + ) # Overload Section @api.model def create(self, vals): - if vals.get('cae_administrative_ok', False): + if vals.get("cae_administrative_ok", False): self._check_administrative_access() return super().create(vals) @api.multi def write(self, vals): - if vals.get('cae_administrative_ok', False) or\ - any(self.mapped('cae_administrative_ok')): + if 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')): + 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")) + 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") + ) diff --git a/fiscal_company_product/tests/test_module.py b/fiscal_company_product/tests/test_module.py index 40bc098..3861815 100644 --- a/fiscal_company_product/tests/test_module.py +++ b/fiscal_company_product/tests/test_module.py @@ -12,13 +12,11 @@ class TestModule(TransactionCase): # 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') + 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") # Test Section def test_01_administrative_product_creation(self): @@ -35,12 +33,12 @@ def test_01_administrative_product_creation(self): 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, + "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 self.ProductProduct.sudo(user).with_context( - mail_create_nosubscribe=True, - mail_create_nolog=True).create(product_vals) + mail_create_nosubscribe=True, mail_create_nolog=True + ).create(product_vals) From cf5c8334be66d0e9148e00cab3603184b4ff6609 Mon Sep 17 00:00:00 2001 From: Github GRAP Bot Date: Mon, 22 Feb 2021 09:20:44 +0000 Subject: [PATCH 15/22] fiscal_company_product 12.0.1.1.0 --- fiscal_company_product/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fiscal_company_product/__manifest__.py b/fiscal_company_product/__manifest__.py index fa90bf8..1496c48 100644 --- a/fiscal_company_product/__manifest__.py +++ b/fiscal_company_product/__manifest__.py @@ -4,7 +4,7 @@ { "name": "CAE - Product", - "version": "12.0.1.0.0", + "version": "12.0.1.1.0", "category": "CAE", "summary": "Glue Module between CAE and Product modules", "author": "GRAP", From 8150d2c871758e9349bca774c2a741337decf3b5 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Mon, 25 Oct 2021 12:03:19 +0200 Subject: [PATCH 16/22] [12.0][REF] uniformize website in __manifest__.py + add pre-commit check --- fiscal_company_product/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fiscal_company_product/__manifest__.py b/fiscal_company_product/__manifest__.py index 1496c48..8a1b947 100644 --- a/fiscal_company_product/__manifest__.py +++ b/fiscal_company_product/__manifest__.py @@ -8,7 +8,7 @@ "category": "CAE", "summary": "Glue Module between CAE and Product modules", "author": "GRAP", - "website": "http://www.grap.coop", + "website": "https://github.com/grap/odoo-addons-cae", "license": "AGPL-3", "depends": ["fiscal_company_base", "product"], "data": [ From 7d03afa8a50e9898ccf62d9204bb463f5d879905 Mon Sep 17 00:00:00 2001 From: Github GRAP Bot Date: Tue, 26 Oct 2021 06:21:54 +0000 Subject: [PATCH 17/22] [UPD] README.rst --- fiscal_company_product/README.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fiscal_company_product/README.rst b/fiscal_company_product/README.rst index ab86814..62a1987 100644 --- a/fiscal_company_product/README.rst +++ b/fiscal_company_product/README.rst @@ -13,9 +13,9 @@ CAE - Product .. |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-odoo-cae%2Fodoo--addons--cae-lightgray.png?logo=github - :target: https://github.com/odoo-cae/odoo-addons-cae/tree/12.0/fiscal_company_product - :alt: odoo-cae/odoo-addons-cae +.. |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| @@ -41,10 +41,10 @@ This module is a glue module for the Odoo Product module. Bug Tracker =========== -Bugs are tracked on `GitHub Issues `_. +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 smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -75,6 +75,6 @@ Porting from odoo V8 to odoo V10 has been funded by : Maintainers ~~~~~~~~~~~ -This module is part of the `odoo-cae/odoo-addons-cae `_ project on GitHub. +This module is part of the `grap/odoo-addons-cae `_ project on GitHub. You are welcome to contribute. From 5ef337b37250344d0f24ccf4134d8599939fd969 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Mon, 27 Mar 2023 00:51:23 +0200 Subject: [PATCH 18/22] [FIX] fiscal_company_product : allow basic user to write non sensitive fields on administrative_ok product --- .../models/product_template.py | 19 +++++++++++-- fiscal_company_product/tests/test_module.py | 27 ++++++++++++++++--- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/fiscal_company_product/models/product_template.py b/fiscal_company_product/models/product_template.py index 561a264..73f2e40 100644 --- a/fiscal_company_product/models/product_template.py +++ b/fiscal_company_product/models/product_template.py @@ -25,8 +25,14 @@ def create(self, vals): @api.multi def write(self, vals): - if vals.get("cae_administrative_ok", False) or any( - self.mapped("cae_administrative_ok") + 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) @@ -44,3 +50,12 @@ def _check_administrative_access(self): 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", + ] diff --git a/fiscal_company_product/tests/test_module.py b/fiscal_company_product/tests/test_module.py index 3861815..caff96b 100644 --- a/fiscal_company_product/tests/test_module.py +++ b/fiscal_company_product/tests/test_module.py @@ -18,19 +18,36 @@ def setUp(self): 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 - self._create_administrative_product(self.user_accountant) + 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", @@ -39,6 +56,8 @@ def _create_administrative_product(self, user): "cae_administrative_ok": True, } user.company_id = self.child_company.id - self.ProductProduct.sudo(user).with_context( - mail_create_nosubscribe=True, mail_create_nolog=True - ).create(product_vals) + return ( + self.ProductProduct.sudo(user) + .with_context(mail_create_nosubscribe=True, mail_create_nolog=True) + .create(product_vals) + ) From 645223f84c40842683793679dcf5262b2e4c2f87 Mon Sep 17 00:00:00 2001 From: Github GRAP Bot Date: Tue, 18 Apr 2023 12:00:41 +0000 Subject: [PATCH 19/22] fiscal_company_product 12.0.1.1.1 --- fiscal_company_product/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fiscal_company_product/__manifest__.py b/fiscal_company_product/__manifest__.py index 8a1b947..f59b01b 100644 --- a/fiscal_company_product/__manifest__.py +++ b/fiscal_company_product/__manifest__.py @@ -4,7 +4,7 @@ { "name": "CAE - Product", - "version": "12.0.1.1.0", + "version": "12.0.1.1.1", "category": "CAE", "summary": "Glue Module between CAE and Product modules", "author": "GRAP", From 79e4128f605f08d631ad673e7ea238d7b2b2c713 Mon Sep 17 00:00:00 2001 From: Github GRAP Bot Date: Wed, 22 Nov 2023 00:39:19 +0000 Subject: [PATCH 20/22] [BOT] post-merge updates --- fiscal_company_product/README.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fiscal_company_product/README.rst b/fiscal_company_product/README.rst index 62a1987..14c047e 100644 --- a/fiscal_company_product/README.rst +++ b/fiscal_company_product/README.rst @@ -2,10 +2,13 @@ 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 @@ -17,7 +20,7 @@ CAE - Product :target: https://github.com/grap/odoo-addons-cae/tree/12.0/fiscal_company_product :alt: grap/odoo-addons-cae -|badge1| |badge2| |badge3| +|badge1| |badge2| |badge3| This module extend Odoo functionnalities, regarding companies features to manage CAE (Coopearatives of Activities and Employment) that is a special @@ -43,7 +46,7 @@ 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 smashing it by providing a detailed and welcomed +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. From 02f9920bfa49634f9a6a562bc80807a661a1277b Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Wed, 27 Nov 2024 01:30:07 +0100 Subject: [PATCH 21/22] [IMP] fiscal_company_product: pre-commit stuff --- .../odoo/addons/fiscal_company_product | 1 + setup/fiscal_company_product/setup.py | 6 ++++++ 2 files changed, 7 insertions(+) create mode 120000 setup/fiscal_company_product/odoo/addons/fiscal_company_product create mode 100644 setup/fiscal_company_product/setup.py diff --git a/setup/fiscal_company_product/odoo/addons/fiscal_company_product b/setup/fiscal_company_product/odoo/addons/fiscal_company_product new file mode 120000 index 0000000..23f13ca --- /dev/null +++ b/setup/fiscal_company_product/odoo/addons/fiscal_company_product @@ -0,0 +1 @@ +../../../../fiscal_company_product \ No newline at end of file diff --git a/setup/fiscal_company_product/setup.py b/setup/fiscal_company_product/setup.py new file mode 100644 index 0000000..28c57bb --- /dev/null +++ b/setup/fiscal_company_product/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) From 12b33e0b8bff33f087bf72fc98971b4ab77e4885 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Wed, 27 Nov 2024 01:30:07 +0100 Subject: [PATCH 22/22] [MIG] fiscal_company_product: Migration to 16.0 (from 12.0) --- fiscal_company_product/README.rst | 83 -------------- fiscal_company_product/__manifest__.py | 14 +-- .../demo/product_pricelist.xml | 23 ---- .../demo/product_product.xml | 21 ---- .../demo/product_template.xml | 28 ----- fiscal_company_product/demo/res_groups.xml | 31 ------ fiscal_company_product/i18n/fr.po | 104 ------------------ fiscal_company_product/models/__init__.py | 1 + .../models/product_pricelist.py | 12 ++ .../models/product_template.py | 59 +--------- fiscal_company_product/readme/CREDITS.rst | 6 - fiscal_company_product/readme/DESCRIPTION.rst | 7 +- .../security/ir.model.access.csv | 6 - fiscal_company_product/security/ir_rule.xml | 23 ---- .../security/res_groups.xml | 15 --- fiscal_company_product/tests/__init__.py | 1 - fiscal_company_product/tests/test_module.py | 63 ----------- .../views/view_product_template.xml | 21 ---- 18 files changed, 21 insertions(+), 497 deletions(-) delete mode 100644 fiscal_company_product/demo/product_pricelist.xml delete mode 100644 fiscal_company_product/demo/product_product.xml delete mode 100644 fiscal_company_product/demo/product_template.xml delete mode 100644 fiscal_company_product/demo/res_groups.xml create mode 100644 fiscal_company_product/models/product_pricelist.py delete mode 100644 fiscal_company_product/readme/CREDITS.rst delete mode 100644 fiscal_company_product/security/ir.model.access.csv delete mode 100644 fiscal_company_product/security/ir_rule.xml delete mode 100644 fiscal_company_product/security/res_groups.xml delete mode 100644 fiscal_company_product/tests/__init__.py delete mode 100644 fiscal_company_product/tests/test_module.py delete mode 100644 fiscal_company_product/views/view_product_template.xml 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 - - - - - - - - -