openerp - what should I add to display the value of fields correctly? -


what should add display user_id , cat correctly

    @api.model      def create(self, vals):          record=super(test, self).create(vals)            if vals['total'] > 0:              vals['date'] = fields.datetime.now()                                      self.env['journal'].create({                  'user_id': record.patient_id,                  'cat': record.cat,})                  ....                  .....

on tree view (journal):

user_id displayed test.user(6,) cat displayed cat1

edits:

class test(models.model):      _name = 'test'      cat = fields.selection(          required=true,           related='test_type_cat.name',          store=true,            )      user_id = fields.many2one('res.users', string='user', readonly=true,)        .....            @api.model      def create(self, vals):                    record=super(test, self).create(vals)            if vals['total'] > 0:              vals['date'] = fields.datetime.now()                                      self.env['journal'].create({                  'patient_id': record.patient_id.name,                  'cat': record.cat,                  'user_id': record.user_id.name,                                         })              record.total = 0            return record

why work .name , not .id ? m2o field should pass integer value ? if case why work here .name ? , m2m , o2m?

this worked because creating record in model: journal not in test model.

and if go journal model find patient_id char field not many2one field.

so if pass: record.patient_id passing object , it's converted char why test(1,). because pateint_id many2one field in test model witch mean object.

hope clear thing little bit you.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -