summaryrefslogtreecommitdiff
path: root/addons/account/static/tests
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/account/static/tests
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/account/static/tests')
-rw-r--r--addons/account/static/tests/account_payment_field_tests.js84
-rw-r--r--addons/account/static/tests/section_and_note_tests.js98
-rw-r--r--addons/account/static/tests/tours/account_dashboard_setup_bar_tests.js42
-rw-r--r--addons/account/static/tests/tours/tax_group_tests.js124
4 files changed, 348 insertions, 0 deletions
diff --git a/addons/account/static/tests/account_payment_field_tests.js b/addons/account/static/tests/account_payment_field_tests.js
new file mode 100644
index 00000000..48609728
--- /dev/null
+++ b/addons/account/static/tests/account_payment_field_tests.js
@@ -0,0 +1,84 @@
+odoo.define('account.reconciliation_field_tests', function (require) {
+"use strict";
+
+var FormView = require('web.FormView');
+var testUtils = require('web.test_utils');
+
+var createView = testUtils.createView;
+
+QUnit.module('account', {
+ beforeEach: function () {
+ this.data = {
+ 'account.move': {
+ fields: {
+ payments_widget: {string: "payments_widget data", type: "char"},
+ outstanding_credits_debits_widget: {string: "outstanding_credits_debits_widget data", type: "char"},
+ },
+ records: [{
+ id: 1,
+ payments_widget: '{"content": [{"digits": [69, 2], "currency": "$", "amount": 555.0, "name": "Customer Payment: INV/2017/0004", "date": "2017-04-25", "position": "before", "ref": "BNK1/2017/0003 (INV/2017/0004)", "payment_id": 22, "move_id": 10, "partial_id": 38, "journal_name": "Bank"}], "outstanding": false, "title": "Less Payment"}',
+ outstanding_credits_debits_widget: '{"content": [{"digits": [69, 2], "currency": "$", "amount": 100.0, "journal_name": "INV/2017/0004", "position": "before", "id": 20}], "move_id": 4, "outstanding": true, "title": "Outstanding credits"}',
+ }]
+ },
+ };
+ }
+}, function () {
+ QUnit.module('Reconciliation');
+
+ QUnit.test('Reconciliation form field', async function (assert) {
+ assert.expect(5);
+
+ var form = await createView({
+ View: FormView,
+ model: 'account.move',
+ data: this.data,
+ arch: '<form>'+
+ '<field name="outstanding_credits_debits_widget" widget="payment"/>'+
+ '<field name="payments_widget" widget="payment"/>'+
+ '</form>',
+ res_id: 1,
+ mockRPC: function (route, args) {
+ if (args.method === 'js_remove_outstanding_partial') {
+ assert.deepEqual(args.args, [10, 38], "should call js_remove_outstanding_partial {warning: required focus}");
+ return Promise.resolve();
+ }
+ if (args.method === 'js_assign_outstanding_line') {
+ assert.deepEqual(args.args, [4, 20], "should call js_assign_outstanding_line {warning: required focus}");
+ return Promise.resolve();
+ }
+ return this._super.apply(this, arguments);
+ },
+ intercepts: {
+ do_action: function (event) {
+ assert.deepEqual(event.data.action, {
+ 'type': 'ir.actions.act_window',
+ 'res_model': 'account.move',
+ 'res_id': 10,
+ 'views': [[false, 'form']],
+ 'target': 'current'
+ },
+ "should open the form view");
+ },
+ },
+ });
+
+ assert.strictEqual(form.$('.o_field_widget[name="payments_widget"]').text().replace(/[\s\n\r]+/g, ' '),
+ " Paid on 04/25/2017 $ 555.00 ",
+ "should display payment information");
+
+ form.$('.o_field_widget[name="outstanding_credits_debits_widget"] .outstanding_credit_assign').trigger('click');
+
+ assert.strictEqual(form.$('.o_field_widget[name="outstanding_credits_debits_widget"]').text().replace(/[\s\n\r]+/g, ' '),
+ " Outstanding credits Add INV/2017/0004 $ 100.00 ",
+ "should display outstanding information");
+
+ form.$('.o_field_widget[name="payments_widget"] .js_payment_info').trigger('focus');
+ form.$('.popover .js_open_payment').trigger('click');
+
+ form.$('.o_field_widget[name="payments_widget"] .js_payment_info').trigger('focus');
+ form.$('.popover .js_unreconcile_payment').trigger('click');
+
+ form.destroy();
+ });
+});
+});
diff --git a/addons/account/static/tests/section_and_note_tests.js b/addons/account/static/tests/section_and_note_tests.js
new file mode 100644
index 00000000..7dcef00a
--- /dev/null
+++ b/addons/account/static/tests/section_and_note_tests.js
@@ -0,0 +1,98 @@
+odoo.define('account.section_and_note_tests', function (require) {
+"use strict";
+
+var FormView = require('web.FormView');
+var testUtils = require('web.test_utils');
+var createView = testUtils.createView;
+
+QUnit.module('section_and_note', {
+ beforeEach: function () {
+ this.data = {
+ invoice: {
+ fields: {
+ invoice_line_ids: {
+ string: "Lines",
+ type: 'one2many',
+ relation: 'invoice_line',
+ relation_field: 'invoice_id'
+ },
+ },
+ records: [
+ {id: 1, invoice_line_ids: [1, 2]},
+ ],
+ },
+ invoice_line: {
+ fields: {
+ display_type: {
+ string: 'Type',
+ type: 'selection',
+ selection: [['line_section', "Section"], ['line_note', "Note"]]
+ },
+ invoice_id: {
+ string: "Invoice",
+ type: 'many2one',
+ relation: 'invoice'
+ },
+ name: {
+ string: "Name",
+ type: 'text'
+ },
+ },
+ records: [
+ {id: 1, display_type: false, invoice_id: 1, name: 'product\n2 lines'},
+ {id: 2, display_type: 'line_section', invoice_id: 1, name: 'section'},
+ ]
+ },
+ };
+ },
+}, function () {
+ QUnit.test('correct display of section and note fields', async function (assert) {
+ assert.expect(5);
+ var form = await createView({
+ View: FormView,
+ model: 'invoice',
+ data: this.data,
+ arch: '<form>' +
+ '<field name="invoice_line_ids" widget="section_and_note_one2many"/>' +
+ '</form>',
+ archs: {
+ 'invoice_line,false,list': '<tree editable="bottom">' +
+ '<field name="display_type" invisible="1"/>' +
+ '<field name="name" widget="section_and_note_text"/>' +
+ '</tree>',
+ },
+ res_id: 1,
+ });
+
+ assert.hasClass(form.$('[name="invoice_line_ids"] table'), 'o_section_and_note_list_view');
+
+ // section should be displayed correctly
+ var $tr0 = form.$('tr.o_data_row:eq(0)');
+
+ assert.doesNotHaveClass($tr0, 'o_is_line_section',
+ "should not have a section class");
+
+ var $tr1 = form.$('tr.o_data_row:eq(1)');
+
+ assert.hasClass($tr1, 'o_is_line_section',
+ "should have a section class");
+
+ // enter edit mode
+ await testUtils.form.clickEdit(form);
+
+ // editing line should be textarea
+ $tr0 = form.$('tr.o_data_row:eq(0)');
+ await testUtils.dom.click($tr0.find('td.o_data_cell'));
+ assert.containsOnce($tr0, 'td.o_data_cell textarea[name="name"]',
+ "editing line should be textarea");
+
+ // editing section should be input
+ $tr1 = form.$('tr.o_data_row:eq(1)');
+ await testUtils.dom.click($tr1.find('td.o_data_cell'));
+ assert.containsOnce($tr1, 'td.o_data_cell input[name="name"]',
+ "editing section should be input");
+
+ form.destroy();
+ });
+});
+});
diff --git a/addons/account/static/tests/tours/account_dashboard_setup_bar_tests.js b/addons/account/static/tests/tours/account_dashboard_setup_bar_tests.js
new file mode 100644
index 00000000..0d11b027
--- /dev/null
+++ b/addons/account/static/tests/tours/account_dashboard_setup_bar_tests.js
@@ -0,0 +1,42 @@
+odoo.define('account.dashboard.setup.tour', function (require) {
+ "use strict";
+
+ var core = require('web.core');
+ var tour = require('web_tour.tour');
+
+ var _t = core._t;
+
+ tour.register('account_render_report', {
+ test: true,
+ url: '/web',
+ }, [tour.stepUtils.showAppsMenuItem(),
+ {
+ id: 'account_menu_click',
+ trigger: '.o_app[data-menu-xmlid="account.menu_finance"]',
+ position: 'bottom',
+ }, {
+ trigger: '.o_data_row:first',
+ extra_trigger: '.breadcrumb',
+ }, {
+ trigger: '.o_control_panel button:contains("' + _t('Print') + '")',
+ }, {
+ trigger: '.o_control_panel .o_dropdown_menu a:contains("' + _t('Invoices without Payment') + '")',
+ }, {
+ trigger: 'iframe .o_report_layout_standard h2',
+ content: 'Primary color is correct',
+ run: function () {
+ if (this.$anchor.css('color') !== "rgb(18, 52, 86)") {
+ console.error('The primary color should be the one set on the company.');
+ }
+ },
+ }, {
+ trigger: 'iframe .o_report_layout_standard #informations div strong',
+ content: 'Secondary color is correct',
+ run: function () {
+ if (this.$anchor.css('color') !== "rgb(120, 145, 1)") {
+ console.error('The secondary color should be the one set on the company.');
+ }
+ },
+ }
+ ]);
+});
diff --git a/addons/account/static/tests/tours/tax_group_tests.js b/addons/account/static/tests/tours/tax_group_tests.js
new file mode 100644
index 00000000..08cb218f
--- /dev/null
+++ b/addons/account/static/tests/tours/tax_group_tests.js
@@ -0,0 +1,124 @@
+odoo.define('account.tax.group.tour.tests', function (require) {
+ "use strict";
+
+ var core = require('web.core');
+ var tour = require('web_tour.tour');
+ var _t = core._t;
+
+ tour.register('account_tax_group', {
+ test: true,
+ url: "/web",
+ }, [tour.stepUtils.showAppsMenuItem(),
+ {
+ content: "Go to Invoicing",
+ trigger: '.o_app[data-menu-xmlid="account.menu_finance"]',
+ edition: 'community',
+ },
+ {
+ content: "Go to Accounting",
+ trigger: '.o_app[data-menu-xmlid="account_accountant.menu_accounting"]',
+ edition: 'enterprise',
+ },
+ {
+ content: "Go to Vendors",
+ trigger: 'a:contains("Vendors")',
+ },
+ {
+ content: "Go to Bills",
+ trigger: 'span:contains("Bills")',
+ },
+ {
+ extra_trigger: '.breadcrumb:contains("Bills")',
+ content: "Create new bill",
+ trigger: '.o_list_button_add',
+ },
+ // Set a vendor
+ {
+ content: "Add vendor",
+ trigger: 'div.o_field_widget.o_field_many2one[name="partner_id"] div input',
+ run: 'text Azure Interior',
+ },
+ {
+ content: "Valid vendor",
+ trigger: '.ui-menu-item a:contains("Azure Interior")',
+ },
+ // Add First product
+ {
+ content: "Add items",
+ trigger: 'div[name="invoice_line_ids"] .o_field_x2many_list_row_add a:contains("Add a line")',
+ },
+ {
+ content: "Select input",
+ trigger: 'div[name="invoice_line_ids"] .o_list_view .o_selected_row .o_list_many2one:first input',
+ },
+ {
+ content: "Type item",
+ trigger: 'div[name="invoice_line_ids"] .o_list_view .o_selected_row .o_list_many2one:first input',
+ run: "text Large Desk",
+ },
+ {
+ content: "Valid item",
+ trigger: '.ui-menu-item-wrapper:contains("Large Desk")',
+ },
+ // Save account.move
+ {
+ content: "Save the account move",
+ trigger: '.o_form_button_save',
+ },
+ // Edit account.move
+ {
+ content: "Edit the account move",
+ trigger: '.o_form_button_edit',
+ },
+ // Edit tax group amount
+ {
+ content: "Edit tax group amount",
+ trigger: '.oe_tax_group_amount_value',
+ },
+ {
+ content: "Modify the input value",
+ trigger: '.tax_group_edit_input input',
+ run: function (actions) {
+ $('.tax_group_edit_input input').val(200);
+ $('.tax_group_edit_input input').select();
+ var keydownEvent = jQuery.Event('keydown');
+ keydownEvent.which = 13;
+ this.$anchor.trigger(keydownEvent);
+ },
+ },
+ // Check new value for total (with modified tax_group_amount).
+ {
+ content: "Valid total amount",
+ trigger: 'span[name="amount_total"]:contains("1,499.00")',
+ },
+ // Modify the quantity of the object
+ {
+ content: "Select item quantity",
+ trigger: 'div[name="invoice_line_ids"] .o_list_view tbody tr.o_data_row .o_list_number[title="1.000"]',
+ },
+ {
+ content: "Change item quantity",
+ trigger: 'div[name="invoice_line_ids"] .o_list_view tbody tr.o_data_row .o_list_number[title="1.000"] input',
+ run: 'text 2',
+ },
+ {
+ content: "Valid the new value",
+ trigger: 'div[name="invoice_line_ids"] .o_list_view tbody tr.o_data_row .o_list_number[title="1.000"] input',
+ run: function (actions) {
+ var keydownEvent = jQuery.Event('keydown');
+ keydownEvent.which = 13;
+ this.$anchor.trigger(keydownEvent);
+ },
+ },
+ // Save form
+ {
+ content: "Save the account move",
+ trigger: '.o_form_button_save',
+ },
+ // Check new tax group value
+ {
+ content: "Check new value of tax group",
+ trigger: '.oe_tax_group_amount_value:contains("389.70")',
+ },
+ ]);
+});