Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
15385 มุมมอง

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.

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
มี.ค. 15
3878
2
มี.ค. 15
4866
1
มี.ค. 15
4678
1
พ.ค. 24
2618
2
ก.ย. 23
2346