Skip to Content
Menu
This question has been flagged
2 Replies
8479 Views

class LmcPhone(models.Model):

    _name = 'lmc.phone'

     partner_phone = fields.Char(string="Phone")

     partner_mobile = fields.Char(string="Mobile")

     email = fields.Char()

#add phone,email,mobile in res.partner in create method.

    @api.model

    def create(self, vals):

        if vals['partner_id']:

            record_set_partner = self.env['res.partner'].browse(vals['partner_id'])

            record_set_partner.email = vals['email']

            record_set_partner.phone = vals['partner_phone']

            record_set_partner.mobile = vals['partner_mobile']

        result = super(LmcPhone, self).create(vals)

        return result


Notes

How to add email,phone,mobile in res.partner in write method(Edit mode)?Thanks in advance.Please help how to get the answer.



Avatar
Discard
Author

I am sorry for adding partner_id in question

partner_id = fields.Many2one('res.partner', string="Client")

Author

dear juan

i don't get the correct answer using this method. i think it's need to override the write method.

Best Answer

your code

.........

result = super(LmcPhone, self).create(vals)

partner_obj = self.env['res.partner'].browse(
vals['partner_id'])
partner_obj.write({'phone':
vals['partner_phone'], 'mobile': vals['partner_mobile']})

return result

Kind regards,
Juanvi

Avatar
Discard
Related Posts Replies Views Activity
8
Apr 23
15822
1
Nov 17
2957
2
Dec 16
4825
2
Jan 16
34004
2
Mar 15
3942