Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
15310 Представления

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
3832
2
мар. 15
4846
1
мар. 15
4628
1
мая 24
2562
2
сент. 23
2265