Skip to Content
Menu
This question has been flagged
4 Replies
6129 Views

Hi,

I created a very simple module with the following model:

class Dossier(models.Model):
    _name = 'juridique.dossier'
    name = fields.Char(string='Nom')
    activity_ids = fields.Many2one('mail.activity', string='Activités')
    message_ids = fields.Many2one('mail.message', string='Messages')

Here is my juridique.dossier.view.form:

<?xml version="1.0"?>
<form string="Dossiers">
    <sheet>
      <div class="oe_title">
        <h1>
            <field name="name"/>
        </h1>
      </div>
    </sheet>
  </form>

and my herited view juridique.dossier.view.form.inherit.mail:

<?xml version="1.0"?>
<data>
      <xpath expr="//sheet" position="after">
        <div class="oe_chatter">
                        <field name="message_ids" widget="mail_thread"/>
        </div>
      </xpath>
</data>

When I launch the juridique.dossier.view.form I get this error:

TypeError: field is undefined
http://10.1.10.28:8069/web/content/1470-890bbfd/web.assets_backend.js:1299
...

Could you explain to me whats wrong in my code or view?

thanks in advance,

Bruno

Avatar
Discard
Author

I am using an Odoo 12

Author Best Answer

thanks, I can see the 'send message' and 'log note' items now

but I got an error in saving my record:

TypeError: messageIDs.slice is not a function

So the message_ids was wrong in the Dossier model:

message_ids = fields.One2many('mail.message', string='Messages')

instead of:

message_ids = fields.Many2one('mail.message', string='Messages')

Avatar
Discard
Best Answer

in your model you add this:         

                     _inherit = ['mail.thread', 'ir.needaction_mixin',]


​and in the view you add this : 


<div class = "oe_chatter"> <nom du champ = "message_follower_ids" widget = "mail_followers" /> <nom du champ = "message_ids" widget = "mail_thread" /> </ div>



Avatar
Discard
Best Answer

Hi,

Add these   'mail.thread' to your object.

_inherit =[ 'mail.thread']


Regards,

Silvestar

Avatar
Discard