Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
8337 Vizualizări

if user write only in comment then write current datetime in field.


_inherit = "res.partner"

_columns = {

'comment_date' : fields.datetime("comment_date")

}

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

    d = datetime.now().date()

    currentdate=time.strftime('%Y-%m-%d')

    partner_obj = self.pool.get('res.partner')

    res = super(res_partner, self).write(cr, uid, ids,vals, context=context)

    if vals['comment']:

    p_id = partner_obj.browse(cr, uid,ids, context=context)

    partner_obj.write(cr, uid,p_id, {'comment_date': currentdate},context=context)

return res

Imagine profil
Abandonează
Cel mai bun răspuns

Hello Vijay,


Try this :-

class Partner(models.Model):

     _inherit = 'res.partner'


     comment_date = fields.datetime('Comment Time')

 

    @api.multi

    def write(self, vals):

         res = super(Partner, self).write(vals)

         if vals.get('comment'):

             res.comment_date = fields.datetime.now()

        return res


Hope it works for you.

Thanks,

Imagine profil
Abandonează

Why used api.multi? decorator

Above code in new api. which version are u used ??

Related Posts Răspunsuri Vizualizări Activitate
0
mar. 25
1292
0
ian. 25
3398
1
aug. 23
14717
1
aug. 23
13316
1
iul. 23
10352