Skip to content

Commit 69cc921

Browse files
committed
[MIG+REF][11] web_widget_x2many_2d_matrix
The widget has been completely refactored to benefit from the new MVC paradigm introduced in v11.
1 parent 75f7975 commit 69cc921

File tree

13 files changed

+623
-515
lines changed

13 files changed

+623
-515
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../web_widget_x2many_2d_matrix
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[bdist_wheel]
2+
universal=1
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)

web_widget_x2many_2d_matrix/README.rst

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
This module allows to show an x2many field with 3-tuples
1010
($x_value, $y_value, $value) in a table
1111

12-
========= =========== ===========
13-
\ $x_value1 $x_value2
14-
========= =========== ===========
15-
$y_value1 $value(1/1) $value(2/1)
16-
$y_value2 $value(1/2) $value(2/2)
17-
========= =========== ===========
12+
+-----------+-------------+-------------+
13+
| | $x_value1 | $x_value2 |
14+
+===========+=============+=============+
15+
| $y_value1 | $value(1/1) | $value(2/1) |
16+
+-----------+-------------+-------------+
17+
| $y_value2 | $value(1/2) | $value(2/2) |
18+
+-----------+-------------+-------------+
1819

1920
where `value(n/n)` is editable.
2021

@@ -59,12 +60,6 @@ field_label_x_axis
5960
Use another field to display in the table header
6061
field_label_y_axis
6162
Use another field to display in the table header
62-
x_axis_clickable
63-
It indicates if the X axis allows to be clicked for navigating to the field
64-
(if it's a many2one field). True by default
65-
y_axis_clickable
66-
It indicates if the Y axis allows to be clicked for navigating to the field
67-
(if it's a many2one field). True by default
6863
field_value
6964
Show this field as value
7065
show_row_totals
@@ -73,10 +68,6 @@ show_row_totals
7368
show_column_totals
7469
If field_value is a numeric field, it indicates if you want to calculate
7570
column totals. True by default
76-
field_att_<name>
77-
Declare as many options prefixed with this string as you need for binding
78-
a field value with an HTML node attribute (disabled, class, style...)
79-
called as the `<name>` passed in the option.
8071

8172
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
8273
:alt: Try me on Runbot
@@ -92,7 +83,7 @@ data model and point to it from our wizard. The crucial part is that we fill
9283
the field in the default function::
9384

9485
from odoo import fields, models
95-
86+
9687
class MyWizard(models.TransientModel):
9788
_name = 'my.wizard'
9889

@@ -105,8 +96,8 @@ the field in the default function::
10596
return [
10697
(0, 0, {
10798
'name': 'Sample task name',
108-
'project_id': p.id,
109-
'user_id': u.id,
99+
'project_id': p.id,
100+
'user_id': u.id,
110101
'planned_hours': 0,
111102
'message_needaction': False,
112103
'date_deadline': fields.Date.today(),
@@ -132,26 +123,17 @@ Now in our wizard, we can use::
132123
</tree>
133124
</field>
134125

135-
Note that all values in the matrix must exist, so you need to create them
136-
previously if not present, but you can control visually the editability of
137-
the fields in the matrix through `field_att_disabled` option with a control
138-
field.
139126

140127
Known issues / Roadmap
141128
======================
142129

143-
* It would be worth trying to instantiate the proper field widget and let it render the input
144-
* Let the widget deal with the missing values of the full Cartesian product,
145-
instead of being forced to pre-fill all the possible values.
146-
* If you pass values with an onchange, you need to overwrite the model's method
147-
`onchange` for making the widget work::
130+
* Support extra attributes on each field cell via `field_extra_attrs` param.
131+
We could set a cell as not editable, required or readonly for instance.
132+
The `readonly` case will also give the ability
133+
to click on m2o to open related records.
134+
135+
* Support limit total records in the matrix. Ref: https://github.com/OCA/web/issues/901
148136

149-
@api.multi
150-
def onchange(self, values, field_name, field_onchange):
151-
if "one2many_field" in field_onchange:
152-
for sub in [<field_list>]:
153-
field_onchange.setdefault("one2many_field." + sub, u"")
154-
return super(model, self).onchange(values, field_name, field_onchange)
155137

156138
Bug Tracker
157139
===========
@@ -170,6 +152,9 @@ Contributors
170152
* Holger Brunn <hbrunn@therp.nl>
171153
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
172154
* Artem Kostyuk <a.kostyuk@mobilunity.com>
155+
* Simone Orsi <simone.orsi@camptocamp.com>
156+
* Timon Tschanz <timon.tschanz@camptocamp.com>
157+
173158

174159
Maintainer
175160
----------
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Copyright 2015 Holger Brunn <hbrunn@therp.nl>
22
# Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
3+
# Copyright 2018 Simone Orsi <simone.orsi@camptocamp.com>
34
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
45
{
56
"name": "2D matrix for x2many fields",
67
"version": "11.0.1.0.0",
78
"author": "Therp BV, "
89
"Tecnativa, "
10+
"Camptocamp, "
911
"Odoo Community Association (OCA)",
1012
"website": "https://github.com/OCA/web",
1113
"license": "AGPL-3",
@@ -15,10 +17,7 @@
1517
'web',
1618
],
1719
"data": [
18-
'views/templates.xml',
19-
],
20-
"qweb": [
21-
'static/src/xml/web_widget_x2many_2d_matrix.xml',
20+
'views/assets.xml',
2221
],
2322
"installable": True,
2423
}
-2.6 KB
Loading
2.99 KB
Loading
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
.oe_form_field_x2many_2d_matrix th.oe_link
2-
{
3-
cursor: pointer;
4-
}
5-
.oe_form_field_x2many_2d_matrix .oe_list_content > tbody > tr > td.oe_list_field_cell
6-
{
7-
white-space: normal;
1+
.o_field_x2many_2d_matrix .row-total {
2+
font-weight: bold;
83
}

0 commit comments

Comments
 (0)