summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJorge Pinna Puissant <jpp@odoo.com>2019-02-28 08:59:25 +0000
committerJorge Pinna Puissant <jpp@odoo.com>2019-02-28 08:59:25 +0000
commitd92eba3a1999ba08c83b6b60c16633ba813bd500 (patch)
tree05af326679a6fac9cec0d8cc02b194fadbde09ee
parent4613d0a80b9a9ef84cc2aa9638b0f3929a3793b8 (diff)
[FIX] website_event_sale: pricelist discount product qty
Before this commit, a pricelist discount based on the product qty could be created and the user may believe that it will work also for event tickets. Now: when configuring a pricelist discount based on the product qty a warning message is show to alert that this kind of discount don't work in event tickets. opw-1940368 closes odoo/odoo#31459 Signed-off-by: "Lucas Perais (lpe)" <lpe@odoo.com>
-rw-r--r--addons/website_event_sale/i18n/website_event_sale.pot18
-rw-r--r--addons/website_event_sale/models/__init__.py1
-rw-r--r--addons/website_event_sale/models/product_pricelist.py23
3 files changed, 42 insertions, 0 deletions
diff --git a/addons/website_event_sale/i18n/website_event_sale.pot b/addons/website_event_sale/i18n/website_event_sale.pot
index 5e4e6269efa..0a748840de1 100644
--- a/addons/website_event_sale/i18n/website_event_sale.pot
+++ b/addons/website_event_sale/i18n/website_event_sale.pot
@@ -31,6 +31,18 @@ msgid "<span>left</span>"
msgstr ""
#. module: website_event_sale
+#: code:addons/website_event_sale/models/product_pricelist.py:16
+#, python-format
+msgid "A pricelist item with a positive min. quantity cannot be applied to this event tickets product."
+msgstr ""
+
+#. module: website_event_sale
+#: code:addons/website_event_sale/models/product_pricelist.py:13
+#, python-format
+msgid "A pricelist item with a positive min. quantity will not be applied to the event tickets products."
+msgstr ""
+
+#. module: website_event_sale
#: model:ir.ui.view,arch_db:website_event_sale.index
msgid "Only"
msgstr ""
@@ -80,6 +92,12 @@ msgid "The ticket doesn't match with this product."
msgstr ""
#. module: website_event_sale
+#: code:addons/website_event_sale/models/product_pricelist.py:20
+#, python-format
+msgid "Warning"
+msgstr ""
+
+#. module: website_event_sale
#: model:ir.model,name:website_event_sale.model_website
msgid "Website"
msgstr ""
diff --git a/addons/website_event_sale/models/__init__.py b/addons/website_event_sale/models/__init__.py
index 1bd7829ab86..a9c94cbe9ae 100644
--- a/addons/website_event_sale/models/__init__.py
+++ b/addons/website_event_sale/models/__init__.py
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from . import product
+from . import product_pricelist
from . import sale_order
from . import website
diff --git a/addons/website_event_sale/models/product_pricelist.py b/addons/website_event_sale/models/product_pricelist.py
new file mode 100644
index 00000000000..5b0d4465759
--- /dev/null
+++ b/addons/website_event_sale/models/product_pricelist.py
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+
+from odoo import _, api, models
+
+class PricelistItem(models.Model):
+ _inherit = "product.pricelist.item"
+
+ @api.onchange('applied_on', 'product_id', 'product_tmpl_id', 'min_quantity')
+ def _onchange_event_sale_warning(self):
+ if self.min_quantity > 0:
+ msg = ''
+ if self.applied_on == '3_global' or self.applied_on == '2_product_category':
+ msg = _("A pricelist item with a positive min. quantity will not be applied to the event tickets products.")
+ elif ((self.applied_on == '1_product' and self.product_tmpl_id.event_ok) or
+ (self.applied_on == '0_product_variant' and self.product_id.event_ok)):
+ msg = _("A pricelist item with a positive min. quantity cannot be applied to this event tickets product.")
+ if msg:
+ return {'warning':
+ {
+ 'title': _("Warning"),
+ 'message': msg
+ }
+ }