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

Hi, 

i want to question .

I want to get 'field' in another object.

and, i want get field 'agreement_date' in object 'smcus.pjbs' to object 'smcus.pjp'

 file in object 'smcus.pjp' like :

class pjp(osv.osv):
    _name = 'smcus.pjp'

owner_date = self.pool.get('smcus.pjbs')

print '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!', owner_date.agreement_date

pjp()

==================================================================

in object 'smcus.pjbs' like :

class proses_jual_beli_sewa(osv.osv):
    _name = 'smcus.pjbs'
    _inherit = ['mail.thread']

    _columns = {
        'konversi_id': fields.many2one('smcus.pjbs.konversi', 'PJBS Konversi'),
        'agreement_date': fields.date('Tanggal Agreement'),
        'pjbs_name': fields.char('PJBS No.', size=64, required=False),

proses_jual_beli_sewa()

 

but the result is error :

Traceback (most recent call last):
  File "/home/heru/odoo/openerp-7.0/openerp-7.0-20150118/openerp/osv/osv.py", line 132, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/heru/odoo/openerp-7.0/openerp-7.0-20150118/openerp/osv/osv.py", line 199, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/heru/odoo/openerp-7.0/openerp-7.0-20150118/openerp/osv/osv.py", line 187, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/heru/odoo/openerp-7.0/openerp-7.0-20150118/openerp/osv/orm.py", line 3718, in read
    result = self._read_flat(cr, user, select, fields, context, load)
  File "/home/heru/odoo/openerp-7.0/openerp-7.0-20150118/openerp/osv/orm.py", line 3841, in _read_flat
    res2 = self._columns[f].get(cr, self, ids, f, user, context=context, values=res)
  File "/home/heru/odoo/openerp-7.0/openerp-7.0-20150118/openerp/osv/fields.py", line 1157, in get
    result = self._fnct(obj, cr, uid, ids, name, self._arg, context)
  File "/home/heru/odoo/addons/CENTURY21/smcus_cn_pjp/pjp.py", line 95, in _get_property_owner
    print '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!', owner_date.agreement_date
AttributeError: 'smcus.pjbs' object has no attribute 'agreement_date'

 

 

how i fix my problem ?

thanks in advance ...

 

Avatar
Discard

you must have to use function(on-change functional or functional field function) then only you will get agreement_date from smcus.pjbs object

Author

ok thanks gpkarthick ....

Best Answer

class pjp(osv.osv):
    _name = 'smcus.pjp'

owner_date = self.pool.get('smcus.pjbs').browse(cr,uid,ids)

val=owner_date.agreement_date

print '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!', val

pjp()

==================================================================

in object 'smcus.pjbs' like :

Use this code 

class proses_jual_beli_sewa(osv.osv):
    _name = 'smcus.pjbs'
    _inherit = ['mail.thread']

    _columns = {
        'konversi_id': fields.many2one('smcus.pjbs.konversi', 'PJBS Konversi'),
        'agreement_date': fields.date('Tanggal Agreement'),
        'pjbs_name': fields.char('PJBS No.', size=64, required=False),

proses_jual_beli_sewa()

Please upvote my answer if its correct

Avatar
Discard
Author

ok thank you very much LIBU ... it's work

Best Answer

From your code you are getting only the object of the module not values.you should browse the record first.then only you get the values in the record

owner_date_obj = self.pool.get('smcus.pjbs')

owner_date=owner_date_obj.browse(cr,uid,ids)

print '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!', owner_date.agreement_date

(Note: write these in a method)

Avatar
Discard
Author

ok thank you very much Vasanth .... it's work ...