[FIX] sale_loyalty: invoice discount lines
Problem: Discount lines are not reflected on invoices when the invoice policy is set to delivered quantities. Loyalty products' invoice policy should be defaulted to invoice on ordered quantities. Thus, if the default is set to invoice on delivered quantities for all products, loyalty products are incorrectly defaulted to invoice on delivered. This feature was removed when loyalty programs was refactored, refer to commit: https://github.com/odoo/odoo/commit/71499bbd23c0e94ffd9b7f82f9d28a5afe045197 Solution: Initialize the loyalty product to have its invoice policy to be on ordered quantities. Steps to Reproduce: Navigate to Sales > Configuration > Settings > Pricing and ensure the Discounts, Loyalty & Gift Card check box is checked Navigate to Sales > Configuration > Settings > Invoicing and set the invoicing policy to Invoice what is delivered Navigate to Sales > Products > Discount and Loyalty Create a new promotion that is available on Sales. Make sure the conditional rules is if minimum $50.00 spent and the rewards is 10.00% discount on your order (which should be set as the defaults) Navigate to Sales and create a new quotation Add a product that costs more than $50 and then click on PROMOTIONS and apply the promotion that was just created and confirm the sale order Navigate to the delivery by clicking on the delivery smart button and click on validate Navigate back to the sales order and click on CREATE INVOICE Then click on CREATE AND VIEW INVOICE You should see the issue that the promotion is not applied on the invoice opw-3582958 closes odoo/odoo#150263 X-original-commit: 9e5b6a48473b344a530f18f1e58121b40328bff3 Signed-off-by: Morgane Demesmaeker <edm@odoo.com>
This commit is contained in:
@@ -13,5 +13,6 @@ class LoyaltyReward(models.Model):
|
||||
vals.update({
|
||||
'taxes_id': False,
|
||||
'supplier_taxes_id': False,
|
||||
'invoice_policy': 'order',
|
||||
})
|
||||
return res
|
||||
|
||||
@@ -23,8 +23,7 @@ class TestSaleInvoicing(TestSaleCouponCommon):
|
||||
'discount_applicability': 'order',
|
||||
})]
|
||||
})
|
||||
# Override the default invoice_policy on products
|
||||
discount_coupon_program.reward_ids.discount_line_product_id.invoice_policy = 'order'
|
||||
|
||||
product = self.env['product.product'].create({
|
||||
'invoice_policy': 'delivery',
|
||||
'name': 'Product invoiced on delivery',
|
||||
@@ -40,6 +39,9 @@ class TestSaleInvoicing(TestSaleCouponCommon):
|
||||
]
|
||||
})
|
||||
|
||||
#Check default invoice_policy on discount product
|
||||
self.assertEqual(discount_coupon_program.reward_ids.discount_line_product_id.invoice_policy, 'order')
|
||||
|
||||
order._update_programs_and_rewards()
|
||||
self._claim_reward(order, discount_coupon_program)
|
||||
# Order is not confirmed, there shouldn't be any invoiceable line
|
||||
@@ -79,8 +81,6 @@ class TestSaleInvoicing(TestSaleCouponCommon):
|
||||
'discount_applicability': 'order',
|
||||
})]
|
||||
})
|
||||
# Override the default invoice_policy on products
|
||||
discount_coupon_program.reward_ids.discount_line_product_id.invoice_policy = 'order'
|
||||
|
||||
order = self.empty_order
|
||||
|
||||
@@ -95,6 +95,9 @@ class TestSaleInvoicing(TestSaleCouponCommon):
|
||||
'order_id': order.id,
|
||||
})
|
||||
|
||||
#Check default invoice_policy on discount product
|
||||
self.assertEqual(discount_coupon_program.reward_ids.discount_line_product_id.invoice_policy, 'order')
|
||||
|
||||
self._auto_rewards(order, discount_coupon_program)
|
||||
|
||||
self.assertEqual(len(order.order_line), 2, 'Coupon correctly applied')
|
||||
|
||||
Reference in New Issue
Block a user