Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
8318 Zobrazení

Hello All,

For below code my boolean field not domain(searched) in database. It's work when i make this method depends. But i have above 1000 records so how to domain in action for all record simultaneously?

Python Code:

@api.multi
def _compute_opportunity_count111(self):
value = {}
for rec in self:
operator = 'child_of' if rec.is_company else '=' # the opportunity count should counts the opportunities of this company and all its contacts
won_list = rec.env['crm.lead'].search(
[('partner_id', operator, rec.id), ('stage_id.probability', '=', 100)]).ids
if won_list:
rec.won_customer = True
value.update(won_customer=rec.won_customer)

won_customer = fields.Boolean(compute='_compute_opportunity_count111'store=True)

XML Code:
<record id="base.action_partner_form" model="ir.actions.act_window">
<field name="name">Customers</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">res.partner</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,tree,form</field>
<field name="context">{"search_default_customer":1}</field>
<field name="domain">[('won_customer', '=', True)]</field>
<field name="search_view_id" ref="base.view_res_partner_filter"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to add a contact in your address book.
</p>
<p>
Odoo helps you easily track all activities related to
a customer: discussions, history of business opportunities,
documents, etc.
</p>
</field>
</record>

Thanks in advance

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
lis 22
3759
2
srp 22
8156
1
led 25
9917
1
zář 21
7163
1
bře 21
5965