diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-07-21 17:03:15 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-07-21 17:03:15 +0700 |
| commit | bc0c9e782140d82dc2147afb4a049c37141b081a (patch) | |
| tree | b41fba25c0b28ecbb9817a11e3594f1fcb8e482d /indoteknik_custom/models/voucher.py | |
| parent | c758c2c63243a01e090a7640839b2dd7ce9476be (diff) | |
Add exclude voucher pricelist API
Diffstat (limited to 'indoteknik_custom/models/voucher.py')
| -rw-r--r-- | indoteknik_custom/models/voucher.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/indoteknik_custom/models/voucher.py b/indoteknik_custom/models/voucher.py index 839a5d47..b3a55499 100644 --- a/indoteknik_custom/models/voucher.py +++ b/indoteknik_custom/models/voucher.py @@ -40,11 +40,12 @@ class Voucher(models.Model): order_ids = fields.One2many('sale.order', 'voucher_id', string='Order') limit = fields.Integer(string='Limit', help='Voucher limit by sale order. Masukan 0 untuk tanpa limit') manufacture_ids = fields.Many2many('x_manufactures', string='Brands', help='Voucher appplied only for brand') + excl_pricelist_ids = fields.Many2many('product.pricelist', string='Excluded Pricelists', help='Hide voucher from selected exclude pricelist') @api.constrains('description') def _check_description_length(self): for record in self: - if len(record.description) > 120: + if record.description and len(record.description) > 120: raise ValidationError('Description cannot exceed 120 characters') def _compute_display_name(self): @@ -71,7 +72,8 @@ class Voucher(models.Model): 'min_purchase_amount': self.min_purchase_amount, 'max_discount_amount': max_discount_amount, 'manufacture_names': ", ".join([x.x_name for x in self.manufacture_ids]), - 'manufacture_ids': [x.id for x in self.manufacture_ids] + 'manufacture_ids': [x.id for x in self.manufacture_ids], + 'excl_pricelist_ids': [x.id for x in self.excl_pricelist_ids], } return data |
