summaryrefslogtreecommitdiff
path: root/addons/sale_coupon_delivery/models/sale_coupon.py
blob: 717008666648a21784f95d2899797e04de368032 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.


from odoo import models, _


class Coupon(models.Model):
    _inherit = "coupon.coupon"

    def _check_coupon_code(self, order):
        if self.program_id.reward_type == 'free_shipping' and not order.order_line.filtered(lambda line: line.is_delivery):
            return {'error': _('The shipping costs are not in the order lines.')}
        return super(Coupon, self)._check_coupon_code(order)