python - Restrict records of a model [Odoo] -
i need list partners in 1 views used model 'res.partner'.
<record id="view_res_partner_tree" model="ir.ui.view"> <field name="name">res.partner.tree</field> <field name="model">res.partner</field> <field name="arch" type="xml"> <tree string="contacts" edit="false" create="false" delete="false"> <field name="display_name"/> <button name="generate" type="object" string="générer" icon="oe_highlight"/> </tree> </field> </record>
this works every partners listed. list partners got services. (custom module services)
i have done in xml like:
domain="[('display_name', 'in', 'select display_name module_services')]"
do know how perform this?
edit: added model ('res.partner')
got_services = fields.boolean('got services', compute='_compute_services') @api.multi def _compute_services(self): record in self: self.env.cr.execute("select * module_service id = %d;" % record.id) res = self.env.cr.fetchall() record.got_services = false if not res else true
and modified view:
[...] <field name="display_name" domain="[('got_services', '=', true)]"/> <field name="got_services"/> [...]
got_services set true if customer got services (good) customers listed anyway domain.
i think need define new field in res.partner model according request.
you may create one2many corresponding field res_partner_id in custom_services model (i guess many2one field), can domain filters easily.
Comments
Post a Comment