Skip to content

Commit 18d79c5

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 18d79c5

File tree

13 files changed

+617
-502
lines changed

13 files changed

+617
-502
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: 15 additions & 21 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

@@ -92,7 +93,7 @@ data model and point to it from our wizard. The crucial part is that we fill
9293
the field in the default function::
9394

9495
from odoo import fields, models
95-
96+
9697
class MyWizard(models.TransientModel):
9798
_name = 'my.wizard'
9899

@@ -105,8 +106,8 @@ the field in the default function::
105106
return [
106107
(0, 0, {
107108
'name': 'Sample task name',
108-
'project_id': p.id,
109-
'user_id': u.id,
109+
'project_id': p.id,
110+
'user_id': u.id,
110111
'planned_hours': 0,
111112
'message_needaction': False,
112113
'date_deadline': fields.Date.today(),
@@ -140,18 +141,8 @@ field.
140141
Known issues / Roadmap
141142
======================
142143

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::
148-
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)
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.
155146

156147
Bug Tracker
157148
===========
@@ -170,6 +161,9 @@ Contributors
170161
* Holger Brunn <hbrunn@therp.nl>
171162
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
172163
* Artem Kostyuk <a.kostyuk@mobilunity.com>
164+
* Simone Orsi <simone.orsi@camptocamp.com>
165+
* Timon Tschanz <timon.tschanz@camptocamp.com>
166+
173167

174168
Maintainer
175169
----------
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)