Skip to content

Commit

Permalink
Merge PR #106 into 12.0
Browse files Browse the repository at this point in the history
Signed-off-by legalsylvain
  • Loading branch information
github-grap-bot committed Nov 18, 2024
2 parents 9faca6b + a07de47 commit 8f14edc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions joint_buying_product/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -2507,6 +2507,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

0 comments on commit 8f14edc

Please sign in to comment.