Hi everyone
I created a new model based on res.partner with delegation (_inherits).
I'm trying to inherit 'base.view_partner_form' to avoid copy/past most of the code and simply add/delete what a need. I think that it should works but I getting a very small javascript error message that I simply can't understand.
Model:
class MyModuleHospital(models.Model):
_name = "mymodule.hospital"
_inherits = {'res.partner': 'partner_id'}
_description = 'Hospital'
partner_id = fields.Many2one('res.partner', 'Related Partner',
required=True, ondelete="cascade", index=True, auto_join=True)
View:
<record id="view_hospital_form" model="ir.ui.view">
<field name="name">mymodule.hospital.form</field>
<field name="model">mymodule.hospital</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//form" position="attributes">
<attribute name="string">Hospital</attribute>
</xpath>
</field>
</record>
Error:
Uncaught TypeError: Widget is not a constructor
http://localhost:8069/web/static/src/js/views/basic/basic_renderer.js:577 Retraçage : TypeError: Widget is not a constructor at Class._renderFieldWidget (http://localhost:8069/web/static/src/js/views/basic/basic_renderer.js:577:22) at Class._renderInnerGroupField (http://localhost:8069/web/static/src/js/views/form/form_renderer.js:553:24) at http://localhost:8069/web/static/src/js/views/form/form_renderer.js:523:29 at Function._.each._.forEach (http://localhost:8069/web/static/lib/underscore/underscore.js:145:9) at Class._renderInnerGroup (http://localhost:8069/web/static/src/js/views/form/form_renderer.js:495:11) at Class._renderTagGroup (http://localhost:8069/web/static/src/js/views/form/form_renderer.js:723:25) at Class._renderNode [as _super] (http://localhost:8069/web/static/src/js/views/form/form_renderer.js:590:29) at Class._renderNode (http://localhost:8069/mail/static/src/js/form_renderer.js:66:32) at Class.<anonymous> (http://localhost:8069/web/static/src/js/core/class.js:123:38) at Class._renderNode (http://localhost:8069/mail_enterprise/static/src/js/form_renderer.js:93:32)
Look how to inherit model and views: http://learnopenerp.blogspot.com/2018/01/inheritance-in-models-and-views.html