Exemplo n.º 1
0
    def test_01_pos_is_loaded_and_print_order_to_kitchen(self):
        # see more https://odoo-development.readthedocs.io/en/latest/dev/tests/js.html#phantom-js-python-tests
        env = Environment(self.registry.test_cr, self.uid, {})

        kitchen_printer = env.ref('pos_restaurant.kitchen_printer')
        receipt_template = env.ref('pos_order_receipt_custom.simple_kitchen_receipt')

        kitchen_printer.write({
            'custom_order_receipt': True,
            'custom_order_receipt_id': [(6, 0, [receipt_template.id])],
        })

        main_pos_config = env.ref('point_of_sale.pos_config_main')
        main_pos_config.open_session_cb()

        self.phantom_js(
            '/pos/web',

            "odoo.__DEBUG__.services['web_tour.tour']"
            ".run('pos_order_receipt_custom_tour')",

            "odoo.__DEBUG__.services['web_tour.tour']"
            ".tours.pos_order_receipt_custom_tour.ready",

            login="******",
            timeout=240,
        )
Exemplo n.º 2
0
def uninstall_hook_update_rule(cr, registry):
    env = Environment(cr, SUPERUSER_ID, {})
    for rule_xml_id, group_xml_id in multi_company_ir_rules.items():
        rule = env.ref(rule_xml_id)
        group = env.ref(group_xml_id)
        if group in rule.groups:
            rule.write({'groups': [(3, group.id)]})
Exemplo n.º 3
0
    def test_01_pos_is_loaded(self):
        # see more https://odoo-development.readthedocs.io/en/latest/dev/tests/js.html#phantom-js-python-tests
        env = Environment(self.registry.test_cr, self.uid, {})

        main_pos_config = env.ref("point_of_sale.pos_config_main")

        main_pos_config.write({"iface_discount": True})
        main_pos_config.discount_product_id = env.ref(
            "point_of_sale.boni_orange")

        main_pos_config.open_session_cb()

        env["ir.module.module"].search(
            [("name", "=", "pos_product_category_discount")],
            limit=1).state = "installed"

        self.phantom_js(
            "/pos/web",
            "odoo.__DEBUG__.services['web_tour.tour']"
            ".run('pos_product_category_discount_tour')",
            "odoo.__DEBUG__.services['web_tour.tour']"
            ".tours.pos_product_category_discount_tour.ready",
            login="******",
            timeout=240,
        )
    def create_invoice(self, partner):
        env = Environment(self.env.cr, SUPERUSER_ID, {})
        currency = env['res.currency'].search([('name', '=', 'EUR')])
        product = env['product.product'].create({
            'name': 'Product',
        })
        account_1 = env['account.account'].create({
            'code':
            random.randint(100, 999),
            'name':
            'Payable Account',
            'reconcile':
            True,
            'user_type_id':
            env.ref('account.data_account_type_payable').id,
        })
        account_2 = env['account.account'].create({
            'code':
            random.randint(100, 999),
            'name':
            'Expenses Account',
            'user_type_id':
            env.ref('account.data_account_type_expenses').id,
        })
        partner.write({
            'property_account_payable_id': account_2.id,
        })
        journal = env['account.journal'].create({
            'name':
            'Journal',
            'type':
            'bank',
            'code':
            str(random.randint(100, 999)),
        })
        account_invoice_line = env['account.invoice.line'].create({
            'name':
            'My line 1',
            'product_id':
            product.id,
            'account_id':
            account_2.id,
            'price_unit':
            '20',
        })
        account_invoice = env['account.invoice'].create({
            'partner_id':
            partner.id,
            'account_id':
            account_1.id,
            'journal_id':
            journal.id,
            'currency_id':
            currency.id,
            'invoice_line_ids': [(4, account_invoice_line.id)],
            'type':
            'in_invoice',
        })

        return account_invoice
Exemplo n.º 5
0
def remove_menus(cr):
    env = Environment(cr, SUPERUSER_ID, {})
    for menu_id in ('base.module_mi', 'base.menu_module_updates'):
        try:
            env.ref(menu_id).unlink()
        except ValueError:
            pass
Exemplo n.º 6
0
    def test_01_pos_basic_order(self):
        cr = self.registry.cursor()
        assert cr == self.registry.test_cr
        env = Environment(cr, self.uid, {})

        journal_obj = env['account.journal']
        account_obj = env['account.account']
        main_company = env.ref('base.main_company')
        main_pos_config = env.ref('point_of_sale.pos_config_main')

        account_receivable = account_obj.create({'code': 'X1012',
                                                 'name': 'Account Receivable - Test',
                                                 'user_type_id': env.ref('account.data_account_type_receivable').id,
                                                 'reconcile': True})
        field = self.env['ir.model.fields'].search([('name', '=', 'property_account_receivable_id'),
                                                    ('model', '=', 'res.partner'),
                                                    ('relation', '=', 'account.account')], limit=1)
        env['ir.property'].create({'name': 'property_account_receivable_id',
                                   'company_id': main_company.id,
                                   'fields_id': field.id,
                                   'value': 'account.account,' + str(account_receivable.id)})

        # set the company currency to USD, otherwise it will assume
        # euro's. this will cause issues as the sale journal is in
        # USD, because of this all products would have a different
        # price
        main_company.currency_id = env.ref('base.USD')

        test_sale_journal = journal_obj.create({'name': 'Sale Journal - Test',
                                                'code': 'TSJ',
                                                'type': 'sale',
                                                'company_id': main_company.id})

        env['product.pricelist'].search([]).write(dict(currency_id=main_company.currency_id.id))

        main_pos_config.journal_id = test_sale_journal
        main_pos_config.write({'journal_ids': [(0, 0, {'name': 'Cash Journal - Test',
                                                       'code': 'TSC',
                                                       'type': 'cash',
                                                       'company_id': main_company.id,
                                                       'journal_user': True})]})

        # open a session, the /pos/web controller will redirect to it
        main_pos_config.open_session_cb()

        # needed because tests are run before the module is marked as
        # installed. In js web will only load qweb coming from modules
        # that are returned by the backend in module_boot. Without
        # this you end up with js, css but no qweb.
        env['ir.module.module'].search([('name', '=', 'point_of_sale')], limit=1).state = 'installed'
        cr.release()

        self.phantom_js("/pos/web",
                        "odoo.__DEBUG__.services['web_tour.tour'].run('pos_basic_order')",
                        "odoo.__DEBUG__.services['web_tour.tour'].tours.pos_basic_order.ready",
                        login="******")

        for order in env['pos.order'].search([]):
            self.assertEqual(order.state, 'paid', "Validated order has payment of " + str(order.amount_paid) + " and total of " + str(order.amount_total))
Exemplo n.º 7
0
def post_init_update_rule(cr, registry):
    env = Environment(cr, SUPERUSER_ID, {})
    for rule_xml_id, group_xml_id in multi_company_ir_rules.items():
        rule = env.ref(rule_xml_id)
        group = env.ref(group_xml_id)
        if rule and group:
            if group not in rule.groups:
                rule.write({'groups': [(4, group.id)]})
Exemplo n.º 8
0
def uninstall_hook_update_rule(cursor, registry):
    """
    Method to execute at module uninstallation time.
    """
    env = Environment(cursor, SUPERUSER_ID, {})
    for rule_xml_id, group_xml_id in MULTI_COMPANY_RULES.items():
        rule = env.ref(rule_xml_id)
        group = env.ref(group_xml_id)
        if group in rule.groups:
            rule.write({'groups':[(3, group.id)]})
Exemplo n.º 9
0
def post_install_hook(cr, registry):
    env = Environment(cr, SUPERUSER_ID, {})
    ks_user_data = {"users": [(4, user_id.id) for user_id in (env['res.users'].search([]))]}
    ks_list_view_manager_edit_and_read = env.ref('ks_list_view_manager.ks_list_view_manager_edit_and_read')
    ks_list_view_manager_edit_and_read.write(ks_user_data)

    ks_list_view_manager_dynamic_list = env.ref('ks_list_view_manager.ks_list_view_manager_dynamic_list')
    ks_list_view_manager_dynamic_list.write(ks_user_data)

    ks_list_view_manager_advance_search = env.ref('ks_list_view_manager.ks_list_view_manager_advance_Search')
    ks_list_view_manager_advance_search.write(ks_user_data)
Exemplo n.º 10
0
def set_user_group_for_double_validation(cr, registry):
    """
    En v9 incorporamos un nuevo grupo para pdoer confirmar pagos, lo marcamos
    por defecto para todos los que vienen de v8 porque si tenían double
    validation no pueden hacer pagos
    """
    env = Environment(cr, 1, {})
    invoice_group = env.ref('account.group_account_invoice')
    confirm_group = env.ref('account_payment_group.account_confirm_payment')
    users = env['res.users'].search([('groups_id', '=', invoice_group.id)])
    users.write({'groups_id': [(4, confirm_group.id, None)]})
Exemplo n.º 11
0
def post_init_update_rule(cursor, registry):
    """
    Method to execute right after module installation.
    """
    env = Environment(cursor, SUPERUSER_ID, {})
    for rule_xml_id, group_xml_id in MULTI_COMPANY_RULES.items():
        rule = env.ref(rule_xml_id)
        group = env.ref(group_xml_id)
        if rule and group:
            if group not in rule.groups:
                rule.write({'groups':[(4, group.id)]})
        # Makes company_id False in partners of companies.
        # Added by Maulik Barad on Date 09-Oct-2019.
        companies = env['res.company'].search([])
        companies.mapped('partner_id').write({'company_id':False})
Exemplo n.º 12
0
def pre_init_hook(cr):
    logger.info("Adding timesheet managers as validators in all timesheets")
    env = Environment(cr, SUPERUSER_ID, {})
    ts_mang_group_id = env.ref('hr_timesheet.group_timesheet_manager').id
    managers = env['res.users'].search([('groups_id', '=', ts_mang_group_id)])
    timesheets = env['hr_timesheet.sheet'].search([])
    timesheets.write({'validator_user_ids': [(4, us.id) for us in managers]})
Exemplo n.º 13
0
    def test_01_pos_is_loaded(self):
        # see more https://odoo-development.readthedocs.io/en/latest/dev/tests/js.html#phantom-js-python-tests
        cr = self.registry.cursor()
        assert cr == self.registry.test_cr
        env = Environment(cr, self.uid, {})

        # get exist pos_config
        main_pos_config = env.ref("point_of_sale.pos_config_main")
        # create new session and open it
        main_pos_config.open_session_cb()

        # From https://github.com/odoo/odoo/blob/11.0/addons/point_of_sale/tests/test_frontend.py#L292-L297
        #
        # needed because tests are run before the module is marked as
        # installed. In js web will only load qweb coming from modules
        # that are returned by the backend in module_boot. Without
        # this you end up with js, css but no qweb.
        env["ir.module.module"].search(
            [("name", "=", "pos_mobile_restaurant")],
            limit=1).state = "installed"
        self.registry.test_cr.release()

        self.phantom_js(
            "/pos/web?m=1",
            "odoo.__DEBUG__.services['web_tour.tour']"
            ".run('pos_mobile_tour')",
            "odoo.__DEBUG__.services['web_tour.tour']"
            ".tours.pos_mobile_tour.ready",
            login="******",
            timeout=240,
        )
Exemplo n.º 14
0
    def test_01_pos_is_loaded(self):
        # see more https://odoo-development.readthedocs.io/en/latest/dev/tests/js.html#phantom-js-python-tests
        env = Environment(self.registry.test_cr, self.uid, {})

        pos_receipt = env['pos.custom_receipt'].search(
            [('type', '=', 'receipt')], limit=1)
        self.assertTrue(pos_receipt, 'Receipt Not Found')

        pos_ticket = env['pos.custom_receipt'].search(
            [('type', '=', 'ticket')], limit=1)
        self.assertTrue(pos_ticket, 'Ticket Not Found')

        main_pos_config = env.ref('point_of_sale.pos_config_main')

        main_pos_config.write({
            'proxy_ip': 'localhost',
            'iface_print_via_proxy': True,
            'custom_xml_receipt': True,
            'custom_xml_receipt_id': pos_receipt.id,
            'iface_print_auto': False,
            'custom_ticket': True,
            'custom_ticket_id': pos_ticket.id
        })

        main_pos_config.open_session_cb()

        self.phantom_js(
            '/pos/web',
            "odoo.__DEBUG__.services['web_tour.tour']"
            ".run('pos_receipt_custom_template_tour')",
            "odoo.__DEBUG__.services['web_tour.tour']"
            ".tours.pos_receipt_custom_template_tour.ready",
            login="******",
            timeout=240,
        )
Exemplo n.º 15
0
def _synchronize_cron(cr, registry):
    env = Environment(cr, SUPERUSER_ID, {'active_test': False})
    cron = env.ref('crm_iap_lead_enrich.ir_cron_lead_enrichment')
    if cron:
        config = env['ir.config_parameter'].get_param(
            'crm.iap.lead.enrich.setting', 'manual')
        cron.active = config != 'manual'
Exemplo n.º 16
0
    def test_01_pos_is_loaded(self):
        # see more https://odoo-development.readthedocs.io/en/latest/dev/tests/js.html#phantom-js-python-tests
        env = Environment(self.registry.test_cr, self.uid, {})

        pos_receipt = env["pos.custom_receipt"].search(
            [("type", "=", "receipt")], limit=1)
        self.assertTrue(pos_receipt, "Receipt Not Found")

        pos_ticket = env["pos.custom_receipt"].search(
            [("type", "=", "ticket")], limit=1)
        self.assertTrue(pos_ticket, "Ticket Not Found")

        main_pos_config = env.ref("point_of_sale.pos_config_main")

        main_pos_config.write({
            "proxy_ip": "localhost",
            "iface_print_via_proxy": True,
            "custom_xml_receipt": True,
            "custom_xml_receipt_id": pos_receipt.id,
            "iface_print_auto": False,
            "custom_ticket": True,
            "custom_ticket_id": pos_ticket.id,
        })

        main_pos_config.open_session_cb()

        self.phantom_js(
            "/pos/web",
            "odoo.__DEBUG__.services['web_tour.tour']"
            ".run('pos_receipt_custom_template_tour')",
            "odoo.__DEBUG__.services['web_tour.tour']"
            ".tours.pos_receipt_custom_template_tour.ready",
            login="******",
            timeout=240,
        )
Exemplo n.º 17
0
def uninstall_hook(cr, registry):
    env = Environment(cr, SUPERUSER_ID, {})

    groups = env['res.groups'].search([
        ('category_id', '=', env.ref('pcp_security.module_category_pcp').id)
    ])
    groups.unlink()
Exemplo n.º 18
0
def post_init_hook(cr, registry):
    env = Environment(cr, SUPERUSER_ID, {})
    menus = env['ir.ui.menu'].search([('parent_id', '=', False),
                                      ('name', 'not in', ['Settings',
                                                          'Apps'])])
    for menu in menus:
        group = env['res.groups'].create({
            'name':
            'Can see {}'.format(menu.name),
            'category_id':
            env.ref('pcp_security.module_category_pcp').id
        })
        if group:
            menu.write({'groups_id': [(6, 0, group.ids)]})
            erp_group = env.ref('base.group_erp_manager')
            if erp_group:
                erp_group.write({'implied_ids': [(4, group.id)]})
Exemplo n.º 19
0
def _upadate_email_templates(cr, registry):
    env = Environment(cr, SUPERUSER_ID, {})
    model_id = env['ir.model'].search([('name', '=', 'sale.order')])
    id = env.ref('sale.email_template_edi_sale').id
    mail = env['mail.template'].search([('model_id', '=', model_id.id),
                                        ('id', '=', id)])
    if mail:
        mail.write({'partner_to': '${object.partner_contact_id.id}'})
Exemplo n.º 20
0
def migrate(cr, version):
    env = Environment(cr, SUPERUSER_ID, {})
    interval_price_id = env.ref(
        "rental_pricelist_interval.pricelist_interval").id
    env["product.product"].search([]).write({
        "def_interval_pricelist_id":
        interval_price_id,
    })
Exemplo n.º 21
0
def _synchronize_cron(cr, registry):
    env = Environment(cr, SUPERUSER_ID, {'active_test': False})
    send_invoice_cron = env.ref('sale.send_invoice_cron',
                                raise_if_not_found=False)
    if send_invoice_cron:
        config = env['ir.config_parameter'].get_param('sale.automatic_invoice',
                                                      False)
        send_invoice_cron.active = bool(config)
Exemplo n.º 22
0
def set_product_def_interval_pricelist_id(cr, registry):
    env = Environment(cr, SUPERUSER_ID, {})
    interval_price_id = env.ref(
        "rental_pricelist_interval.pricelist_interval").id
    env["product.product"].search([]).write({
        "def_interval_pricelist_id":
        interval_price_id,
    })
Exemplo n.º 23
0
def post_init_hook(cr, pool):
    """
    We need to activate the rule only if we are not in a test environment.
    """
    if not config["test_enable"]:
        env = Environment(cr, SUPERUSER_ID, {})
        tier_partner = env.ref(
            "partner_tier_validation.partner_tier_definition_company_only")
        tier_partner.write({"active": True})
Exemplo n.º 24
0
def post_install_hook(cr, registry):
    env = Environment(cr, SUPERUSER_ID, {})
    users = {
        "users": [(4, user_id.id) for user_id in (env['res.users'].search([]))
                  if not user_id.has_group('base.group_system')]
    }
    chatter_hide_future_activity = env.ref(
        'chatter.hide_future_activity_group')
    chatter_hide_future_activity.write(users)
Exemplo n.º 25
0
def post_init_hook(cr, registry):
    env = Environment(cr, SUPERUSER_ID, {})
    module_obj = env['ir.module.module']
    product_obj = env['product.template']
    module = module_obj.search([('name', '=', 'shopinvader_algolia')])
    if module.demo:
        product = env.ref('product.product_product_4_product_template')
        description = product.description
        vals = {'description': description}
        products = product_obj.search([])
        products.write(vals)
Exemplo n.º 26
0
def post_install_hook(cr, registry):
    """
    This will provide access of the module to the existing users at the time of installation.
    """

    env = Environment(cr, SUPERUSER_ID, {})
    ks_user_data = {
        "users": [(4, user_id.id) for user_id in (env['res.users'].search([]))]
    }
    ks_woo_access = env.ref('ks_woocommerce.ks_woocommerce_group')
    ks_woo_access.write(ks_user_data)
Exemplo n.º 27
0
def post_init_hook(cr, registry):
    env = Environment(cr, SUPERUSER_ID, {})
    module_obj = env["ir.module.module"]
    product_obj = env["product.template"]
    module = module_obj.search([("name", "=", "shopinvader_algolia")])
    if module.demo:
        product = env.ref("product.product_product_4_product_template")
        description = product.description
        vals = {"description": description}
        products = product_obj.search([])
        products.write(vals)
Exemplo n.º 28
0
 def test_01_pos_is_loaded(self):
     # see more https://odoo-development.readthedocs.io/en/latest/dev/tests/js.html#phantom-js-python-tests
     env = Environment(self.registry.test_cr, self.uid, {})
     product = env.ref("point_of_sale.boni_orange")
     product.write({
         "pos_category_ids":
         [(4, category.id) for category in env["pos.category"].search([])]
     })
     # get exist pos_config
     main_pos_config = env.ref("point_of_sale.pos_config_main")
     # create new session and open it
     main_pos_config.open_session_cb()
     self.phantom_js(
         "/pos/web",
         "odoo.__DEBUG__.services['web_tour.tour']"
         ".run('pos_category_multi_tour')",
         "odoo.__DEBUG__.services['web_tour.tour']"
         ".tours.pos_category_multi_tour.ready",
         login="******",
         timeout=240,
     )
Exemplo n.º 29
0
def post_init_hook(cr, pool):
    """
    Desabilitar regra
    """
    env = Environment(cr, SUPERUSER_ID, {})
    rule = env.ref('base.res_partner_rule_private_employee')
    if rule:
        rule.write({
            'active': False,
        })

    env['res.company'].browse(1).name = 'ABGF'
Exemplo n.º 30
0
def set_default_lang(cr):
    env = Environment(cr, SUPERUSER_ID, {})
    if env['res.lang'].search([('code', '=', 'fr_FR')], limit=1):
        partner_lang_field_id = env.ref('base.field_res_partner__lang').id
        value = env['ir.default'].search(
            [('field_id', '=', partner_lang_field_id)], limit=1)
        vals = {
            'field_id': partner_lang_field_id,
            'json_value': '"fr_FR"',
        }
        if value:
            value.write(vals)
        else:
            value.create(vals)
Exemplo n.º 31
0
    def test_01_pos_is_loaded(self):
        # see more https://odoo-development.readthedocs.io/en/latest/dev/tests/js.html#phantom-js-python-tests
        env = Environment(self.registry.test_cr, self.uid, {})

        # get exist pos_config
        main_pos_config = env.ref("point_of_sale.pos_config_main")
        # create new session and open it
        main_pos_config.open_session_cb()

        self.phantom_js(
            "/pos/web?m=1",
            "odoo.__DEBUG__.services['web_tour.tour']" ".run('pos_mobile_tour')",
            "odoo.__DEBUG__.services['web_tour.tour']" ".tours.pos_mobile_tour.ready",
            login="******",
            timeout=240,
        )
Exemplo n.º 32
0
    def test_01_pos_basic_order(self):
        cr = self.registry.cursor()
        assert cr == self.registry.test_cr
        env = Environment(cr, self.uid, {})

        # By default parent_store computation is deferred until end of
        # tests. Pricelist items however are sorted based on these
        # fields, so they need to be computed.
        env['product.category']._parent_store_compute()

        journal_obj = env['account.journal']
        account_obj = env['account.account']
        main_company = env.ref('base.main_company')
        main_pos_config = env.ref('point_of_sale.pos_config_main')

        account_receivable = account_obj.create({'code': 'X1012',
                                                 'name': 'Account Receivable - Test',
                                                 'user_type_id': env.ref('account.data_account_type_receivable').id,
                                                 'reconcile': True})
        field = self.env['ir.model.fields'].search([('name', '=', 'property_account_receivable_id'),
                                                    ('model', '=', 'res.partner'),
                                                    ('relation', '=', 'account.account')], limit=1)
        env['ir.property'].create({'name': 'property_account_receivable_id',
                                   'company_id': main_company.id,
                                   'fields_id': field.id,
                                   'value': 'account.account,' + str(account_receivable.id)})

        fixed_pricelist = env['product.pricelist'].create({
            'name': 'Fixed',
            'item_ids': [(0, 0, {
                'compute_price': 'fixed',
                'fixed_price': 1,
            }), (0, 0, {
                'compute_price': 'fixed',
                'fixed_price': 2,
                'applied_on': '0_product_variant',
                'product_id': env.ref('point_of_sale.boni_orange').id,
            }), (0, 0, {
                'compute_price': 'fixed',
                'fixed_price': 13.95,  # test for issues like in 7f260ab517ebde634fc274e928eb062463f0d88f
                'applied_on': '0_product_variant',
                'product_id': env.ref('point_of_sale.papillon_orange').id,
            })],
        })

        env['product.pricelist'].create({
            'name': 'Percentage',
            'item_ids': [(0, 0, {
                'compute_price': 'percentage',
                'percent_price': 100,
                'applied_on': '0_product_variant',
                'product_id': env.ref('point_of_sale.boni_orange').id,
            }), (0, 0, {
                'compute_price': 'percentage',
                'percent_price': 99,
                'applied_on': '0_product_variant',
                'product_id': env.ref('point_of_sale.papillon_orange').id,
            }), (0, 0, {
                'compute_price': 'percentage',
                'percent_price': 0,
                'applied_on': '0_product_variant',
                'product_id': env.ref('point_of_sale.citron').id,
            })],
        })

        env['product.pricelist'].create({
            'name': 'Formula',
            'item_ids': [(0, 0, {
                'compute_price': 'formula',
                'price_discount': 6,
                'price_surcharge': 5,
                'applied_on': '0_product_variant',
                'product_id': env.ref('point_of_sale.boni_orange').id,
            }), (0, 0, {
                # .99 prices
                'compute_price': 'formula',
                'price_surcharge': -0.01,
                'price_round': 1,
                'applied_on': '0_product_variant',
                'product_id': env.ref('point_of_sale.papillon_orange').id,
            }), (0, 0, {
                'compute_price': 'formula',
                'price_min_margin': 10,
                'price_max_margin': 100,
                'applied_on': '0_product_variant',
                'product_id': env.ref('point_of_sale.citron').id,
            }), (0, 0, {
                'compute_price': 'formula',
                'price_surcharge': 10,
                'price_max_margin': 5,
                'applied_on': '0_product_variant',
                'product_id': env.ref('point_of_sale.limon').id,
            }), (0, 0, {
                'compute_price': 'formula',
                'price_discount': -100,
                'price_min_margin': 5,
                'price_max_margin': 20,
                'applied_on': '0_product_variant',
                'product_id': env.ref('point_of_sale.pamplemousse_rouge_pamplemousse').id,
            })],
        })

        env['product.pricelist'].create({
            'name': 'min_quantity ordering',
            'item_ids': [(0, 0, {
                'compute_price': 'fixed',
                'fixed_price': 1,
                'applied_on': '0_product_variant',
                'min_quantity': 2,
                'product_id': env.ref('point_of_sale.boni_orange').id,
            }), (0, 0, {
                'compute_price': 'fixed',
                'fixed_price': 2,
                'applied_on': '0_product_variant',
                'min_quantity': 1,
                'product_id': env.ref('point_of_sale.boni_orange').id,
            }), (0, 0, {
                'compute_price': 'fixed',
                'fixed_price': 2,
                'applied_on': '0_product_variant',
                'min_quantity': 2,
                'product_id': env.ref('point_of_sale.product_product_consumable').id,
            })],
        })

        env['product.pricelist'].create({
            'name': 'Product template',
            'item_ids': [(0, 0, {
                'compute_price': 'fixed',
                'fixed_price': 1,
                'applied_on': '1_product',
                'product_tmpl_id': env.ref('point_of_sale.boni_orange_product_template').id,
            }), (0, 0, {
                'compute_price': 'fixed',
                'fixed_price': 2,
            })],
        })

        env['product.pricelist'].create({
            # no category has precedence over category
            'name': 'Category vs no category',
            'item_ids': [(0, 0, {
                'compute_price': 'fixed',
                'fixed_price': 1,
                'applied_on': '2_product_category',
                'categ_id': env.ref('product.product_category_3').id,  # All / Saleable / Services
            }), (0, 0, {
                'compute_price': 'fixed',
                'fixed_price': 2,
            })],
        })

        p = env['product.pricelist'].create({
            'name': 'Category',
            'item_ids': [(0, 0, {
                'compute_price': 'fixed',
                'fixed_price': 2,
                'applied_on': '2_product_category',
                'categ_id': env.ref('product.product_category_all').id,
            }), (0, 0, {
                'compute_price': 'fixed',
                'fixed_price': 1,
                'applied_on': '2_product_category',
                'categ_id': env.ref('product.product_category_3').id,  # All / Saleable / Services
            })],
        })

        today = date.today()
        one_week_ago = today - timedelta(weeks=1)
        two_weeks_ago = today - timedelta(weeks=2)
        one_week_from_now = today + timedelta(weeks=1)
        two_weeks_from_now = today + timedelta(weeks=2)

        env['product.pricelist'].create({
            'name': 'Dates',
            'item_ids': [(0, 0, {
                'compute_price': 'fixed',
                'fixed_price': 1,
                'date_start': two_weeks_ago.strftime(DEFAULT_SERVER_DATE_FORMAT),
                'date_end': one_week_ago.strftime(DEFAULT_SERVER_DATE_FORMAT),
            }), (0, 0, {
                'compute_price': 'fixed',
                'fixed_price': 2,
                'date_start': today.strftime(DEFAULT_SERVER_DATE_FORMAT),
                'date_end': one_week_from_now.strftime(DEFAULT_SERVER_DATE_FORMAT),
            }), (0, 0, {
                'compute_price': 'fixed',
                'fixed_price': 3,
                'date_start': one_week_from_now.strftime(DEFAULT_SERVER_DATE_FORMAT),
                'date_end': two_weeks_from_now.strftime(DEFAULT_SERVER_DATE_FORMAT),
            })],
        })

        cost_base_pricelist = env['product.pricelist'].create({
            'name': 'Cost base',
            'item_ids': [(0, 0, {
                'base': 'standard_price',
                'compute_price': 'percentage',
                'percent_price': 55,
            })],
        })

        pricelist_base_pricelist = env['product.pricelist'].create({
            'name': 'Pricelist base',
            'item_ids': [(0, 0, {
                'base': 'pricelist',
                'base_pricelist_id': cost_base_pricelist.id,
                'compute_price': 'percentage',
                'percent_price': 15,
            })],
        })

        env['product.pricelist'].create({
            'name': 'Pricelist base 2',
            'item_ids': [(0, 0, {
                'base': 'pricelist',
                'base_pricelist_id': pricelist_base_pricelist.id,
                'compute_price': 'percentage',
                'percent_price': 3,
            })],
        })

        env['product.pricelist'].create({
            'name': 'Pricelist base rounding',
            'item_ids': [(0, 0, {
                'base': 'pricelist',
                'base_pricelist_id': fixed_pricelist.id,
                'compute_price': 'percentage',
                'percent_price': 0.01,
            })],
        })

        excluded_pricelist = env['product.pricelist'].create({
            'name': 'Not loaded'
        })
        env.ref('base.res_partner_18').property_product_pricelist = excluded_pricelist

        # set the company currency to USD, otherwise it will assume
        # euro's. this will cause issues as the sales journal is in
        # USD, because of this all products would have a different
        # price
        main_company.currency_id = env.ref('base.USD')

        test_sale_journal = journal_obj.create({'name': 'Sales Journal - Test',
                                                'code': 'TSJ',
                                                'type': 'sale',
                                                'company_id': main_company.id})

        all_pricelists = env['product.pricelist'].search([('id', '!=', excluded_pricelist.id)])
        all_pricelists.write(dict(currency_id=main_company.currency_id.id))

        main_pos_config.write({
            'journal_id': test_sale_journal.id,
            'invoice_journal_id': test_sale_journal.id,
            'journal_ids': [(0, 0, {'name': 'Cash Journal - Test',
                                                       'code': 'TSC',
                                                       'type': 'cash',
                                                       'company_id': main_company.id,
                                                       'journal_user': True})],
            'available_pricelist_ids': [(4, pricelist.id) for pricelist in all_pricelists],
        })

        # open a session, the /pos/web controller will redirect to it
        main_pos_config.open_session_cb()

        # needed because tests are run before the module is marked as
        # installed. In js web will only load qweb coming from modules
        # that are returned by the backend in module_boot. Without
        # this you end up with js, css but no qweb.
        env['ir.module.module'].search([('name', '=', 'point_of_sale')], limit=1).state = 'installed'
        cr.release()

        self.phantom_js("/pos/web",
                        "odoo.__DEBUG__.services['web_tour.tour'].run('pos_pricelist')",
                        "odoo.__DEBUG__.services['web_tour.tour'].tours.pos_pricelist.ready",
                        login="******")

        self.phantom_js("/pos/web",
                        "odoo.__DEBUG__.services['web_tour.tour'].run('pos_basic_order')",
                        "odoo.__DEBUG__.services['web_tour.tour'].tours.pos_basic_order.ready",
                        login="******")

        for order in env['pos.order'].search([]):
            self.assertEqual(order.state, 'paid', "Validated order has payment of " + str(order.amount_paid) + " and total of " + str(order.amount_total))