This question has been flagged
7592 Views

I added button(.xml) in my custom module for sending mail and i defined relevant definition in py file...

i defined my py in init file and xml in openerp correctly.


xml view:

=======

 <record id="student_attendance_form_view" model="ir.ui.view">

            <field name="name">example.model.form</field>

            <field name="model">example.model</field>

            <field name="arch" type="xml">

                <form string="Detailed List">

                <header>                    

                    <button name="send_mail_template" string="Send - Email" type="object" class="btn-primary"/>

                          </header>

<sheet>

                    <group>

   <field name="cus_name"  string="Name of person" />

 

                    </group>

</sheet>

                </form>

            </field>

        </record>

    

python file:

========

class zzz_my_module(models.Model):

 _name = 'example.model'

 cus_name = fields.Char()

def send_mail_template(self, cr, uid, ids, context=None):

        '''

        This function opens a window to compose an email, with the edi sale template message loaded by default

        '''

        ir_model_data = self.pool.get('ir.model.data')

        try:

            compose_form_id = ir_model_data.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')[1]

        except ValueError:

            compose_form_id = False

        ctx = dict()

        return {

            'type': 'ir.actions.act_window',

            'view_type': 'form',

            'view_mode': 'form',

            'res_model': 'mail.compose.message',

            'views': [(compose_form_id, 'form')],

            'view_id': compose_form_id,

            'target': 'new',

            'context': ctx,

        }

class mail_compose_message(models.Model):

    _inherit = 'mail.compose.message'

    '''

        This function send mail to respective customer

    '''

    def send_mail(self, cr, uid, ids, context=None):

        context = context or {}

        if context.get('default_model') == 'example.model' and context.get('default_res_id') and context.get('mark_so_as_sent'):

            context = dict(context, mail_post_autofollow=True)

            self.pool.get('example.model').signal_workflow(cr, uid, [context['default_res_id']], 'quotation_sent')

        return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context)


Error:

====

when i click that button, I got error like .

AttributeError: 'example.model' object has no attribute 'send_mail_template. Button is not meet relevant definition which is i defined on .py file... Anyone please help!!!!

Avatar
Discard