Skip to Content
Menu
This question has been flagged
1 Reply
2656 Views

hi iam getting this error while pressing action_send function 


code:


    #@api.model

    def create(self, vals):

        number = self.env['ir.sequence'].next_by_code('project.work.sequence')

        vals.update({

            'number': number,

            })

        return super(ProjectWorkPackage, self).create(vals)




    def action_send(self, vals):

        self.ensure_one()

        ir_model_data = self.env['ir.model.data']

        try:

            template_id = self.env.ref('job_costing_work_package.email_work_packages_templates').id

        except ValueError:

            template_id = False

        try:

            compose_form_id = self.env.ref('mail.email_compose_message_wizard_form').id

        except ValueError:

            compose_form_id = False

        ctx = {

            'default_model': 'project.work.package',

            'default_res_id': self.ids[0],

            'default_use_template': bool (template_id),

            'default_template_id': template_id,

            'default_composition_mode': 'comment',

            'mark_so_as_sent': True,

            'force_email': True

        }

        self.state = 'sent'

        return {

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

            'view_mode': 'form',

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

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

            'view_id': compose_form_id,

            'target': 'new',

            'context': ctx,

        }



error:

  File "/odoo/odoo_13/odoo/api.py", line 374, in _call_kw_multi
    result = method (recs, * args, ** kwargs)
TypeError: action_send () missing 1 required positional argument: 'vals'
Avatar
Discard
Author

anyone

Best Answer

Hi,

    I guess you need to remove vals in your def action_send(self):   

1. vals is of type dictionary which stores your current records as key and value pair.

    name (key) = fields.Char(string="Name") // Value is your data given in front end.

2. In your def create function there is a parameter vals,  //def create(self, vals):

3. There your are (returning) passing value for the parameter vals at the end //return super(ProjectWorkPackage, self).create(vals)

4. But in your action_send you are returning an act_window ie an action. so i guess there is no value passed for the parameter vals in your def action_send. Thats what your error says.

Hope it helps,

Thanks


Avatar
Discard