diff options
| author | Krupal Oza <koz@odoo.com> | 2020-08-11 14:11:22 +0000 |
|---|---|---|
| committer | Barad Mahendra <mba@openerp.com> | 2020-12-10 05:01:30 +0000 |
| commit | 713ecc290909834671b155aa93b31dca6b3c18b2 (patch) | |
| tree | d36e8f2c2645cc36b48e49d63751890ece3403aa /addons | |
| parent | 4d162a36c8d24799f7b64d73a199a0ec87a30ee9 (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')
| -rw-r--r-- | addons/coupon/models/coupon_program.py | 22 | ||||
| -rw-r--r-- | addons/sale_coupon/models/coupon_program.py | 5 |
2 files changed, 18 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 + } diff --git a/addons/sale_coupon/models/coupon_program.py b/addons/sale_coupon/models/coupon_program.py index 7b9c2f327d2..e9bef9a1cf2 100644 --- a/addons/sale_coupon/models/coupon_program.py +++ b/addons/sale_coupon/models/coupon_program.py @@ -175,6 +175,11 @@ class CouponProgram(models.Model): programs += programs_curr_order._filter_not_ordered_reward_programs(order) return programs + def _get_discount_product_values(self): + res = super()._get_discount_product_values() + res['invoice_policy'] = 'order' + return res + def _is_global_discount_program(self): self.ensure_one() return self.promo_applicability == 'on_current_order' and \ |
