Beispiel #1
0
 def test_10_leave_summary_reports(self):
     # Print the HR Holidays(Summary Employee) Report through the wizard
     ctx = {
         'model':
         'hr.employee',
         'active_ids': [
             self.ref('hr.employee_admin'),
             self.ref('hr.employee_qdp'),
             self.ref('hr.employee_al')
         ]
     }
     data_dict = {
         'date_from':
         datetime.today().strftime('%Y-%m-01'),
         'emp': [(6, 0, [
             self.ref('hr.employee_admin'),
             self.ref('hr.employee_qdp'),
             self.ref('hr.employee_al')
         ])],
         'holiday_type':
         'Approved'
     }
     self.env.company.external_report_layout_id = self.env.ref(
         'web.external_layout_standard').id
     test_reports.try_report_action(self.env.cr,
                                    self.env.uid,
                                    'action_hr_holidays_summary_employee',
                                    wiz_data=data_dict,
                                    context=ctx,
                                    our_module='hr_holidays')
    def test_10_leave_summary_reports(self):
        # Print the HR Holidays(Summary Department) Report through the wizard
        ctx = {
            'model':
            'hr.department',
            'active_ids': [
                self.ref('hr.employee_admin'),
                self.ref('hr.employee_qdp'),
                self.ref('hr.employee_al')
            ]
        }
        data_dict = {
            'date_from': datetime.today().strftime('%Y-%m-01'),
            'depts': [(6, 0, [self.ref('hr.dep_sales')])],
            'holiday_type': 'Approved'
        }
        test_reports.try_report_action(self.env.cr,
                                       self.env.uid,
                                       'action_hr_holidays_summary_dept',
                                       wiz_data=data_dict,
                                       context=ctx,
                                       our_module='hr_holidays')

        # Print the HR Holidays(Summary Employee) Report through the wizard
        ctx = {
            'model':
            'hr.employee',
            'active_ids': [
                self.ref('hr.employee_admin'),
                self.ref('hr.employee_qdp'),
                self.ref('hr.employee_al')
            ]
        }
        data_dict = {
            'date_from':
            datetime.today().strftime('%Y-%m-01'),
            'emp': [(6, 0, [
                self.ref('hr.employee_admin'),
                self.ref('hr.employee_qdp'),
                self.ref('hr.employee_al')
            ])],
            'holiday_type':
            'Approved'
        }
        test_reports.try_report_action(self.env.cr,
                                       self.env.uid,
                                       'action_hr_holidays_summary_employee',
                                       wiz_data=data_dict,
                                       context=ctx,
                                       our_module='hr_holidays')
Beispiel #3
0
    def test_10_calculation_price_of_products_pricelist(self):
        """Test calculation of product price based on pricelist"""
        # I check sale price of Customizable Desk
        context = {}
        context.update({
            'pricelist': self.customer_pricelist.id,
            'quantity': 1
        })
        ipad_retina_display = self.ipad_retina_display.with_context(context)
        msg = "Wrong sale price: Customizable Desk. should be %s instead of %s" % (
            ipad_retina_display.price,
            (ipad_retina_display.lst_price - ipad_retina_display.lst_price *
             (0.10)))
        self.assertEqual(
            float_compare(ipad_retina_display.price,
                          (ipad_retina_display.lst_price -
                           ipad_retina_display.lst_price * (0.10)),
                          precision_digits=2), 0, msg)

        # I check sale price of Laptop.
        laptop_E5023 = self.laptop_E5023.with_context(context)
        msg = "Wrong sale price: Laptop. should be %s instead of %s" % (
            laptop_E5023.price, (laptop_E5023.lst_price + 1))
        self.assertEqual(
            float_compare(laptop_E5023.price,
                          laptop_E5023.lst_price + 1,
                          precision_digits=2), 0, msg)

        # I check sale price of IT component.
        apple_headphones = self.apple_in_ear_headphones.with_context(context)
        msg = "Wrong sale price: IT component. should be %s instead of %s" % (
            apple_headphones.price, apple_headphones.lst_price)
        self.assertEqual(
            float_compare(apple_headphones.price,
                          apple_headphones.lst_price,
                          precision_digits=2), 0, msg)

        # I check sale price of IT component if more than 3 Unit.
        context.update({'quantity': 5})
        laptop_S3450 = self.laptop_S3450.with_context(context)
        msg = "Wrong sale price: IT component if more than 3 Unit. should be %s instead of %s" % (
            laptop_S3450.price,
            (laptop_S3450.lst_price - laptop_S3450.lst_price * (0.05)))
        self.assertEqual(
            float_compare(laptop_S3450.price,
                          laptop_S3450.lst_price - laptop_S3450.lst_price *
                          (0.05),
                          precision_digits=2), 0, msg)

        # I check sale price of LCD Monitor.
        context.update({'quantity': 1})
        ipad_mini = self.ipad_mini.with_context(context)
        msg = "Wrong sale price: LCD Monitor. should be %s instead of %s" % (
            ipad_mini.price, ipad_mini.lst_price)
        self.assertEqual(
            float_compare(ipad_mini.price,
                          ipad_mini.lst_price,
                          precision_digits=2), 0, msg)

        # I check sale price of LCD Monitor on end of year.
        context.update({'quantity': 1, 'date': '2011-12-31'})
        ipad_mini = self.ipad_mini.with_context(context)
        msg = "Wrong sale price: LCD Monitor on end of year. should be %s instead of %s" % (
            ipad_mini.price, ipad_mini.lst_price - ipad_mini.lst_price *
            (0.30))
        self.assertEqual(
            float_compare(ipad_mini.price,
                          ipad_mini.lst_price - ipad_mini.lst_price * (0.30),
                          precision_digits=2), 0, msg)

        # I check cost price of LCD Monitor.
        context.update({
            'quantity': 1,
            'date': False,
            'partner_id': self.res_partner_4.id
        })
        ipad_mini = self.ipad_mini.with_context(context)
        partner = self.res_partner_4.with_context(context)
        msg = "Wrong cost price: LCD Monitor. should be 790 instead of %s" % ipad_mini._select_seller(
            partner_id=partner, quantity=1.0).price
        self.assertEqual(
            float_compare(ipad_mini._select_seller(partner_id=partner,
                                                   quantity=1.0).price,
                          790,
                          precision_digits=2), 0, msg)

        # I check cost price of LCD Monitor if more than 3 Unit.
        context.update({'quantity': 3})
        ipad_mini = self.ipad_mini.with_context(context)
        partner = self.res_partner_4.with_context(context)
        msg = "Wrong cost price: LCD Monitor if more than 3 Unit.should be 785 instead of %s" % ipad_mini._select_seller(
            partner_id=partner, quantity=3.0).price
        self.assertEqual(
            float_compare(ipad_mini._select_seller(partner_id=partner,
                                                   quantity=3.0).price,
                          785,
                          precision_digits=2), 0, msg)

        # I print the sale prices report.
        ctx = {
            'active_model':
            'product.product',
            'date':
            '2011-12-30',
            'active_ids': [
                self.computer_SC234.id, self.ipad_retina_display.id,
                self.custom_computer_kit.id, self.ipad_mini.id
            ]
        }
        data_dict = {
            'qty1': 1,
            'qty2': 5,
            'qty3': 10,
            'qty4': 15,
            'qty5': 30,
            'price_list': self.customer_pricelist.id,
        }

        with self.assertRaises(UserError):
            test_reports.try_report_action(self.cr,
                                           self.uid,
                                           'action_product_price_list',
                                           wiz_data=data_dict,
                                           context=ctx,
                                           our_module='product')

        self.env.company.external_report_layout_id = self.env.ref(
            'web.external_layout_standard').id
        test_reports.try_report_action(self.cr,
                                       self.uid,
                                       'action_product_price_list',
                                       wiz_data=data_dict,
                                       context=ctx,
                                       our_module='product')
    def test_00_payslip_flow(self):
        """ Testing payslip flow and report printing """
        # I create an employee Payslip
        richard_payslip = self.env['hr.payslip'].create({
            'name':
            'Payslip of Richard',
            'employee_id':
            self.richard_emp.id
        })

        payslip_input = self.env['hr.payslip.input'].search([
            ('payslip_id', '=', richard_payslip.id)
        ])
        # I assign the amount to Input data
        payslip_input.write({'amount': 5.0})

        # I verify the payslip is in draft state
        self.assertEqual(richard_payslip.state, 'draft', 'State not changed!')

        context = {
            "lang": "en_US",
            "tz": False,
            "active_model": "ir.ui.menu",
            "department_id": False,
            "section_id": False,
            "active_ids": [self.ref("hr_payroll.menu_department_tree")],
            "active_id": self.ref("hr_payroll.menu_department_tree")
        }
        # I click on 'Compute Sheet' button on payslip
        richard_payslip.with_context(context).compute_sheet()

        # Then I click on the 'Confirm' button on payslip
        richard_payslip.action_payslip_done()

        # I verify that the payslip is in done state
        self.assertEqual(richard_payslip.state, 'done', 'State not changed!')

        # I want to check refund payslip so I click on refund button.
        richard_payslip.refund_sheet()

        # I check on new payslip Credit Note is checked or not.
        payslip_refund = self.env['hr.payslip'].search([
            ('name', 'like', 'Refund: ' + richard_payslip.name),
            ('credit_note', '=', True)
        ])
        self.assertTrue(bool(payslip_refund), "Payslip not refunded!")

        # I want to generate a payslip from Payslip run.
        payslip_run = self.env['hr.payslip.run'].create({
            'date_end':
            '2011-09-30',
            'date_start':
            '2011-09-01',
            'name':
            'Payslip for Employee'
        })

        # I create record for generating the payslip for this Payslip run.

        payslip_employee = self.env['hr.payslip.employees'].create(
            {'employee_ids': [(4, self.richard_emp.id)]})

        # I generate the payslip by clicking on Generat button wizard.
        payslip_employee.with_context(active_id=payslip_run.id).compute_sheet()

        # I open Contribution Register and from there I print the Payslip Lines report.
        self.env['payslip.lines.contribution.register'].create({
            'date_from':
            '2011-09-30',
            'date_to':
            '2011-09-01'
        })

        # I print the payslip report
        data, data_format = self.env.ref(
            'hr_payroll.action_report_payslip').render(richard_payslip.ids)

        # I print the payslip details report
        data, data_format = self.env.ref(
            'hr_payroll.payslip_details_report').render(richard_payslip.ids)

        # I print the contribution register report
        context = {
            'model': 'hr.contribution.register',
            'active_ids': [self.ref('hr_payroll.hr_houserent_register')]
        }
        test_reports.try_report_action(
            self.env.cr,
            self.env.uid,
            'action_payslip_lines_contribution_register',
            context=context,
            our_module='hr_payroll')