Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

Integrate OpenChatter (mail.thread) in existing Model

By
Marvin Haß
on 1/6/15, 3:34 AM 3,908 views

Hello,

is it possible to integrate the OpenChatter (mail.thread) in an existing Model like stock.move?

 

Regards

2

Dhinesh - Technical Consultant, Sodexis Inc

--Dhinesh - Technical Consultant, Sodexis Inc--
3577
| 5 4 9
Pondicherry, India
--Dhinesh - Technical Consultant, Sodexis Inc--

Passionate coder in Python/OpenERP. Knows Django/Flask MVC frameworks. Did code in Java, PHP.

Contact me at: dvdhinesh.mail@gmail.com

Dhinesh - Technical Consultant, Sodexis Inc
On 1/6/15, 3:49 AM

Hi, This is a simple example. Add this _inherit = ['mail.thread', 'ir.needaction_mixin'] to stock.move in py:

class stock_move(models.Model):
    _name = "stock.move"
    _inherit = ['stock.move','mail.thread', 'ir.needaction_mixin']

In xml:

Add this before to your end of form tag:
<div class="oe_chatter">
    <field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
    <field name="message_ids" widget="mail_thread"/>
</div>

To track changes in your field, you may want to use track visiblity. You can find detail here....

1
Marvin Haß
On 1/6/15, 3:56 AM

I'm working in Version 7.

class stock_move(osv.osv):
    _name = "stock.move"
    _inherit = ['mail.thread', 'ir.needaction_mixin']

Raises:

Traceback (most recent call last):
  File "/home/marvin/dev/erp-dev/7.0/parts/odoo/openerp/cli/server.py", line 97, in preload_registry
    db, registry = openerp.pooler.get_db_and_pool(dbname,update_module=update_module)
  File "/home/marvin/dev/erp-dev/7.0/parts/odoo/openerp/pooler.py", line 33, in get_db_and_pool
    registry = RegistryManager.get(db_name, force_demo, status, update_module)
  File "/home/marvin/dev/erp-dev/7.0/parts/odoo/openerp/modules/registry.py", line 203, in get
    update_module)
  File "/home/marvin/dev/erp-dev/7.0/parts/odoo/openerp/modules/registry.py", line 233, in new
    openerp.modules.load_modules(registry.db, force_demo, status, update_module)
  File "/home/marvin/dev/erp-dev/7.0/parts/odoo/openerp/modules/loading.py", line 351, in load_modules
    force, status, report, loaded_modules, update_module)
  File "/home/marvin/dev/erp-dev/7.0/parts/odoo/openerp/modules/loading.py", line 256, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
  File "/home/marvin/dev/erp-dev/7.0/parts/odoo/openerp/modules/loading.py", line 165, in load_module_graph
    init_module_models(cr, package.name, models)
  File "/home/marvin/dev/erp-dev/7.0/parts/odoo/openerp/modules/module.py", line 374, in init_module_models
    result = obj._auto_init(cr, {'module': module_name})
  File "/home/marvin/dev/erp-dev/7.0/parts/odoo/openerp/osv/orm.py", line 3114, in _auto_init
    self._o2m_raise_on_missing_reference(cr, f)
  File "/home/marvin/dev/erp-dev/7.0/parts/odoo/openerp/osv/orm.py", line 3419, in _o2m_raise_on_missing_reference
    raise except_orm('Programming Error', "There is no reference field '%s' found for '%s'" % (f._fields_id, f._obj,))
except_orm: ('Programming Error', "There is no reference field 'sale_line_id' found for 'stock.move'")

######################

class my_stock_move(osv.osv):
    _inherit = ['stock.move', 'mail.thread', 'ir.needaction_mixin']

Raises:

Traceback (most recent call last):
  File "/home/marvin/dev/erp-dev/7.0/parts/odoo/openerp/cli/server.py", line 97, in preload_registry
    db, registry = openerp.pooler.get_db_and_pool(dbname,update_module=update_module)
  File "/home/marvin/dev/erp-dev/7.0/parts/odoo/openerp/pooler.py", line 33, in get_db_and_pool
    registry = RegistryManager.get(db_name, force_demo, status, update_module)
  File "/home/marvin/dev/erp-dev/7.0/parts/odoo/openerp/modules/registry.py", line 203, in get
    update_module)
  File "/home/marvin/dev/erp-dev/7.0/parts/odoo/openerp/modules/registry.py", line 233, in new
    openerp.modules.load_modules(registry.db, force_demo, status, update_module)
  File "/home/marvin/dev/erp-dev/7.0/parts/odoo/openerp/modules/loading.py", line 351, in load_modules
    force, status, report, loaded_modules, update_module)
  File "/home/marvin/dev/erp-dev/7.0/parts/odoo/openerp/modules/loading.py", line 256, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
  File "/home/marvin/dev/erp-dev/7.0/parts/odoo/openerp/modules/loading.py", line 161, in load_module_graph
    models = pool.load(cr, package)
  File "/home/marvin/dev/erp-dev/7.0/parts/odoo/openerp/modules/registry.py", line 118, in load
    model = cls.create_instance(self, cr)
  File "/home/marvin/dev/erp-dev/7.0/parts/odoo/openerp/osv/orm.py", line 898, in create_instance
    raise TypeError('_name is mandatory in case of multiple inheritance')
TypeError: _name is mandatory in case of multiple inheritance

 

I have updated my answer. Put _name = "stock.move" and try again.

Dhinesh - Technical Consultant, Sodexis Inc
on 1/6/15, 5:33 AM

Thanks! It works! I have not enough karma to vote or to mark my question as answerd... Stupid!

Marvin Haß
on 1/6/15, 5:38 AM

Karma restrictions have been changed now due to spammers. I have upvoted your question so that you can get minimum points.

Dhinesh - Technical Consultant, Sodexis Inc
on 1/8/15, 9:53 PM
0

Ivan

--Ivan--
3210
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
On 1/6/15, 4:26 AM

@Dhinesh forgets to put 'stock.move' in the _inherit.  It should be _inherit = ['stock.move', 'mail.thread', 'ir.needaction_mixin'].  Well, to get the discussion thread _inherit = ['stock.move', 'mail.thread'] would suffice.  The 'ir.needaction_mixin' is used more for validation feature (if an action is needed for this record).

Thanks. I forget to add 'stock.move' in _inherit.

Dhinesh - Technical Consultant, Sodexis Inc
on 1/6/15, 5:30 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/6/15, 3:34 AM
Seen: 3908 times
Last updated: 5/28/15, 9:10 AM