Example #1
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})

        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'].run('pos_basic_order', 'test')",
                        "odoo.__DEBUG__.services['web.Tour'].tours.pos_basic_order",
                        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))
Example #2
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)]})
Example #3
0
    def process_search_log(self, cr, uid, context=None):
        env = Environment(cr, uid, context=context or {})
        logs = env['website.search.log'].search([])
        if not logs:
            return

        template = env.ref('website_sale_search_log.search_log_email')
        template = template.with_context(lang=env['res.users'].browse(uid).lang, logs=[l.log for l in logs])
        template.send_mail(logs[0].id, force_send=True, raise_exception=True)

        logs.unlink()