Browse Source

[ADD] easy_my_coop: representative_of_member_company

pull/126/head
Manuel Claeys Bouuaert 4 years ago
parent
commit
4eb89729fd
  1. 20
      easy_my_coop/models/partner.py
  2. 2
      easy_my_coop/view/res_partner_view.xml

20
easy_my_coop/models/partner.py

@ -141,6 +141,11 @@ class ResPartner(models.Model):
compute=_compute_effective_date, compute=_compute_effective_date,
store=True) store=True)
representative = fields.Boolean(string="Legal Representative") representative = fields.Boolean(string="Legal Representative")
representative_of_member_company = fields.Boolean(
string="Legal Representative of Member Company",
store=True,
compute="_compute_representative_of_member_company",
)
subscription_request_ids = fields.One2many('subscription.request', subscription_request_ids = fields.One2many('subscription.request',
'partner_id', 'partner_id',
string="Subscription request") string="Subscription request")
@ -172,6 +177,21 @@ class ResPartner(models.Model):
partner.coop_candidate = is_candidate partner.coop_candidate = is_candidate
@api.multi
@api.depends("parent_id", "representative")
def _compute_representative_of_member_company(self):
for partner in self:
member_companies = self.env["res.partner"].search(
[("is_company", "=", True), ("member", "=", True)]
)
partner.representative_of_member_company = (
partner in member_companies.mapped(
"child_ids"
).filtered(
"representative"
)
)
def has_representative(self): def has_representative(self):
if self.child_ids.filtered('representative'): if self.child_ids.filtered('representative'):
return True return True

2
easy_my_coop/view/res_partner_view.xml

@ -146,7 +146,7 @@
<field name="res_model">res.partner</field> <field name="res_model">res.partner</field>
<field name="view_type">form</field> <field name="view_type">form</field>
<field name="view_mode">kanban,tree,form</field> <field name="view_mode">kanban,tree,form</field>
<field name="domain">[('cooperator','=',True),('representative','=',True)]</field>
<field name="domain">[('representative_of_member_company','=',True)]</field>
<field name="filter" eval="True"/> <field name="filter" eval="True"/>
<field name="help" type="html"> <field name="help" type="html">
<p class="oe_view_nocontent_create"> <p class="oe_view_nocontent_create">

Loading…
Cancel
Save