99This 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
1920where `value(n/n) ` is editable.
2021
@@ -59,12 +60,6 @@ field_label_x_axis
5960 Use another field to display in the table header
6061field_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
6863field_value
6964 Show this field as value
7065show_row_totals
@@ -73,10 +68,6 @@ show_row_totals
7368show_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
9283the 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
140127Known 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
156138Bug 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
174159Maintainer
175160----------
0 commit comments