[SOLVE] _track property of mail.thread, create messages on bottom form


Hi all,

My module is create a state (Approved) in "Sale" module and it worked. Now, I want to create a messages on bottom "sale.view_order_form", when the my custom state changed, as "Quotation created" and "Quotation confirmed"...

I use _track property of mail.thread same as "Sale" module. But it's not work, there has a error

Element '<record id="mt_order_approved" model="mail.message.subtype">' cannot be located in parent view

Please help me. Here is my code

In and, there is not problem

Here is

from openerp import fields, models, api

class sale_order(models.Model):
    extension to existing sale.order model
    _name = 'sale.order'
    _inherit = 'sale.order'
    _track = {
        'state': {
            'sale_extension.mt_order_approved': lambda self, cr, uid, obj, ctx=None: obj.state in ['quotation_approved'],
            'sale.mt_order_confirmed': lambda self, cr, uid, obj, ctx=None: obj.state in ['manual'],
            'sale.mt_order_sent': lambda self, cr, uid, obj, ctx=None: obj.state in ['sent']

    state = fields.Selection([
            ('draft', 'Draft Quotation'),
            ('quotation_approved', "Quotation Approved"),
            ('sent', 'Quotation Sent'),
            ('cancel', 'Cancelled'),
            ('waiting_date', 'Waiting Schedule'),
            ('progress', 'Sales Order'),
            ('manual', 'Sale to Invoice'),
            ('shipping_except', 'Shipping Exception'),
            ('invoice_except', 'Invoice Exception'),
            ('done', 'Done'),
            ], 'Status', readonly=True, copy=False, help="Gives the status of the quotation or sales order.\
              \nThe exception status is automatically set when a cancel operation occurs \
              in the invoice validation (Invoice Exception) or in the picking list process (Shipping Exception).\nThe 'Waiting Schedule' status is set when the invoice is confirmed\
               but waiting for the scheduler to run on the order date.", select=True)
    def action_quotation_approve(self):
        self.state =  'quotation_approved'
        return True

And here is sale_order_view.xml

<?xml version="1.0" encoding="utf-8"?>
    <data noupdate="1">
        <record id="my_quotation_form" model="ir.ui.view">
            <field name="name">sale.order.form</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="priority">1</field>
            <field name="arch" type="xml">

                    <button name="action_quotation_send" position="before">
                        <button name="approve_quotation" string="Approve" states="draft"
                            type="workflow" class="oe_highlight" groups="base.group_user"/>
                    <field name="state" position="attributes">
                        <attribute name="statusbar_visible">draft,quotation_approved,sent,progress,done</attribute>

<!-- Sale-related subtypes for messaging / Chatter -->

            <record id="mt_order_approved" model="mail.message.subtype">
                <field name="name">Quotation Approved</field>
                <field name="res_model">sale.order</field>
                <field name="default" eval="True"/>
                <field name="description">Quotation Approved</field>

            <!-- Salesteam-related subtypes for messaging / Chatter -->
            <record id="mt_salesteam_order_approved" model="mail.message.subtype">
                <field name="name">Quotation Approved</field>
                <field name="sequence">22</field>
                <field name="res_model"></field>
                <field name="parent_id" eval="ref('sale_extension.mt_order_approved')"/>
                <field name="relation_field">section_id</field>


1 Comment
Bonnet Denis

hy! You have tagged your question as SAOLVED but you didn't post a solution. Can you tell us how you did to solve your problem?

1 Answer
Best Answer

The solution is as above. I edited. I had two errors, but I fixed them.

1. I forgot add "noupdate="1" into the .xml file

2. Error record. My old code is


<!-- Sale-related subtypes for messaging / Chatter -->




<!-- Salesteam-related subtypes for messaging / Chatter -->