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

Hi

i have a custom module for the sale.order.form , what i need is to add the child.ids of the selected partner.id as drop down list.

at below what i write, so please check and feed me back if that right or not?

in the .py

partner_id.child_ids = fields.Many2one('res.partner', string='Contact Person', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]},
domain=[('partner_id.child_ids', '=', False)])


in the view.xml

<data>
    <xpath expr="//field[@name='partner_id']" position="after">
<field name="partner_id.child_ids" domain="[('customer','=',True)]" context="{'search_default_customer':1}" options='{"always_reload": True}'/>
    </xpath>
</data>


report_templates.xml

<span t-field="doc.partner_id.child_ids"/>



Аватар
Отменить

Try this domain : domain=lambda self: [('model_id', '=', self.parent_id.id)]

Автор Лучший ответ

Dear All,

i tried your solutions, but it gives me an error related to another field in the view.xml file , actually i don't know why because I'm not a developer.

now, i will trying another solution as following and i will feed you back.


in report_templates.xml

<t t-if="doc.partner_id.child_ids">
    <t t-if="doc.partner_id.child_ids.type == 'Contact'">
        <span t-field="doc.partner_id.child_ids.name"/>
    </t>
</t>

this solution required to set only one child_ids as contact in the types


appreciate your cooperation


Аватар
Отменить
Лучший ответ

Remove domain from .py file,

and modify domain in .xml file as,

domain="[('customer', '=', True),('parent_id', '=', partner_id)]"

Аватар
Отменить
Лучший ответ
Hi Ayman Gabr,
 
Change this code.
 
Python:
 partner_id_child_ids = fields.Many2one('res.partner', string='Contact Person', domain=[('parent_id', '=', self.partner_id)])
Xml:
 
 <xpath expr="//field[@name='partner_id']" position="after">
<field name="partner_id_child_ids" domain="[('customer','=',True)]" context="{'search_default_customer':1}" options='{"always_reload": True}'/>
 </xpath>
 
Thank you.
Аватар
Отменить

Where are there such files?
I'm using Odoo (Studio) online and have seen no buttons for editing code.

Related Posts Ответы Просмотры Активность
2
мар. 22
6476
1
нояб. 19
7223
2
июл. 24
1869
0
мар. 15
4565
2
июн. 20
3256