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

[IMP] joint_buying_product: avoid bad configuration if use Order Cate… #106

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
6 changes: 6 additions & 0 deletions joint_buying_product/i18n/fr.po
Original file line number Diff line number Diff line change
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/res_partner.py:105
#, python-format
msgid "You can not uncheck 'Use Order Categories' if some categories are defined in the 'Next Orders' Section."
msgstr "Vous ne pouvez pas décocher la case 'Utiliser les catégories de commandes, si certaines catégories sont paramétrées dans la section 'Prochaines commandes'."

#. module: joint_buying_product
#: code:addons/joint_buying_product/models/joint_buying_purchase_order.py:407
#, python-format
Expand Down
14 changes: 13 additions & 1 deletion joint_buying_product/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +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 import api, fields, models
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError


class ResPartner(models.Model):
Expand Down Expand Up @@ -94,6 +95,17 @@ def _compute_joint_buying_grouped_order_qty(self):
partner.joint_buying_grouped_order_ids
)

@api.constrains("joint_buying_use_category", "joint_buying_frequency_ids")
def _check_joint_buying_use_category(self):
for partner in self.filtered(lambda x: not x.joint_buying_use_category):
if partner.mapped("joint_buying_frequency_ids.category_ids"):
raise ValidationError(
_(
"You can not uncheck 'Use Order Categories'"
" if some categories are defined in the 'Next Orders' Section."
)
)

# Custom Section
def _get_joint_buying_products(self, categories):
self.ensure_one()
Expand Down
Loading