From c7acd24333cc0c2422cd9f63be275d0734ec8a4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 5 Dec 2024 19:34:39 +0100 Subject: [PATCH] Remove name on sale promotion coupon Closes #13737 --- modules/sale_promotion_coupon/CHANGELOG | 1 + modules/sale_promotion_coupon/sale.py | 11 ++++++++++- .../tests/scenario_sale_promotion_coupon.rst | 2 +- .../tests/scenario_sale_promotion_coupon_unique.rst | 4 ++-- modules/sale_promotion_coupon/view/coupon_form.xml | 5 +---- modules/sale_promotion_coupon/view/coupon_list.xml | 1 - 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/modules/sale_promotion_coupon/CHANGELOG b/modules/sale_promotion_coupon/CHANGELOG index df3ee733d2..4d0cd0659b 100644 --- a/modules/sale_promotion_coupon/CHANGELOG +++ b/modules/sale_promotion_coupon/CHANGELOG @@ -1,3 +1,4 @@ +* Remove name on coupon Version 7.4.0 - 2024-11-04 -------------------------- diff --git a/modules/sale_promotion_coupon/sale.py b/modules/sale_promotion_coupon/sale.py index 0317564e09..5e1a1278bb 100644 --- a/modules/sale_promotion_coupon/sale.py +++ b/modules/sale_promotion_coupon/sale.py @@ -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' diff --git a/modules/sale_promotion_coupon/tests/scenario_sale_promotion_coupon.rst b/modules/sale_promotion_coupon/tests/scenario_sale_promotion_coupon.rst index c7c81a2a88..e39a905001 100644 --- a/modules/sale_promotion_coupon/tests/scenario_sale_promotion_coupon.rst +++ b/modules/sale_promotion_coupon/tests/scenario_sale_promotion_coupon.rst @@ -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() diff --git a/modules/sale_promotion_coupon/tests/scenario_sale_promotion_coupon_unique.rst b/modules/sale_promotion_coupon/tests/scenario_sale_promotion_coupon_unique.rst index a41a84f8e4..b56e09d461 100644 --- a/modules/sale_promotion_coupon/tests/scenario_sale_promotion_coupon_unique.rst +++ b/modules/sale_promotion_coupon/tests/scenario_sale_promotion_coupon_unique.rst @@ -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): diff --git a/modules/sale_promotion_coupon/view/coupon_form.xml b/modules/sale_promotion_coupon/view/coupon_form.xml index c002417bf2..4429eba281 100644 --- a/modules/sale_promotion_coupon/view/coupon_form.xml +++ b/modules/sale_promotion_coupon/view/coupon_form.xml @@ -1,15 +1,12 @@ -
+