summaryrefslogtreecommitdiff
path: root/addons/coupon
diff options
context:
space:
mode:
authorKrupal Oza <koz@odoo.com>2020-08-11 14:11:22 +0000
committerBarad Mahendra <mba@openerp.com>2020-12-10 05:01:30 +0000
commit713ecc290909834671b155aa93b31dca6b3c18b2 (patch)
treed36e8f2c2645cc36b48e49d63751890ece3403aa /addons/coupon
parent4d162a36c8d24799f7b64d73a199a0ec87a30ee9 (diff)
[FIX] sale_(coupon): Fix coupon reflection on invoice
The purpose of this task is to reflect the coupon discount perfectly from sale order to invoice. This issue is already fixed in 13.0 in commit: bb5d999 but during refactor of coupon it was removed due to module split. So in this commit, improve the default invoicing policy of coupon product. The default invoicing policy should always be by ordered quantity. Otherwise, if the user changes the default invoicing policy to "delivered quantity", coupon won't be applied to the invoice. closes odoo/odoo#63119 Taskid: 2303244 Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
Diffstat (limited to 'addons/coupon')
-rw-r--r--addons/coupon/models/coupon_program.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/addons/coupon/models/coupon_program.py b/addons/coupon/models/coupon_program.py
index b61bccc560d..afcb3da6768 100644
--- a/addons/coupon/models/coupon_program.py
+++ b/addons/coupon/models/coupon_program.py
@@ -86,15 +86,8 @@ class CouponProgram(models.Model):
def create(self, vals):
program = super(CouponProgram, self).create(vals)
if not vals.get('discount_line_product_id', False):
- discount_line_product_id = self.env['product.product'].create({
- 'name': program.reward_id.display_name,
- 'type': 'service',
- 'taxes_id': False,
- 'supplier_taxes_id': False,
- 'sale_ok': False,
- 'purchase_ok': False,
- 'lst_price': 0, #Do not set a high value to avoid issue with coupon code
- })
+ values = program._get_discount_product_values()
+ discount_line_product_id = self.env['product.product'].create(values)
program.write({'discount_line_product_id': discount_line_product_id.id})
return program
@@ -153,3 +146,14 @@ class CouponProgram(models.Model):
domain = ast.literal_eval(self.rule_products_domain)
return products.filtered_domain(domain)
return products
+
+ def _get_discount_product_values(self):
+ return {
+ 'name': self.reward_id.display_name,
+ 'type': 'service',
+ 'taxes_id': False,
+ 'supplier_taxes_id': False,
+ 'sale_ok': False,
+ 'purchase_ok': False,
+ 'lst_price': 0, #Do not set a high value to avoid issue with coupon code
+ }