19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:29:53 +01:00
parent 6e54c1af6c
commit 3ca647e428
1087 changed files with 132065 additions and 108499 deletions

View file

@ -1,62 +1,24 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import Command
from odoo.addons.point_of_sale.tests.common import TestPointOfSaleCommon
from odoo.addons.pos_loyalty.tests.common import CommonPosLoyaltyTest
from odoo.tests.common import tagged
@tagged('-at_install', 'post_install')
class TestUnlinkReward(TestPointOfSaleCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
# Create a loyalty program
cls.loyalty_program = cls.env['loyalty.program'].create({
'name': 'Buy 4 whiteboard_pen, Take 1 whiteboard_pen',
'program_type': 'loyalty',
'trigger': 'auto',
'applies_on': 'both',
'rule_ids': [Command.create({
'product_ids': cls.whiteboard_pen.ids,
'reward_point_mode': 'unit',
'minimum_qty': 1,
})],
})
# Create a reward
cls.reward = cls.env['loyalty.reward'].create({
'program_id': cls.loyalty_program.id,
'reward_type': 'product',
'reward_product_id': cls.whiteboard_pen.id,
'reward_product_qty': 1,
'required_points': 4,
})
class TestUnlinkReward(CommonPosLoyaltyTest):
def test_pos_unlink_reward(self):
self.pos_config.open_ui()
current_session = self.pos_config.current_session_id
self.PosOrder.create({
'company_id': self.env.company.id,
'session_id': current_session.id,
'partner_id': self.partner1.id,
'pricelist_id': self.partner1.property_product_pricelist.id,
'lines': [
Command.create({
'product_id': self.whiteboard_pen.id,
'qty': 5,
'price_subtotal': 12.0,
'price_subtotal_incl': 12.0,
'reward_id': self.reward.id,
})
],
'amount_tax': 0.0,
'amount_total': 134.38,
'amount_paid': 0.0,
'amount_return': 0.0,
self.create_backend_pos_order({
'order_data': {
'partner_id': self.partner_lowe.id,
'pricelist_id': self.partner_lowe.property_product_pricelist.id,
},
'line_data': [{
'qty': 5,
'product_id': self.twenty_dollars_no_tax.product_variant_id.id,
'reward_id': self.twenty_dollars_reward.id,
}],
})
# Attempt to delete the reward
self.reward.unlink()
# Ensure the reward is archived and not deleted
self.assertTrue(self.reward.exists())
self.assertFalse(self.reward.active)
self.twenty_dollars_reward.unlink()
self.assertTrue(self.twenty_dollars_reward.exists())
self.assertFalse(self.twenty_dollars_reward.active)