Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
8810 Lượt xem

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"/>



Ảnh đại diện
Huỷ bỏ

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

Tác giả Câu trả lời hay nhất

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


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Remove domain from .py file,

and modify domain in .xml file as,

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất
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.
Ảnh đại diện
Huỷ bỏ

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 3 22
6554
1
thg 11 19
7286
2
thg 7 24
1926
0
thg 3 15
4615
2
thg 6 20
3278