简体   繁体   中英

integration of OpenChatter and OpenERP custome module erro

I have Created a Module with a form and few fields. I want add an comment like system, (Chatter in OpenERP), How to easily add chatter to my module.

Give me the code snippet and let me know where to place it my form

My XML file is

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<!-- action windows -->
    <record model="ir.actions.act_window" id="course_list_action">
        <field name="name">Questions form</field>
        <!--<field name="date_of_q_created">Date of Q xml</field>-->
        <field name="res_model">openacademy.course</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="help" type="html">
        <p class="oe_view_nocontent_create">Create the first Question</p>
        </field>
    </record>

    <record model="ir.ui.view" id="course_form_view">
      <field name="name">course.form</field>
      <field name="model">openacademy.course</field>
      <field name="arch" type="xml">

      <form string="Questions Form">

      <field name="name" colspan="4" />
      <field name="description" colspan="4" />
      <field name="date_of_q_created" colspan="4" />
      <field name="category_question" colspan="4" />
      <field name="create_uid" colspan="4" />

      <field name="message_ids" colspan="4" widget="mail_thread" nolabel="1"/>
      </form>
      </field>


     </record>

<!-- menuitems -->
    <menuitem id="main_openacademy_menu" name="Manage forum" />
        <menuitem id="openacademy_menu" name="Discussion Forum" parent="main_openacademy_menu" />
        <menuitem id="courses_menu" name="Questions sidemenu" parent="openacademy_menu" action="course_list_action" />


</data>
</openerp>

my .py file is

import datetime
import time
import openerp
from openerp.osv import osv, fields


class Course(osv.Model):
    _name = "openacademy.course"


    _columns = {
              'name' : fields.char(string="Question Title", size=256, required=True),
              'description' : fields.text(string="Question Description", required=True),
              'date_of_q_created': fields.datetime('Date of Created'),
              'category_question': fields.many2one('openacademy.categ', 'Question Category'),
              'create_uid': fields.many2one('res.users', 'Question Created By', readonly=True),
                 }

class Course(osv.Model):
    _name = "openacademy.course"
    _inherit = ['mail.thread', 'ir.needaction_mixin']


class question_categ(osv.osv):
    _name='openacademy.categ'
    _description='category of Question'
    _columns={
       'name':fields.char('Create a Category type',size=100)
    }
question_categ()

but I am getting following error.

'You may need to add a dependency on the parent class\' module.' % (name, parent_name))
TypeError: The model "openacademy.course" specifies an unexisting parent class "mail.thread" You may need to add a dependency on the parent class' module.

Help me to get rid of this.. :-(

just simply add this tag to your form view after all the fields, <div class=”oe_chatter”> ... content of the bottom part ... </div> and I hope this will help you. for more details https://doc.openerp.com/trunk/server/form-view-guidelines/

try this in your xml,

   <div class="oe_chatter">
       <field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
       <field name="message_ids" widget="mail_thread"/>
   </div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM