<commit_before># -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from openerp.tests import common


class TestSaleCouponCommon(common.TransactionCase):

    def setUp(self):
        super(TestSaleCouponCommon, self).setUp()

        # Set all the existing programs to active=False to avoid interference
        self.env['sale.coupon.program'].search([]).write({'active': False})

        # create partner for sale order.
        self.steve = self.env['res.partner'].create({
            'name': '<NAME>',
            'customer': True,
            'email': '<EMAIL>',
        })

        self.empty_order = self.env['sale.order'].create({
            'partner_id': self.steve.id
        })

        self.uom_unit = self.env.ref('product.product_uom_unit')

        #products
        self.product_A = self.env['product.product'].create({
            'name': 'Product A',
            'list_price': 100,
            'sale_ok': True
        })

        self.product_B = self.env['product.product'].create({
            'name': 'Product B',
            'list_price': 5,
            'sale_ok': True
        })

        # Immediate Program By A + B: get B free
        # No Conditions
        self.immediate_promotion_program = self.env['sale.coupon.program'].create({
            'name': 'Buy A + 1 B, 1 B are free',
            'promo_code_usage': 'no_code_needed',
            'reward_type': 'product',
            'reward_product_id': self.product_B.id,
            'rule_products_domain': "[('id', 'in', [%s])]" % (self.product_A.id),
            'active': True,
        })

        self.code_promotion_program = self.env['sale.coupon.program'].create({
            'name': 'Buy 1 A + Enter code, 1 A is free',
            'promo_code_usage': 'code_needed',
            'reward_type': 'product',
            'reward_product_id': self.product_A.id,
            'rule_products_domain': "[('id', 'in', [%s])]" % (self.product_A.id),
            'active': True,
        })

        self.tax_10pc_incl = self.env['account.tax'].create({
            'name': "10% Tax incl",
            'amount_type': 'percent',
            'amount': 10,
            'price_include': True,
        })<commit_msg>[FIX] sale_coupon: fix test<commit_after># -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from openerp.tests import common


class TestSaleCouponCommon(common.TransactionCase):

    def setUp(self):
        super(TestSaleCouponCommon, self).setUp()

        # Set all the existing programs to active=False to avoid interference
        self.env['sale.coupon.program'].search([]).write({'active': False})

        # create partner for sale order.
        self.steve = self.env['res.partner'].create({
            'name': '<NAME>',
            'customer': True,
            'email': '<EMAIL>',
        })

        self.empty_order = self.env['sale.order'].create({
            'partner_id': self.steve.id
        })

        self.uom_unit = self.env.ref('product.product_uom_unit')

        # Taxes
        self.tax_15pc_excl = self.env['account.tax'].create({
            'name': "Tax 15%",
            'amount_type': 'percent',
            'amount': 15,
            'type_tax_use': 'sale',
        })

        self.tax_10pc_incl = self.env['account.tax'].create({
            'name': "10% Tax incl",
            'amount_type': 'percent',
            'amount': 10,
            'price_include': True,
        })

        #products
        self.product_A = self.env['product.product'].create({
            'name': 'Product A',
            'list_price': 100,
            'sale_ok': True,
            'taxes_id': [(6, 0, [self.tax_15pc_excl.id])],
        })

        self.product_B = self.env['product.product'].create({
            'name': 'Product B',
            'list_price': 5,
            'sale_ok': True,
            'taxes_id': [(6, 0, [self.tax_15pc_excl.id])],
        })

        # Immediate Program By A + B: get B free
        # No Conditions
        self.immediate_promotion_program = self.env['sale.coupon.program'].create({
            'name': 'Buy A + 1 B, 1 B are free',
            'promo_code_usage': 'no_code_needed',
            'reward_type': 'product',
            'reward_product_id': self.product_B.id,
            'rule_products_domain': "[('id', 'in', [%s])]" % (self.product_A.id),
            'active': True,
        })

        self.code_promotion_program = self.env['sale.coupon.program'].create({
            'name': 'Buy 1 A + Enter code, 1 A is free',
            'promo_code_usage': 'code_needed',
            'reward_type': 'product',
            'reward_product_id': self.product_A.id,
            'rule_products_domain': "[('id', 'in', [%s])]" % (self.product_A.id),
            'active': True,
        })
{'fraction_non_alphanumeric': 0.15537600994406464, 'fraction_numerical': 0.009115392583385125, 'mean_word_length': 2.0062266500622665, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '714964', 'n_tokens_mistral': 1562, 'n_tokens_neox': 1474, 'n_words': 315}