Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
15305 Vizualizări

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 ?

Imagine profil
Abandonează
Cel mai bun răspuns

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.

Imagine profil
Abandonează

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

Cel mai bun răspuns

Hi,

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

so in _defaults :

 _defaults = {
             'wpartner_id': _get_default_wpartner,
             }
Imagine profil
Abandonează
Autor

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

Autor

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 Răspunsuri Vizualizări Activitate
0
mar. 15
3829
2
mar. 15
4845
1
mar. 15
4627
1
mai 24
2561
2
sept. 23
2265