[18.0][BUG] web_widget_x2many_2d_matrix: not support monetary field
Module
web_widget_x2many_2d_matrix
Describe the bug
I think this module still does not support the Monetary type. I found two issues:
show_row_totalsandshow_column_totalsdo not display with the currency symbol.- After activate Developer Mode, fields of type
Monetaryusing thex2many_2d_matrixwidget cannot be opened.
To Reproduce
Affected versions: 18.0
Steps to reproduce the behavior:
- Coding with widget
x2many_2d_matrix
python file
date_range_id = fields.Many2one(comodel_name="date.range",)
kpi_id = fields.Many2one(comodel_name="budget.kpi",)
amount = fields.Monetary()
currency_id = fields.Many2one(comodel_name="res.currency")
xml file
<field
name="line_ids"
widget="x2many_2d_matrix"
field_x_axis="date_range_id"
field_y_axis="kpi_id"
field_value="amount"
readonly="state not in ['draft', 'submit']"
>
<list limit="1000000">
<field name="date_range_id" />
<field name="kpi_id" />
<field name="amount" />
<field name="currency_id" column_invisible="1" />
</list>
</field>
- After activate developer mode it can't open this document.
UncaughtPromiseError > OwlError
Uncaught Promise > Invalid props for component 'MonetaryField': unknown key 'canCreate', unknown key 'canOpen', unknown key 'canWrite', unknown key 'canQuickCreate', unknown key 'canCreateEdit'
Occured on localhost:18069 on 2025-03-26 10:26:42 GMT
OwlError: Invalid props for component 'MonetaryField': unknown key 'canCreate', unknown key 'canOpen', unknown key 'canWrite', unknown key 'canQuickCreate', unknown key 'canCreateEdit'
Error: Invalid props for component 'MonetaryField': unknown key 'canCreate', unknown key 'canOpen', unknown key 'canWrite', unknown key 'canQuickCreate', unknown key 'canCreateEdit'
at Object.validateProps (http://localhost:18069/web/assets/e2287b2/web.assets_web.min.js:1188:67)
at X2Many2DMatrixRenderer.template (eval at compile (http://localhost:18069/web/assets/e2287b2/web.assets_web.min.js:1563:421), <anonymous>:61:21)
at Fiber._render (http://localhost:18069/web/assets/e2287b2/web.assets_web.min.js:985:96)
at Fiber.render (http://localhost:18069/web/assets/e2287b2/web.assets_web.min.js:984:6)
at ComponentNode.initiateRender (http://localhost:18069/web/assets/e2287b2/web.assets_web.min.js:1054:47)
Expected behavior
- The sum total should be displayed with the currency symbol.
- It should activate developer mode should not cause an error.
Can confirm, in debug mode the error above is thrown.
Hi @Saran440 , thank you for reporting this bug, I had the same issue in debug mode only, for Float field. That issue has been solved for me with https://github.com/OCA/web/pull/3203, thanks @hbrunn for that !
Can you check if this issue is also solved for you use case with Monetary fields ?
@remi-filament Thank you for remind me.
Tested, it still not support monetory field in total. but solved in case debug mode 👍
However, I change my code to float already.
closing this as OP has worked around the issue.
For posterity: To solve this, I guess we have to add the company/currency field to the synthetic record created in https://github.com/OCA/web/blob/18.0/web_widget_x2many_2d_matrix/static/src/components/x2many_2d_matrix_renderer/x2many_2d_matrix_renderer.esm.js#L163, probably extracted from the first real record available, assuming those fields are the same for the whole matrix