mirror of https://github.com/OCA/web.git
[18.0][FIX] web_pivot_computed_measure: fix tests
There is no need to create a model for just testing UI interaction. After finish test the fields of that model cause errors with other modules tests like web_responsive. Instead we can use existing models like res.partner.pull/3038/head
parent
48dc5919a8
commit
c1c4e14c35
|
@ -11,6 +11,9 @@
|
||||||
"auto_install": False,
|
"auto_install": False,
|
||||||
"installable": True,
|
"installable": True,
|
||||||
"maintainers": ["CarlosRoca13"],
|
"maintainers": ["CarlosRoca13"],
|
||||||
|
"demo": [
|
||||||
|
"demo/demo_users_pivot_view.xml",
|
||||||
|
],
|
||||||
"assets": {
|
"assets": {
|
||||||
"web.assets_backend": [
|
"web.assets_backend": [
|
||||||
"web_pivot_computed_measure/static/src/**/*.esm.js",
|
"web_pivot_computed_measure/static/src/**/*.esm.js",
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<record id="pivot_partner_demo" model="res.partner">
|
||||||
|
<field name="name">Pivot Demo</field>
|
||||||
|
<field name="company_id" ref="base.main_company" />
|
||||||
|
<field name="company_name">YourCompany</field>
|
||||||
|
<field name="street">3575 Buena Vista Avenue</field>
|
||||||
|
<field name="city">Eugene</field>
|
||||||
|
<field name="state_id" model="res.country.state" search="[('code','=','OR')]" />
|
||||||
|
<field name="zip">97401</field>
|
||||||
|
<field name="country_id" ref="base.us" />
|
||||||
|
<field name="tz">Europe/Brussels</field>
|
||||||
|
<field name="email">mark.brown23@example.com</field>
|
||||||
|
<field name="phone">(441)-695-2344</field>
|
||||||
|
<field name="partner_latitude">40.712776</field>
|
||||||
|
<field name="partner_longitude">-74.005974</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="demo_view_res_partner_report_pivot" model="ir.ui.view">
|
||||||
|
<field name="name">res.partner.report.pivot</field>
|
||||||
|
<field name="model">res.partner</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<pivot string="Partners Table" sample="1">
|
||||||
|
<field name="active" type="col" />
|
||||||
|
<field name="name" type="row" />
|
||||||
|
</pivot>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="demo_action_res_partner_report_pivot" model="ir.actions.act_window">
|
||||||
|
<field name="name">Demo Pivot</field>
|
||||||
|
<field name="res_model">res.partner</field>
|
||||||
|
<field name="view_mode">pivot</field>
|
||||||
|
<field
|
||||||
|
name="view_id"
|
||||||
|
ref="web_pivot_computed_measure.demo_view_res_partner_report_pivot"
|
||||||
|
/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<menuitem
|
||||||
|
id="demo_menu_res_partner_report_pivot"
|
||||||
|
action="web_pivot_computed_measure.demo_action_res_partner_report_pivot"
|
||||||
|
sequence="10"
|
||||||
|
/>
|
||||||
|
</odoo>
|
|
@ -216,7 +216,7 @@ patch(PivotModel.prototype, {
|
||||||
const afield = toAnalyze.shift();
|
const afield = toAnalyze.shift();
|
||||||
const fieldDef = this.metaData.fields[afield];
|
const fieldDef = this.metaData.fields[afield];
|
||||||
// Need to check if fieldDef exists to avoid problems with __count
|
// Need to check if fieldDef exists to avoid problems with __count
|
||||||
if (fieldDef && fieldDef.__computed_id) {
|
if (fieldDef?.__computed_id) {
|
||||||
const cm = this._computed_measures.find((item) => {
|
const cm = this._computed_measures.find((item) => {
|
||||||
return item.id === fieldDef.__computed_id;
|
return item.id === fieldDef.__computed_id;
|
||||||
});
|
});
|
||||||
|
@ -275,10 +275,10 @@ patch(PivotModel.prototype, {
|
||||||
const fieldNames = Object.keys(this.metaData.fields);
|
const fieldNames = Object.keys(this.metaData.fields);
|
||||||
for (const fieldName of fieldNames) {
|
for (const fieldName of fieldNames) {
|
||||||
const field = this.metaData.fields[fieldName];
|
const field = this.metaData.fields[fieldName];
|
||||||
if (field.__computed_id) {
|
if (field?.__computed_id) {
|
||||||
const cm = this._computed_measures.find((item) => {
|
const cm = this._computed_measures.find(
|
||||||
return item.id === field.__computed_id;
|
(item) => item.id === field.__computed_id
|
||||||
});
|
);
|
||||||
if (!cm) {
|
if (!cm) {
|
||||||
delete this.metaData.fields[fieldName];
|
delete this.metaData.fields[fieldName];
|
||||||
delete this.metaData.measures[fieldName];
|
delete this.metaData.measures[fieldName];
|
||||||
|
|
|
@ -11,19 +11,8 @@ registry.category("web_tour.tours").add("web_pivot_computed_measure_tour", {
|
||||||
run: "click",
|
run: "click",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
trigger: '.o_app[data-menu-xmlid="base.menu_administration"]',
|
trigger:
|
||||||
run: "click",
|
'.o_app[data-menu-xmlid="web_pivot_computed_measure.demo_menu_res_partner_report_pivot"]',
|
||||||
},
|
|
||||||
{
|
|
||||||
trigger: 'button[data-menu-xmlid="base.menu_users"]',
|
|
||||||
run: "click",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
trigger: 'a[data-menu-xmlid="base.menu_action_res_users"]',
|
|
||||||
run: "click",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
trigger: "button.o_pivot",
|
|
||||||
run: "click",
|
run: "click",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -37,25 +26,25 @@ registry.category("web_tour.tours").add("web_pivot_computed_measure_tour", {
|
||||||
{
|
{
|
||||||
trigger: "select#computed_measure_field_1",
|
trigger: "select#computed_measure_field_1",
|
||||||
run() {
|
run() {
|
||||||
this.anchor.value = "user_year_now";
|
this.anchor.value = "partner_latitude";
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
trigger: "select#computed_measure_field_2",
|
trigger: "select#computed_measure_field_2",
|
||||||
run() {
|
run() {
|
||||||
this.anchor.value = "user_year_born";
|
this.anchor.value = "partner_longitude";
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
trigger: "select#computed_measure_operation",
|
trigger: "select#computed_measure_operation",
|
||||||
run() {
|
run() {
|
||||||
this.anchor.value = "m1-m2";
|
this.anchor.value = "m1+m2";
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
trigger: "select#computed_measure_format",
|
trigger: "select#computed_measure_format",
|
||||||
run() {
|
run() {
|
||||||
this.anchor.value = "integer";
|
this.anchor.value = "float";
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -63,22 +52,26 @@ registry.category("web_tour.tours").add("web_pivot_computed_measure_tour", {
|
||||||
run: "click",
|
run: "click",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
trigger: 'th.o_pivot_measure_row:contains("User Year Now")',
|
trigger: '.o_pivot_buttons div[aria-label="Main actions"] button',
|
||||||
|
run: "click",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
trigger: 'div.o_value:contains("2,022")',
|
trigger: 'th.o_pivot_measure_row:contains("Geo Latitude")',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
trigger: 'th.o_pivot_measure_row:contains("User Year Born")',
|
trigger: 'th.o_pivot_measure_row:contains("Geo Longitude")',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
trigger: 'div.o_value:contains("1,998")',
|
trigger: 'th.o_pivot_measure_row:contains("Geo Latitude+Geo Longitude")',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
trigger: 'th.o_pivot_measure_row:contains("User Year Now-User Year Born")',
|
trigger: 'div.o_value:contains("40.7127760")',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
trigger: 'div.o_value:contains("24")',
|
trigger: 'div.o_value:contains("-74.0059740")',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
trigger: 'div.o_value:contains("-33.29")',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
# Copyright 2022 Tecnativa - Carlos Roca
|
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
|
||||||
|
|
||||||
|
|
||||||
from odoo import fields, models
|
|
||||||
|
|
||||||
|
|
||||||
class ResUsersFake(models.Model):
|
|
||||||
_inherit = "res.users"
|
|
||||||
|
|
||||||
user_year_born = fields.Integer()
|
|
||||||
user_year_now = fields.Integer()
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Copyright 2022 Tecnativa - Carlos Roca
|
# Copyright 2022 Tecnativa - Carlos Roca
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||||
from odoo_test_helper import FakeModelLoader
|
|
||||||
|
|
||||||
from odoo.tests import common, tagged
|
from odoo.tests import common, tagged
|
||||||
|
|
||||||
|
@ -9,24 +9,8 @@ from odoo.tests import common, tagged
|
||||||
class TestUIPivot(common.HttpCase):
|
class TestUIPivot(common.HttpCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super().setUpClass()
|
res = super().setUpClass()
|
||||||
cls.loader = FakeModelLoader(cls.env, cls.__module__)
|
return res
|
||||||
cls.loader.backup_registry()
|
|
||||||
from .res_users_fake import ResUsersFake
|
|
||||||
|
|
||||||
cls.loader.update_registry((ResUsersFake,))
|
|
||||||
cls.env["res.users"].create(
|
|
||||||
{
|
|
||||||
"name": "User 1",
|
|
||||||
"login": "us_1",
|
|
||||||
# Fake fields
|
|
||||||
"user_year_born": 1998,
|
|
||||||
"user_year_now": 2022,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
# Set pivot view to company action
|
|
||||||
action = cls.env.ref("base.action_res_users")
|
|
||||||
action.view_mode += ",pivot"
|
|
||||||
|
|
||||||
def test_ui(self):
|
def test_ui(self):
|
||||||
self.start_tour(
|
self.start_tour(
|
||||||
|
|
Loading…
Reference in New Issue