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.

2

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

By
NhuVanTran
on 2/24/15, 4:05 AM 2,053 views

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 __init__.py and __openerp__.py, there is not problem

Here is sale_extension.py

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)

@api.one
    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"?>
<openerp>
    <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"/>
                    </button>
                    <field name="state" position="attributes">
                        <attribute name="statusbar_visible">draft,quotation_approved,sent,progress,done</attribute>
                    </field>                 
            </field>
        </record>

<!-- 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>
            </record>

            <!-- 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">crm.case.section</field>
                <field name="parent_id" eval="ref('sale_extension.mt_order_approved')"/>
                <field name="relation_field">section_id</field>
            </record>

    </data>
</openerp>

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?

Bonnet Denis
on 2/24/15, 11:05 AM
0
NhuVanTran
On 2/24/15, 12:14 PM

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

<record>

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

      <record>

....something

     </record>

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

<record>

....something

     </record>

</record>

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: 2/24/15, 4:05 AM
Seen: 2053 times
Last updated: 11/12/15, 5:51 AM