Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

12.0 various fixes relation local global product #108

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -2479,6 +2473,18 @@ msgstr "Vous ne pouvez pas confirmer une commande avec un montant nul."
msgid "You can not confirm an order without any lines."
msgstr "Vous ne pouvez pas confirmer une commande sans lignes."

#. 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: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/product_product.py:136
#, python-format
Expand Down
26 changes: 23 additions & 3 deletions 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 @@ -171,8 +171,17 @@ def set_joint_buying_local_product_id(self, new_local_product):
if current_local_product == new_local_product:
# Nothing change
return
if current_local_product:
raise ValidationError(_("Unimplemented Feature"))
if (
current_local_product
and current_local_product.company_id.joint_buying_partner_id
== self.joint_buying_partner_id
):
raise ValidationError(
_(
"You can not change the relation between a global product"
" and a local product if you sale it."
)
)
new_local_product.joint_buying_product_id = self and self.id

@api.model
Expand Down Expand Up @@ -209,10 +218,21 @@ def create_joint_buying_product(self):
def update_joint_buying_product(self):
products = self.filtered(lambda x: (x.joint_buying_product_id))
for product in products:

vals = product._prepare_joint_buying_product("update")
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
Loading