[REF] point_of_sale: converted yml test cases to python unit test
This commit is contained in:
committed by
Martin Trigaux
parent
32b5515a8f
commit
62040dea69
@@ -65,14 +65,6 @@ Main Features
|
||||
'demo': [
|
||||
'data/point_of_sale_demo.xml',
|
||||
],
|
||||
'test': [
|
||||
'../account/test/account_minimal_test.xml',
|
||||
'test/tests_before.xml',
|
||||
'test/00_register_open.yml',
|
||||
'test/01_order_to_payment.yml',
|
||||
'test/02_order_to_invoice.yml',
|
||||
'test/account_statement_reports.yml',
|
||||
],
|
||||
'installable': True,
|
||||
'application': True,
|
||||
'qweb': ['static/src/xml/pos.xml'],
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
-
|
||||
In order to test the Point of Sale module, I will open all cash registers through the wizard
|
||||
-
|
||||
I go to the window to open the cash registers as admin
|
||||
-
|
||||
!record {model: pos.open.statement, id: new_statement_open}:
|
||||
-
|
||||
I click on the button to open all statements/cash registers
|
||||
-
|
||||
!python {model: pos.open.statement}: |
|
||||
self.open_statement(cr, uid, [ref('new_statement_open')], context={})
|
||||
@@ -1,136 +0,0 @@
|
||||
- |
|
||||
In order to test the Point of Sale in module, I will do a full flow from the sale to the payment and invoicing.
|
||||
I will use two products, one with price including a 10% tax, the other one with 5% tax excluded from the price.
|
||||
- |
|
||||
I create a VAT tax of 10%, included in the public price
|
||||
-
|
||||
!record {model: account.tax, id: account_tax_10_incl}:
|
||||
name: VAT 10 perc Incl
|
||||
amount_type: percent
|
||||
amount: 10.0
|
||||
price_include: 1
|
||||
-
|
||||
I assign this 10 percent tax on the [PCSC234] PC Assemble SC234 product as a sale tax
|
||||
-
|
||||
!record {model: product.product, id: product.product_product_3, view: False}:
|
||||
taxes_id: [account_tax_10_incl]
|
||||
- |
|
||||
I create a VAT tax of 5%, which is added to the public price
|
||||
-
|
||||
!record {model: account.tax, id: account_tax_05_incl}:
|
||||
name: VAT 05 perc Excl
|
||||
amount_type: percent
|
||||
amount: 5.0
|
||||
price_include: 0
|
||||
-
|
||||
I will create a second VAT tax of 5% but this time for a child company, to
|
||||
ensure that only product taxes of the current session's company are considered
|
||||
(this tax should be ignore when computing order's taxes in following tests)
|
||||
-
|
||||
!record {model: account.tax, id: account_tax_05_incl_chicago}:
|
||||
name: VAT 05 perc Excl (US)
|
||||
amount_type: percent
|
||||
amount: 5.0
|
||||
price_include: 0
|
||||
company_id: stock.res_company_1
|
||||
-
|
||||
I assign those 5 percent taxes on the PCSC349 product as a sale taxes
|
||||
-
|
||||
!record {model: product.product, id: product.product_product_4, view: False}:
|
||||
taxes_id: [account_tax_05_incl, account_tax_05_incl_chicago]
|
||||
-
|
||||
I click on create a new session button
|
||||
-
|
||||
!python {model: pos.config}: |
|
||||
self.open_session_cb(cr, uid, [ref('pos_config_main')])
|
||||
-
|
||||
I create a PoS order with 2 units of PCSC234 at 450 EUR (Tax Incl) and 3 units of PCSC349 at 300 EUR. (Tax Excl)
|
||||
-
|
||||
!record {model: pos.order, id: pos_order_pos0}:
|
||||
company_id: base.main_company
|
||||
lines:
|
||||
- name: OL/0001
|
||||
product_id: product.product_product_3
|
||||
price_unit: 450
|
||||
discount: 0.0
|
||||
qty: 2.0
|
||||
- name: OL/0002
|
||||
product_id: product.product_product_4
|
||||
price_unit: 300
|
||||
discount: 0.0
|
||||
qty: 3.0
|
||||
-
|
||||
I check that the total of the order is equal to 450*2 + 300*3*1.05 and the tax of the order is equal to 900 -(450 * 2 / 1.1) + 300*0.05*3
|
||||
-
|
||||
!python {model: pos.order}: |
|
||||
order = self.browse(cr, uid, ref('pos_order_pos0'))
|
||||
assert(abs(order.amount_total - (450*2 + 300*3*1.05)) < 0.01), "The order has a wrong amount, tax included"
|
||||
assert(abs(order.amount_tax - (900-(450*2/1.1) + 300*0.05*3)) < 0.01), "The order has a wrong tax amount"
|
||||
-
|
||||
I want to add a global discount of 5 percent using the wizard
|
||||
-
|
||||
!record {model: pos.discount, id: pos_discount_0}:
|
||||
discount: 5.0
|
||||
-
|
||||
I click the apply button to set the discount on all lines
|
||||
-
|
||||
!python {model: pos.discount}: |
|
||||
self.apply_discount(cr, uid, [ref("pos_discount_0")], {"active_model": "pos.order",
|
||||
"active_ids": [ref("pos_order_pos0")], "active_id": ref("pos_order_pos0"), })
|
||||
-
|
||||
I check that the total of the order is now equal to (450*2 + 300*3*1.05)*0.95
|
||||
-
|
||||
!python {model: pos.order}: |
|
||||
order = self.browse(cr, uid, ref('pos_order_pos0'))
|
||||
assert(abs(order.amount_total - (450*2 + 300*3*1.05)*0.95) < 0.01), "The order has a wrong total including tax and discounts"
|
||||
-
|
||||
I click on the "Make Payment" wizard to pay the PoS order with a partial amount of 100.0 EUR
|
||||
-
|
||||
!record {model: pos.make.payment, id: pos_make_payment_0, context: '{"active_id": ref("pos_order_pos0"), "active_ids": [ref("pos_order_pos0")]}' }:
|
||||
amount: 100.0
|
||||
-
|
||||
I click on the validate button to register the payment.
|
||||
-
|
||||
!python {model: pos.make.payment}: |
|
||||
self.check(cr, uid, [ref('pos_make_payment_0')], context={'active_id': ref('pos_order_pos0'), 'lang':'en_US', 'active_model': 'pos.order', 'tz': False, 'active_ids': [ref('pos_order_pos0')]} )
|
||||
- |
|
||||
I check that the order is not marked as paid yet
|
||||
-
|
||||
!assert {model: pos.order, id: pos_order_pos0}:
|
||||
- state == 'draft'
|
||||
- |
|
||||
On the second payment proposition, I check that it proposes me the remaining balance which is 1790.0 EUR
|
||||
-
|
||||
!python {model: pos.make.payment}: |
|
||||
defs = self.default_get(cr, uid, ['amount'], {'active_id': ref('pos_order_pos0')})
|
||||
assert abs(defs['amount'] - ((450*2 + 300*3*1.05)*0.95-100.0)) < 0.01, "The remaining balance is incorrect"
|
||||
-
|
||||
I pay the remaining balance.
|
||||
-
|
||||
!record {model: pos.make.payment, id: pos_make_payment_1, context: '{"active_id": ref("pos_order_pos0"), "active_ids": [ref("pos_order_pos0")]}' }:
|
||||
amount: !eval >
|
||||
(450*2 + 300*3*1.05)*0.95-100.0
|
||||
-
|
||||
I click on the validate button to register the payment.
|
||||
-
|
||||
!python {model: pos.make.payment}: |
|
||||
self.check(cr, uid, [ref('pos_make_payment_1')], context={'active_id': ref('pos_order_pos0')} )
|
||||
- |
|
||||
I check that the order is marked as paid
|
||||
-
|
||||
!assert {model: pos.order, id: pos_order_pos0}:
|
||||
- state == 'paid'
|
||||
-
|
||||
I generate the journal entries
|
||||
-
|
||||
!python {model: pos.order}: |
|
||||
self._create_account_move_lines(cr, uid, [ref('pos_order_pos0')], {})
|
||||
-
|
||||
I test that the generated journal entry is attached to the PoS order
|
||||
-
|
||||
!assert {model: pos.order, id: pos_order_pos0}:
|
||||
- bool(account_move)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
-
|
||||
I create a new PoS order with 2 units of PC1 at 450 EUR (Tax Incl) and 3 units of PCSC349 at 300 EUR. (Tax Excl)
|
||||
-
|
||||
!record {model: pos.order, id: pos_order_pos1}:
|
||||
company_id: base.main_company
|
||||
partner_id: base.res_partner_1
|
||||
lines:
|
||||
- name: OL/0001
|
||||
product_id: product.product_product_3
|
||||
price_unit: 450
|
||||
discount: 5.0
|
||||
qty: 2.0
|
||||
- name: OL/0002
|
||||
product_id: product.product_product_4
|
||||
price_unit: 300
|
||||
discount: 5.0
|
||||
qty: 3.0
|
||||
-
|
||||
I click on the "Make Payment" wizard to pay the PoS order
|
||||
-
|
||||
!record {model: pos.make.payment, id: pos_make_payment_2, context: '{"active_id": ref("pos_order_pos1"), "active_ids": [ref("pos_order_pos1")]}' }:
|
||||
amount: !eval >
|
||||
(450*2 + 300*3*1.05)*0.95
|
||||
-
|
||||
I click on the validate button to register the payment.
|
||||
-
|
||||
!python {model: pos.make.payment}: |
|
||||
self.check(cr, uid, [ref('pos_make_payment_2')], context={'active_id': ref('pos_order_pos1')} )
|
||||
- |
|
||||
I check that the order is marked as paid and there is no invoice attached to it
|
||||
-
|
||||
!python {model: pos.order}: |
|
||||
order = self.browse(cr,uid,ref('pos_order_pos1'))
|
||||
-
|
||||
!assert {model: pos.order, id: pos_order_pos1, string: State not correct}:
|
||||
- state == 'paid'
|
||||
- not invoice_id
|
||||
-
|
||||
I set the order as invoiced
|
||||
-
|
||||
!workflow {model: pos.order, action: invoice, ref: pos_order_pos1}
|
||||
-
|
||||
I generate an invoice from the order
|
||||
-
|
||||
!python {model: pos.order}: |
|
||||
invoice = self.action_invoice(cr, uid, [ref('pos_order_pos1')])
|
||||
-
|
||||
I test that the total of the attached invoice is correct
|
||||
-
|
||||
!python {model: pos.order}: |
|
||||
from openerp.tools import float_compare
|
||||
amount_total = self.browse(cr, uid, ref('pos_order_pos1')).amount_total
|
||||
assert float_compare(amount_total, 1752.75, precision_digits=2) == 0, "Invoice not correct"
|
||||
@@ -1,68 +0,0 @@
|
||||
-
|
||||
In order to test the reports on Bank Statement defined in point_of_sale module, I create a bank statement line, confirm it and print the reports
|
||||
-
|
||||
I select the period and journal for the bank statement
|
||||
-
|
||||
!python {model: account.bank.statement}: |
|
||||
import time
|
||||
journal = self._default_journal(cr, uid, {'journal_type': 'bank'})
|
||||
assert journal, 'Journal has not been selected'
|
||||
-
|
||||
I create a bank statement with Opening and Closing balance 0.
|
||||
-
|
||||
!record {model: account.bank.statement, id: account_bank_statement_0}:
|
||||
balance_end_real: 0.0
|
||||
balance_start: 0.0
|
||||
date: !eval time.strftime('%Y-%m-%d')
|
||||
journal_id: bank_journal
|
||||
-
|
||||
I create bank statement line
|
||||
-
|
||||
!record {model: account.bank.statement.line, id: account_bank_statement_line_0}:
|
||||
amount: 1000.0
|
||||
partner_id: base.res_partner_4
|
||||
statement_id: account_bank_statement_0
|
||||
name: 'EXT001'
|
||||
-
|
||||
I modify the bank statement and set the Closing Balance.
|
||||
-
|
||||
!record {model: account.bank.statement, id: account_bank_statement_0}:
|
||||
balance_end_real: 1000.0
|
||||
-
|
||||
I reconcile the bank statement.
|
||||
-
|
||||
!python {model: account.bank.statement.line}: |
|
||||
new_aml_dicts = [{
|
||||
'account_id': self.pool.get('res.partner').browse(cr, uid, ref('base.res_partner_4')).property_account_receivable_id.id,
|
||||
'name': "EXT001",
|
||||
'credit': 1000.0,
|
||||
'debit': 0.0,
|
||||
}]
|
||||
self.process_reconciliations(cr, uid, [ref("account_bank_statement_line_0")], [{'new_aml_dicts': new_aml_dicts}])
|
||||
-
|
||||
I confirm the bank statement using Confirm button
|
||||
-
|
||||
!python {model: account.bank.statement}: |
|
||||
self.button_confirm_bank(cr, uid, [ref("account_bank_statement_0")])
|
||||
-
|
||||
Print the account statement report
|
||||
-
|
||||
!python {model: account.bank.statement}: |
|
||||
import os
|
||||
import openerp.report
|
||||
from openerp import tools
|
||||
data, format = openerp.report.render_report(cr, uid, [ref('account_bank_statement_0')], 'point_of_sale.report_statement', {}, {})
|
||||
if tools.config['test_report_directory']:
|
||||
file(os.path.join(tools.config['test_report_directory'], 'point_of_sale-statement.'+format), 'wb+').write(data)
|
||||
|
||||
-
|
||||
Printing the user s product report
|
||||
-
|
||||
!python {model: account.bank.statement}: |
|
||||
import os
|
||||
import openerp.report
|
||||
from openerp import tools
|
||||
data, format = openerp.report.render_report(cr, uid, [ref('account_bank_statement_0')], 'point_of_sale.report_usersproduct', {}, {})
|
||||
if tools.config['test_report_directory']:
|
||||
file(os.path.join(tools.config['test_report_directory'], 'point_of_sale-usersproduct.'+format), 'wb+').write(data)
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="bank_journal" model="account.journal">
|
||||
<field eval="True" name="journal_user"/>
|
||||
</record>
|
||||
<record model="pos.config" id="pos_config_main">
|
||||
<field name="journal_ids" eval="[(6, 0, [ref('bank_journal')])]" />
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import test_point_of_sale_flow
|
||||
@@ -0,0 +1,60 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
class TestPointOfSaleCommon(common.TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestPointOfSaleCommon, self).setUp()
|
||||
self.AccountBankStatement = self.env['account.bank.statement']
|
||||
self.AccountBankStatementLine = self.env['account.bank.statement.line']
|
||||
self.PosMakePayment = self.env['pos.make.payment']
|
||||
self.PosOrder = self.env['pos.order']
|
||||
self.company_id = self.ref('base.main_company')
|
||||
self.product3 = self.env.ref('product.product_product_3')
|
||||
self.product4 = self.env.ref('product.product_product_4')
|
||||
self.partner1 = self.env.ref('base.res_partner_1')
|
||||
self.partner4 = self.env.ref('base.res_partner_4')
|
||||
self.pos_config = self.env.ref('point_of_sale.pos_config_main')
|
||||
|
||||
# create a new session
|
||||
self.pos_order_session0 = self.env['pos.session'].create({
|
||||
'user_id': 1,
|
||||
'config_id': self.pos_config.id
|
||||
})
|
||||
|
||||
# create a VAT tax of 10%, included in the public price
|
||||
Tax = self.env['account.tax']
|
||||
account_tax_10_incl = Tax.create({
|
||||
'name': 'VAT 10 perc Incl',
|
||||
'amount_type': 'percent',
|
||||
'amount': 10.0,
|
||||
'price_include': 1
|
||||
})
|
||||
|
||||
# assign this 10 percent tax on the [PCSC234] PC Assemble SC234 product
|
||||
# as a sale tax
|
||||
self.product3.taxes_id = [(6, 0, [account_tax_10_incl.id])]
|
||||
|
||||
# create a VAT tax of 5%, which is added to the public price
|
||||
account_tax_05_incl = Tax.create({
|
||||
'name': 'VAT 5 perc Incl',
|
||||
'amount_type': 'percent',
|
||||
'amount': 5.0,
|
||||
'price_include': 0
|
||||
})
|
||||
|
||||
# create a second VAT tax of 5% but this time for a child company, to
|
||||
# ensure that only product taxes of the current session's company are considered
|
||||
#(this tax should be ignore when computing order's taxes in following tests)
|
||||
account_tax_05_incl_chicago = Tax.create({
|
||||
'name': 'VAT 05 perc Excl (US)',
|
||||
'amount_type': 'percent',
|
||||
'amount': 5.0,
|
||||
'price_include': 0,
|
||||
'company_id': self.ref('stock.res_company_1')
|
||||
})
|
||||
|
||||
# I assign those 5 percent taxes on the PCSC349 product as a sale taxes
|
||||
self.product4.write(
|
||||
{'taxes_id': [(6, 0, [account_tax_05_incl.id, account_tax_05_incl_chicago.id])]})
|
||||
@@ -0,0 +1,217 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import datetime
|
||||
import time
|
||||
import os
|
||||
|
||||
import odoo
|
||||
from odoo import tools, report as odoo_report
|
||||
from odoo.tools import float_compare, test_reports
|
||||
|
||||
from odoo.addons.point_of_sale.tests.common import TestPointOfSaleCommon
|
||||
|
||||
|
||||
@odoo.tests.common.at_install(False)
|
||||
@odoo.tests.common.post_install(True)
|
||||
class TestPointOfSaleFlow(TestPointOfSaleCommon):
|
||||
|
||||
def test_register_open(self):
|
||||
"""
|
||||
In order to test the Point of Sale module, I will open all cash registers through the wizard
|
||||
"""
|
||||
# open all statements/cash registers
|
||||
self.env['pos.open.statement'].create({}).open_statement()
|
||||
|
||||
def test_order_to_payment(self):
|
||||
"""
|
||||
In order to test the Point of Sale in module, I will do a full flow from the sale to the payment and invoicing.
|
||||
I will use two products, one with price including a 10% tax, the other one with 5% tax excluded from the price.
|
||||
"""
|
||||
# I click on create a new session button
|
||||
self.pos_config.open_session_cb()
|
||||
|
||||
# I create a PoS order with 2 units of PCSC234 at 450 EUR (Tax Incl)
|
||||
# and 3 units of PCSC349 at 300 EUR. (Tax Excl)
|
||||
self.pos_order_pos0 = self.PosOrder.create({
|
||||
'company_id': self.company_id,
|
||||
'pricelist_id': self.partner1.property_product_pricelist.id,
|
||||
'partner_id': self.partner1.id,
|
||||
'lines': [(0, 0, {
|
||||
'name': "OL/0001",
|
||||
'product_id': self.product3.id,
|
||||
'price_unit': 450,
|
||||
'discount': 0.0,
|
||||
'qty': 2.0,
|
||||
'tax_ids': [(6, 0, self.product3.taxes_id.ids)],
|
||||
}), (0, 0, {
|
||||
'name': "OL/0002",
|
||||
'product_id': self.product4.id,
|
||||
'price_unit': 300,
|
||||
'discount': 0.0,
|
||||
'qty': 3.0,
|
||||
'tax_ids': [(6, 0, self.product4.taxes_id.ids)],
|
||||
})]
|
||||
})
|
||||
|
||||
# I check that the total of the order is equal to 450*2 + 300*3*1.05
|
||||
# and the tax of the order is equal to 900 -(450 * 2 / 1.1) +
|
||||
# 300*0.05*3
|
||||
self.assertLess(
|
||||
abs(self.pos_order_pos0.amount_total - (450 * 2 + 300 * 3 * 1.05)),
|
||||
0.01, 'The order has a wrong amount, tax included.')
|
||||
|
||||
self.assertLess(
|
||||
abs(self.pos_order_pos0.amount_tax - (900 - (450 * 2 / 1.1) + 300 * 0.05 * 3)),
|
||||
0.01, 'The order has a wrong tax amount.')
|
||||
|
||||
# I want to add a global discount of 5 percent using the wizard
|
||||
|
||||
self.pos_discount_0 = self.env['pos.discount'].create({'discount': 5.0})
|
||||
|
||||
context = {"active_model": "pos.order", "active_ids": [self.pos_order_pos0.id], "active_id": self.pos_order_pos0.id}
|
||||
|
||||
# I click the apply button to set the discount on all lines
|
||||
self.pos_discount_0.with_context(context).apply_discount()
|
||||
|
||||
# I check that the total of the order is now equal to (450*2 +
|
||||
# 300*3*1.05)*0.95
|
||||
self.assertLess(
|
||||
abs(self.pos_order_pos0.amount_total - (450 * 2 + 300 * 3 * 1.05) * 0.95),
|
||||
0.01, 'The order has a wrong total including tax and discounts')
|
||||
|
||||
# I click on the "Make Payment" wizard to pay the PoS order with a
|
||||
# partial amount of 100.0 EUR
|
||||
context_make_payment = {"active_ids": [self.pos_order_pos0.id], "active_id": self.pos_order_pos0.id}
|
||||
self.pos_make_payment_0 = self.PosMakePayment.with_context(context_make_payment).create({
|
||||
'amount': 100.0
|
||||
})
|
||||
|
||||
# I click on the validate button to register the payment.
|
||||
context_payment = {'active_id': self.pos_order_pos0.id}
|
||||
self.pos_make_payment_0.with_context(context_payment).check()
|
||||
|
||||
# I check that the order is not marked as paid yet
|
||||
self.assertEqual(self.pos_order_pos0.state, 'draft', 'Order should be in draft state.')
|
||||
|
||||
# On the second payment proposition, I check that it proposes me the
|
||||
# remaining balance which is 1790.0 EUR
|
||||
defs = self.pos_make_payment_0.with_context({'active_id': self.pos_order_pos0.id}).default_get(['amount'])
|
||||
|
||||
self.assertLess(
|
||||
abs(defs['amount'] - ((450 * 2 + 300 * 3 * 1.05) * 0.95 - 100.0)), 0.01, "The remaining balance is incorrect.")
|
||||
|
||||
#'I pay the remaining balance.
|
||||
context_make_payment = {
|
||||
"active_ids": [self.pos_order_pos0.id], "active_id": self.pos_order_pos0.id}
|
||||
|
||||
self.pos_make_payment_1 = self.PosMakePayment.with_context(context_make_payment).create({
|
||||
'amount': (450 * 2 + 300 * 3 * 1.05) * 0.95 - 100.0
|
||||
})
|
||||
|
||||
# I click on the validate button to register the payment.
|
||||
self.pos_make_payment_1.with_context(context_make_payment).check()
|
||||
|
||||
# I check that the order is marked as paid
|
||||
self.assertEqual(self.pos_order_pos0.state, 'paid', 'Order should be in paid state.')
|
||||
|
||||
# I generate the journal entries
|
||||
self.pos_order_pos0._create_account_move_line()
|
||||
|
||||
# I test that the generated journal entry is attached to the PoS order
|
||||
self.assertTrue(self.pos_order_pos0.account_move, "Journal entry has not been attached to Pos order.")
|
||||
|
||||
def test_order_to_invoice(self):
|
||||
|
||||
#I create a new PoS order with 2 units of PC1 at 450 EUR (Tax Incl) and 3 units of PCSC349 at 300 EUR. (Tax Excl)
|
||||
self.pos_order_pos1 = self.PosOrder.create({
|
||||
'company_id': self.company_id,
|
||||
'partner_id': self.partner1.id,
|
||||
'pricelist_id': self.partner1.property_product_pricelist.id,
|
||||
'lines': [(0, 0, {
|
||||
'name': "OL/0001",
|
||||
'product_id': self.product3.id,
|
||||
'price_unit': 450,
|
||||
'discount': 5.0,
|
||||
'qty': 2.0,
|
||||
'tax_ids': [(6, 0, self.product3.taxes_id.ids)],
|
||||
}), (0, 0, {
|
||||
'name': "OL/0002",
|
||||
'product_id': self.product4.id,
|
||||
'price_unit': 300,
|
||||
'discount': 5.0,
|
||||
'qty': 3.0,
|
||||
'tax_ids': [(6, 0, self.product4.taxes_id.ids)],
|
||||
})]
|
||||
})
|
||||
|
||||
# I click on the "Make Payment" wizard to pay the PoS order
|
||||
context_make_payment = {"active_ids": [self.pos_order_pos1.id], "active_id": self.pos_order_pos1.id}
|
||||
self.pos_make_payment = self.PosMakePayment.with_context(context_make_payment).create({
|
||||
'amount': (450 * 2 + 300 * 3 * 1.05) * 0.95,
|
||||
})
|
||||
# I click on the validate button to register the payment.
|
||||
context_payment = {'active_id': self.pos_order_pos1.id}
|
||||
self.pos_make_payment.with_context(context_payment).check()
|
||||
|
||||
# I check that the order is marked as paid and there is no invoice
|
||||
# attached to it
|
||||
self.assertEqual(self.pos_order_pos1.state, 'paid', "Order should be in paid state.")
|
||||
self.assertFalse(self.pos_order_pos1.invoice_id, 'Invoice should not be attached to order.')
|
||||
|
||||
# I set the order as invoiced
|
||||
self.pos_order_pos1.signal_workflow('invoice')
|
||||
|
||||
# I generate an invoice from the order
|
||||
self.invoice = self.pos_order_pos1.action_invoice()
|
||||
|
||||
# I test that the total of the attached invoice is correct
|
||||
self.amount_total = self.pos_order_pos1.amount_total
|
||||
self.assertEqual(
|
||||
float_compare(self.amount_total, 1752.75, precision_digits=2), 0, "Invoice not correct")
|
||||
|
||||
"""In order to test the reports on Bank Statement defined in point_of_sale module, I create a bank statement line, confirm it and print the reports"""
|
||||
|
||||
# I select the period and journal for the bank statement
|
||||
|
||||
context_journal = {'journal_type': 'bank'}
|
||||
self.assertTrue(self.AccountBankStatement.with_context(
|
||||
context_journal)._default_journal(), 'Journal has not been selected')
|
||||
journal = self.env['account.journal'].create({
|
||||
'name': 'Bank Test',
|
||||
'code': 'BNKT',
|
||||
'type': 'bank',
|
||||
'company_id': self.company_id,
|
||||
})
|
||||
# I create a bank statement with Opening and Closing balance 0.
|
||||
account_statement = self.AccountBankStatement.create({
|
||||
'balance_start': 0.0,
|
||||
'balance_end_real': 0.0,
|
||||
'date': time.strftime('%Y-%m-%d'),
|
||||
'journal_id': journal.id,
|
||||
'company_id': self.company_id,
|
||||
})
|
||||
# I create bank statement line
|
||||
account_statement_line = self.AccountBankStatementLine.create({
|
||||
'amount': 1000,
|
||||
'partner_id': self.partner4.id,
|
||||
'statement_id': account_statement.id,
|
||||
'name': 'EXT001'
|
||||
})
|
||||
# I modify the bank statement and set the Closing Balance.
|
||||
account_statement.write({
|
||||
'balance_end_real': 1000.0,
|
||||
})
|
||||
|
||||
# I reconcile the bank statement.
|
||||
new_aml_dicts = [{
|
||||
'account_id': self.partner4.property_account_receivable_id.id,
|
||||
'name': "EXT001",
|
||||
'credit': 1000.0,
|
||||
'debit': 0.0,
|
||||
}]
|
||||
|
||||
self.AccountBankStatementLine._model.process_reconciliations(
|
||||
self.env.cr, self.env.uid, [account_statement_line.id], [{'new_aml_dicts': new_aml_dicts}])
|
||||
|
||||
# I confirm the bank statement using Confirm button
|
||||
|
||||
self.AccountBankStatement.button_confirm_bank()
|
||||
Reference in New Issue
Block a user