| 1 |
# -*- coding: utf-8 -*- |
| 2 |
|
| 3 |
from odoo import _, api, models |
| 4 |
|
| 5 |
|
| 6 |
class ProductPricelistItem(models.Model): |
| 7 |
_inherit = "product.pricelist.item" |
| 8 |
|
| 9 |
@api.onchange('applied_on', 'product_id', 'product_tmpl_id', 'min_quantity') |
| 10 |
def _onchange_event_sale_warning(self): |
| 11 |
if self.min_quantity > 0: |
| 12 |
msg = '' |
| 13 |
if self.applied_on == '3_global' or self.applied_on == '2_product_category': |
| 14 |
msg = _("A pricelist item with a positive min. quantity will not be applied to the event tickets products.") |
| 15 |
elif ((self.applied_on == '1_product' and self.product_tmpl_id.service_tracking == 'event') or |
| 16 |
(self.applied_on == '0_product_variant' and self.product_id.service_tracking == 'event')): |
| 17 |
msg = _("A pricelist item with a positive min. quantity cannot be applied to this event tickets product.") |
| 18 |
if msg: |
| 19 |
return {'warning': |
| 20 |
{ |
| 21 |
'title': _("Warning"), |
| 22 |
'message': msg |
| 23 |
} |
| 24 |
} |