web icon indicating copy to clipboard operation
web copied to clipboard

[18.0][BUG] web_widget_x2many_2d_matrix: not support monetary field

Open Saran440 opened this issue 9 months ago • 1 comments

Module

web_widget_x2many_2d_matrix

Describe the bug

I think this module still does not support the Monetary type. I found two issues:

  1. show_row_totals and show_column_totals do not display with the currency symbol.
  2. After activate Developer Mode, fields of type Monetary using the x2many_2d_matrix widget cannot be opened.

To Reproduce

Affected versions: 18.0

Steps to reproduce the behavior:

  1. 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>

Image

  1. 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

  1. The sum total should be displayed with the currency symbol.
  2. It should activate developer mode should not cause an error.

Saran440 avatar Mar 26 '25 10:03 Saran440

Can confirm, in debug mode the error above is thrown.

AyoubZahid avatar Apr 21 '25 16:04 AyoubZahid

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 avatar Jul 23 '25 08:07 remi-filament

@remi-filament Thank you for remind me.

Tested, it still not support monetory field in total. but solved in case debug mode 👍

Image

However, I change my code to float already.

Saran440 avatar Jul 23 '25 10:07 Saran440

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

hbrunn avatar Nov 14 '25 06:11 hbrunn