odoo / odoo

Odoo. Open Source Apps To Grow Your Business.
https://www.odoo.com
Other
37.54k stars 24.42k forks source link

Set default record in one2many ! Impacts almost all versions #68008

Open nch-odoo opened 3 years ago

nch-odoo commented 3 years ago

When setting a default record in one2many field that has a many2many too. Odoo crashes when access from mobile browser (chrome) but works fine with desktop browser(chrome)

Impacted versions: Almost all. Tested in odoo 11CE

Steps to reproduce: Its just simple thing Create an object and add one o2m in it. That one2many should have one m2m in it. Now just set default_get method that sets default record in that one2many when you click 'add an item' the default get should also set that m2m in it. for eg:

 tmp_vals = {
                            'product_id': each_new_item.id,
                            'name': work_line_id.name,
                            'product_uom_qty': work_line_id.product_uom_qty,
                            'price_unit': work_line_id.price_unit,
                            'product_uom': work_line_id.product_uom.id,
                            'tax_id': [(6, 0, work_line_id.tax_id.ids)],
                            'product_type': 'service',
                            'state': 'new',
                            'discount':work_line_id.discount
                        }

Now if you access this it will work fine from your desktop but when accessed in mobile browser after activating debugging tools in android mobile settings. and access the same db from chrome you get this

Uncaught TypeError: Cannot read property 'views' of undefined
at Class._processX2ManyCommands (web.assets_backend.js:1274)
at web.assets_backend.js:1277
at Function._.each._.forEach (web.assets_common.js:12)
at Class._processX2ManyCommands (web.assets_backend.js:1275)
at Class.applyDefaultValues (web.assets_backend.js:1114)
at Object.<anonymous> (web.assets_backend.js:1264)
at Object.<anonymous> (web.assets_common.js:802)
at fire (web.assets_common.js:796)
at Object.fireWith [as resolveWith] (web.assets_common.js:801)
at Object.deferred.<computed> [as resolve] (web.assets_common.js:803

THE PROBLEM HERE IS THE tax_id FIELD IF YOU COMMENT IT OUT IT WORKS BUT THAT SHOULD WORK WITHOUT COMMENTING IT. Related issue and fix but that is not working
https://github.com/odoo/odoo/commit/034c075e7e58ad9e5a2dce34782106c0dbd1c786

Current behavior: crashes Expected behavior: should set default

nch-odoo commented 3 years ago

@mart-e

mart-e commented 3 years ago

As the error is only on mobile maybe @adr-odoo ?

adr-odoo commented 3 years ago

@nch-odoo Did you try to set a kanban view?