[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>
This commit is contained in:
Jorge Pinna Puissant
2019-02-28 08:59:25 +00:00
parent 4613d0a80b
commit d92eba3a19
3 changed files with 42 additions and 0 deletions
@@ -30,6 +30,18 @@ msgstr ""
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"
@@ -79,6 +91,12 @@ msgstr ""
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"
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from . import product
from . import product_pricelist
from . import sale_order
from . import website
@@ -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
}
}