Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to get 'field' in another object ?

By
heru
on 2/11/15, 8:00 PM 1,664 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 ...

 

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

gpkarthick
on 2/11/15, 10:53 PM

ok thanks gpkarthick ....

heru
on 2/12/15, 1:41 AM
1

Odoo

--Odoo --
1328
| 5 2 5
kerala, India
--Odoo --

Working as a Odoo Functional and Technical Expert

Odoo
On 2/12/15, 1:35 AM

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

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

heru
on 2/12/15, 1:44 AM
1

Vasanth

--Vasanth--
3458
| 5 3 8
Pondicherry, India
--Vasanth--
Vasanth
On 2/12/15, 12:33 AM

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)

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

heru
on 2/12/15, 1:45 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 2/11/15, 8:00 PM
Seen: 1664 times
Last updated: 5/5/16, 12:16 AM