[FIX] website_sale: avoid archiving loyalty program products

A product can't be archived if it's used in a pos loyalty program.

opw-2276745

closes odoo/odoo#53948

X-original-commit: 3af9b65638a9725fbeb6597b77328d8f6be5b2ec
Related: odoo/enterprise#11590
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
This commit is contained in:
Jorge Pinna Puissant
2020-07-02 07:52:21 +00:00
parent df50a215f4
commit 4b8d716188
@@ -14,6 +14,13 @@ class TestWebsiteSequence(odoo.tests.TransactionCase):
# if stock is installed we can't archive since there is orderpoints
if hasattr(self.env['product.product'], 'orderpoint_ids'):
product_templates.mapped('product_variant_ids.orderpoint_ids').write({'active': False})
# if pos loyalty is installed we can't archive since there are loyalty rules and rewards
if 'loyalty.rule' in self.env:
rules = self.env['loyalty.rule'].search([])
rules.unlink()
if 'loyalty.reward' in self.env:
rewards = self.env['loyalty.reward'].search([])
rewards.unlink()
product_templates.write({'active': False})
self.p1, self.p2, self.p3, self.p4 = ProductTemplate.create([{
'name': 'First Product',