Skip to content

Commit

Permalink
[FIX] joint_buying_product : update global data for product you don't…
Browse files Browse the repository at this point in the history
… own should be not possible !
  • Loading branch information
legalsylvain committed Oct 18, 2024
1 parent 897fdb4 commit ffd7754
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
18 changes: 12 additions & 6 deletions joint_buying_product/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -2321,12 +2321,6 @@ msgstr "URL du document en ligne qui sera ajouté automatiquement dans l'email e
msgid "Unavailable Product (450gr) (Global)"
msgstr "Article indisponible (450gr) (Global)"

#. module: joint_buying_product
#: code:addons/joint_buying_product/models/product_product.py:175
#, python-format
msgid "Unimplemented Feature"
msgstr "Fonctionnalité non implémentée"

#. module: joint_buying_product
#: model_terms:ir.ui.view,arch_db:joint_buying_product.view_joint_buying_purchase_order_form
#: model_terms:ir.ui.view,arch_db:joint_buying_product.view_joint_buying_purchase_order_grouped_form
Expand Down Expand Up @@ -2461,6 +2455,12 @@ msgstr "Si un message est une note interne (en mode commentaire seulement)"
msgid "Wizard"
msgstr "Assistant"

#. module: joint_buying_product
#: code:addons/joint_buying_product/models/product_product.py:180
#, python-format
msgid "You can not change the relation between a global product and a local product if you sale it."
msgstr "Vous ne pouvez pas changer le lien entre un produit global et un produit local si vous en êtes le fournisseur."

#. module: joint_buying_product
#: code:addons/joint_buying_product/models/product_product.py:152
#, python-format
Expand Down Expand Up @@ -2501,6 +2501,12 @@ msgstr "Vous ne pouvez pas mettre une unité de mesure poids / unité, si l'arti
msgid "You can not set a negative quantity in the 'Purchase Quantity' field !"
msgstr "Vous ne pouvez pas saisir de quantité négative dans le champ 'quantité à commander' !"

#. module: joint_buying_product
#: code:addons/joint_buying_product/models/product_product.py:231
#, python-format
msgid "You can not update the data of the product that belong to %s."
msgstr "Vous ne pouvez pas mettre à jour les données d'un produit qui appartient à %s."

#. module: joint_buying_product
#: code:addons/joint_buying_product/models/joint_buying_purchase_order.py:407
#, python-format
Expand Down
12 changes: 11 additions & 1 deletion joint_buying_product/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from datetime import timedelta

from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
from odoo.exceptions import AccessError, ValidationError

from odoo.addons.joint_buying_base.models.res_partner import (
_JOINT_BUYING_PARTNER_CONTEXT,
Expand Down Expand Up @@ -223,6 +223,16 @@ def update_joint_buying_product(self):
global_product = product.joint_buying_product_id.with_context(
joint_buying=True, joint_buying_local_to_global=True
)
if (
product.company_id.joint_buying_partner_id
!= global_product.joint_buying_partner_id
):
raise AccessError(
_(
"You can not update the data of the product that belong to %s."
% global_product.joint_buying_partner_id.name
)
)
global_product.write(vals)

def _prepare_joint_buying_product(self, action):
Expand Down

0 comments on commit ffd7754

Please sign in to comment.