Remove name on sale promotion coupon

Closes #13737
This commit is contained in:
Cédric Krier committed 2024-12-05 19:34:39 +01:00
1 parent 184536c72a
commit c7acd24333
6 files changed
+15 -9

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Remove name on coupon
Version 7.4.0 - 2024-11-04
--------------------------
+10 -1
View File
@@ -68,7 +68,6 @@ class Promotion(metaclass=PoolMeta):
class PromotionCoupon(ModelSQL, ModelView):
__name__ = 'sale.promotion.coupon'
name = fields.Char("Name", required=True)
number_of_use = fields.Integer(
"Number of Use", required=True,
help="How much times a coupon number can be used.\n"
@@ -116,6 +115,9 @@ class PromotionCoupon(ModelSQL, ModelView):
promotion.company,
where=promotion.id == table.promotion)]))
# Migration from 7.4: remove name
table_h.not_null_action('name', 'remove')
@classmethod
def default_company(cls):
return Transaction().context.get('company')
@@ -128,6 +130,13 @@ class PromotionCoupon(ModelSQL, ModelView):
def default_per_party(cls):
return False
def get_rec_name(self, name):
return self.promotion.rec_name
@classmethod
def search_rec_name(cls, name, clause):
return [('promotion.rec_name', *clause[1:])]
class PromotionCouponNumber(DeactivableMixin, ModelSQL, ModelView):
__name__ = 'sale.promotion.coupon.number'
@@ -56,7 +56,7 @@ Create Promotion with coupon::
>>> Promotion = Model.get('sale.promotion')
>>> promotion = Promotion(name="10%")
>>> promotion.formula = '0.9 * unit_price'
>>> coupon = promotion.coupons.new(name="Promo")
>>> coupon = promotion.coupons.new()
>>> coupon.number_of_use = 0
>>> number = coupon.numbers.new(number="CODE10")
>>> promotion.save()
@@ -27,7 +27,7 @@ Create a promotion with coupon::
>>> promotion1 = Promotion(name="Promotion 1")
>>> promotion1.formula = 'unit_price'
>>> coupon = promotion1.coupons.new(name="Coupon 1")
>>> coupon = promotion1.coupons.new()
>>> number = coupon.numbers.new(number="TEST", start_date=None)
>>> promotion1.save()
@@ -35,7 +35,7 @@ Try to create a second promotion with same coupon number::
>>> promotion2 = Promotion(name="Promotion 2")
>>> promotion2.formula = 'unit_price'
>>> coupon = promotion2.coupons.new(name="Coupon 2")
>>> coupon = promotion2.coupons.new()
>>> number = coupon.numbers.new(number="TEST")
>>> promotion2.save()
Traceback (most recent call last):
@@ -1,15 +1,12 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form>
<form cursor="number_of_use">
<label name="promotion"/>
<field name="promotion"/>
<label name="company"/>
<field name="company"/>
<label name="name"/>
<field name="name" colspan="3"/>
<label name="number_of_use"/>
<field name="number_of_use"/>
<label name="per_party"/>
@@ -4,7 +4,6 @@ this repository contains the full copyright notices and license terms. -->
<tree>
<field name="company" expand="1" optional="1"/>
<field name="promotion" expand="1"/>
<field name="name" expand="1"/>
<field name="number_of_use"/>
<field name="per_party"/>
</tree>