def test_in_refund_line_onchange_partner_1(self):
        move_form = Form(self.invoice)
        move_form.partner_id = self.partner_b
        move_form.invoice_payment_ref = 'turlututu'
        move_form.save()

        self.assertInvoiceValues(
            self.invoice, [
                {
                    **self.product_line_vals_1,
                    'partner_id': self.partner_b.id,
                },
                {
                    **self.product_line_vals_2,
                    'partner_id': self.partner_b.id,
                },
                {
                    **self.tax_line_vals_1,
                    'partner_id': self.partner_b.id,
                },
                {
                    **self.tax_line_vals_2,
                    'partner_id': self.partner_b.id,
                },
                {
                    **self.term_line_vals_1,
                    'name': 'turlututu',
                    'partner_id': self.partner_b.id,
                    'account_id':
                    self.partner_b.property_account_payable_id.id,
                    'price_unit': -338.4,
                    'price_subtotal': -338.4,
                    'price_total': -338.4,
                    'debit': 338.4,
                },
                {
                    **self.term_line_vals_1,
                    'name': 'turlututu',
                    'partner_id': self.partner_b.id,
                    'account_id':
                    self.partner_b.property_account_payable_id.id,
                    'price_unit': -789.6,
                    'price_subtotal': -789.6,
                    'price_total': -789.6,
                    'debit': 789.6,
                    'date_maturity': fields.Date.from_string('2019-02-28'),
                },
            ], {
                **self.move_vals,
                'partner_id': self.partner_b.id,
                'invoice_payment_ref': 'turlututu',
                'fiscal_position_id': self.fiscal_pos_a.id,
                'invoice_payment_term_id': self.pay_terms_b.id,
                'amount_untaxed': 960.0,
                'amount_tax': 168.0,
                'amount_total': 1128.0,
            })

        # Remove lines and recreate them to apply the fiscal position.
        move_form = Form(self.invoice)
        move_form.invoice_line_ids.remove(0)
        move_form.invoice_line_ids.remove(0)
        with move_form.invoice_line_ids.new() as line_form:
            line_form.product_id = self.product_a
        with move_form.invoice_line_ids.new() as line_form:
            line_form.product_id = self.product_b
        move_form.save()

        self.assertInvoiceValues(
            self.invoice, [
                {
                    **self.product_line_vals_1,
                    'account_id':
                    self.product_b.property_account_expense_id.id,
                    'partner_id':
                    self.partner_b.id,
                    'tax_ids':
                    self.tax_purchase_b.ids,
                },
                {
                    **self.product_line_vals_2,
                    'partner_id': self.partner_b.id,
                    'price_total': 184.0,
                    'tax_ids': self.tax_purchase_b.ids,
                },
                {
                    **self.tax_line_vals_1,
                    'name': self.tax_purchase_b.name,
                    'partner_id': self.partner_b.id,
                    'tax_line_id': self.tax_purchase_b.id,
                },
                {
                    **self.term_line_vals_1,
                    'name': 'turlututu',
                    'account_id':
                    self.partner_b.property_account_payable_id.id,
                    'partner_id': self.partner_b.id,
                    'price_unit': -331.2,
                    'price_subtotal': -331.2,
                    'price_total': -331.2,
                    'debit': 331.2,
                },
                {
                    **self.term_line_vals_1,
                    'name': 'turlututu',
                    'account_id':
                    self.partner_b.property_account_payable_id.id,
                    'partner_id': self.partner_b.id,
                    'price_unit': -772.8,
                    'price_subtotal': -772.8,
                    'price_total': -772.8,
                    'debit': 772.8,
                    'date_maturity': fields.Date.from_string('2019-02-28'),
                },
            ], {
                **self.move_vals,
                'partner_id': self.partner_b.id,
                'invoice_payment_ref': 'turlututu',
                'fiscal_position_id': self.fiscal_pos_a.id,
                'invoice_payment_term_id': self.pay_terms_b.id,
                'amount_untaxed': 960.0,
                'amount_tax': 144.0,
                'amount_total': 1104.0,
            })
예제 #2
0
    def test_out_refund_line_onchange_partner_1(self):
        move_form = Form(self.invoice)
        move_form.partner_id = self.partner_b
        move_form.invoice_payment_ref = 'turlututu'
        move_form.save()

        self.assertInvoiceValues(
            self.invoice, [
                {
                    **self.product_line_vals_1,
                    'partner_id': self.partner_b.id,
                },
                {
                    **self.product_line_vals_2,
                    'partner_id': self.partner_b.id,
                },
                {
                    **self.tax_line_vals_1,
                    'partner_id': self.partner_b.id,
                },
                {
                    **self.tax_line_vals_2,
                    'partner_id': self.partner_b.id,
                },
                {
                    **self.term_line_vals_1,
                    'name': 'turlututu',
                    'partner_id': self.partner_b.id,
                    'account_id':
                    self.partner_b.property_account_receivable_id.id,
                    'price_unit': -987.0,
                    'price_subtotal': -987.0,
                    'price_total': -987.0,
                    'credit': 987.0,
                    'date_maturity': fields.Date.from_string('2019-02-28'),
                },
                {
                    **self.term_line_vals_1,
                    'name': 'turlututu',
                    'partner_id': self.partner_b.id,
                    'account_id':
                    self.partner_b.property_account_receivable_id.id,
                    'price_unit': -423.0,
                    'price_subtotal': -423.0,
                    'price_total': -423.0,
                    'credit': 423.0,
                },
            ], {
                **self.move_vals,
                'partner_id': self.partner_b.id,
                'invoice_payment_ref': 'turlututu',
                'fiscal_position_id': self.fiscal_pos_a.id,
                'invoice_payment_term_id': self.pay_terms_b.id,
                'amount_untaxed': 1200.0,
                'amount_tax': 210.0,
                'amount_total': 1410.0,
            })

        # Remove lines and recreate them to apply the fiscal position.
        move_form = Form(self.invoice)
        move_form.invoice_line_ids.remove(0)
        move_form.invoice_line_ids.remove(0)
        with move_form.invoice_line_ids.new() as line_form:
            line_form.product_id = self.product_a
        with move_form.invoice_line_ids.new() as line_form:
            line_form.product_id = self.product_b
        move_form.save()

        self.assertInvoiceValues(
            self.invoice, [
                {
                    **self.product_line_vals_1,
                    'account_id':
                    self.product_b.property_account_income_id.id,
                    'partner_id':
                    self.partner_b.id,
                    'tax_ids':
                    self.tax_sale_b.ids,
                },
                {
                    **self.product_line_vals_2,
                    'partner_id': self.partner_b.id,
                    'price_total': 230.0,
                    'tax_ids': self.tax_sale_b.ids,
                },
                {
                    **self.tax_line_vals_1,
                    'name': self.tax_sale_b.name,
                    'partner_id': self.partner_b.id,
                    'tax_line_id': self.tax_sale_b.id,
                },
                {
                    **self.term_line_vals_1,
                    'name': 'turlututu',
                    'account_id':
                    self.partner_b.property_account_receivable_id.id,
                    'partner_id': self.partner_b.id,
                    'price_unit': -966.0,
                    'price_subtotal': -966.0,
                    'price_total': -966.0,
                    'credit': 966.0,
                    'date_maturity': fields.Date.from_string('2019-02-28'),
                },
                {
                    **self.term_line_vals_1,
                    'name': 'turlututu',
                    'account_id':
                    self.partner_b.property_account_receivable_id.id,
                    'partner_id': self.partner_b.id,
                    'price_unit': -414.0,
                    'price_subtotal': -414.0,
                    'price_total': -414.0,
                    'credit': 414.0,
                },
            ], {
                **self.move_vals,
                'partner_id': self.partner_b.id,
                'invoice_payment_ref': 'turlututu',
                'fiscal_position_id': self.fiscal_pos_a.id,
                'invoice_payment_term_id': self.pay_terms_b.id,
                'amount_untaxed': 1200.0,
                'amount_tax': 180.0,
                'amount_total': 1380.0,
            })