跳至內容
選單
此問題已被標幟
2 回覆
15311 瀏覽次數

Hi Again,

I have this code and works fine, but i need get default value to wpartner_id when the form is open to create a new record.

'wpartner_id': fields.related('incidencia_id', 'partner_id', type="many2one", relation="res.partner", string="Cliente Incidencia", store=True),

How can i do it ?

頭像
捨棄
最佳答案

Hi Francisco,

_get_default_wpartner is a function that returns default wpartner.

def _get_default_wpartner(self, cr, uid, context=None):
        your code
        your condition
        #Something like Following
        domain = [] # condition
        res = self.pool.get('res.partner').search(cr, uid, domain, limit=1)
    return res and res[0] or False

Hope it work for you.

頭像
捨棄

How to add or load only same project task in current task form?

Ex.

i have one task and i want to check it's depending task

from same project so how i can load only same project task

最佳答案

Hi,

define defaut value of incidencia_id then wpartner_id will be automatically assigned.

so in _defaults :

 _defaults = {
             'wpartner_id': _get_default_wpartner,
             }
頭像
捨棄
作者

I get this error: NameError: name '_get_default_wpartner' is not defined ... i Need a function to get the relared default value??

this is normal ! _get_default_wpartner : is a function that return the default wpartner. you can define it in your model

作者

Thx Bordi, But this is not my problem, now i try to explain it better: when i open a form with a exist record this return de wpartner_id well, the problem is when y try to open a form with a new empty record, wpartner_id is empty, and i need get the related partner_id value from res.partner as default to use on domain in many2one selection field.

相關帖文 回覆 瀏覽次數 活動
0
3月 15
3833
2
3月 15
4846
1
3月 15
4628
1
5月 24
2562
2
9月 23
2265