Browse Source

[IMP] add a computed field coop_candidate and a menu item to display

company representative
pull/1/head
houssine 7 years ago
parent
commit
131b2a65d7
  1. 17
      easy_my_coop/models/partner.py
  2. 36
      easy_my_coop/view/res_partner_view.xml

17
easy_my_coop/models/partner.py

@ -96,6 +96,7 @@ class ResPartner(models.Model):
cooperator = fields.Boolean(string='Cooperator', help="Check this box if this contact is a cooperator(effective or not).") cooperator = fields.Boolean(string='Cooperator', help="Check this box if this contact is a cooperator(effective or not).")
member = fields.Boolean(string='Effective cooperator', help="Check this box if this cooperator is an effective member.") member = fields.Boolean(string='Effective cooperator', help="Check this box if this cooperator is an effective member.")
coop_candidate = fields.Boolean(string="Cooperator Candidate", compute="_compute_coop_candidate", store=True, readonly=True)
old_member = fields.Boolean(string='Old cooperator', help="Check this box if this cooperator is no more an effective member.") old_member = fields.Boolean(string='Old cooperator', help="Check this box if this cooperator is no more an effective member.")
gender = fields.Selection([('male', 'Male'), ('female', 'Female'), ('other', 'Other')], string='Gender') gender = fields.Selection([('male', 'Male'), ('female', 'Female'), ('other', 'Other')], string='Gender')
national_register_number = fields.Char(string='National Register Number') national_register_number = fields.Char(string='National Register Number')
@ -108,6 +109,22 @@ class ResPartner(models.Model):
cooperator_type = fields.Selection(selection='_get_share_type', compute='_compute_cooperator_type', string='Cooperator Type', store=True) cooperator_type = fields.Selection(selection='_get_share_type', compute='_compute_cooperator_type', string='Cooperator Type', store=True)
effective_date = fields.Date(sting="Effective Date", compute='_compute_effective_date', store=True) effective_date = fields.Date(sting="Effective Date", compute='_compute_effective_date', store=True)
representative = fields.Boolean(string="Legal Representative") representative = fields.Boolean(string="Legal Representative")
subscription_request_ids = fields.One2many('subscription.request', 'partner_id', string="Subscription request")
@api.multi
@api.depends('subscription_request_ids.state')
def _compute_coop_candidate(self):
for partner in self:
paid_sub_req = partner.subscription_request_ids.filtered(lambda record: record.state == 'paid')
if paid_sub_req:
is_candidate = False
else:
if len(partner.subscription_request_ids.filtered(lambda record: record.state != 'cancelled')) > 0:
is_candidate = True
else :
is_candidate = False
partner.coop_candidate = is_candidate
def has_representative(self): def has_representative(self):
if self.child_ids.filtered('representative'): if self.child_ids.filtered('representative'):

36
easy_my_coop/view/res_partner_view.xml

@ -22,6 +22,7 @@
<field name="company_register_number" readonly="True" attrs="{'invisible':[('is_company','=',False)]}"/> <field name="company_register_number" readonly="True" attrs="{'invisible':[('is_company','=',False)]}"/>
<field name="national_register_number" readonly="True" attrs="{'invisible':[('is_company','=',True)]}" groups="easy_my_coop.group_energiris_super_manager"/> <field name="national_register_number" readonly="True" attrs="{'invisible':[('is_company','=',True)]}" groups="easy_my_coop.group_energiris_super_manager"/>
<field name="cooperator" groups="easy_my_coop.group_energiris_super_manager"/> <field name="cooperator" groups="easy_my_coop.group_energiris_super_manager"/>
<field name="coop_candidate" groups="easy_my_coop.group_energiris_user"/>
<field name="member" groups="easy_my_coop.group_energiris_super_manager"/> <field name="member" groups="easy_my_coop.group_energiris_super_manager"/>
<field name="cooperator_type" attrs="{'invisible':[('member','=',False)]}"/> <field name="cooperator_type" attrs="{'invisible':[('member','=',False)]}"/>
<field name="effective_date" attrs="{'invisible':[('member','=',False)]}"/> <field name="effective_date" attrs="{'invisible':[('member','=',False)]}"/>
@ -47,6 +48,18 @@
</tree> </tree>
</field> </field>
</page> </page>
<page string="Share subscriptions" name="share_subscription" attrs="{'invisible':[('cooperator','=',False)]}" groups="easy_my_coop.group_energiris_user">
<field name="subscription_request_ids">
<tree create="false" delete="false" edit="false">
<field name="share_short_name"/>
<field name="ordered_parts" sum="Total of shares"/>
<field name="share_unit_price"/>
<field name="subscription_amount" sum="Total subscribed amount"/>
<field name="type"/>
<field name="state"/>
</tree>
</field>
</page>
</xpath> </xpath>
</field> </field>
</record> </record>
@ -108,7 +121,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),('member','=',False),('old_member','=',False)]</field>
<field name="domain">[('cooperator','=',True),('coop_candidate','=',True)]</field>
<field name="context">{'default_cooperator':1, 'search_default_cooperator':1}</field> <field name="context">{'default_cooperator':1, 'search_default_cooperator':1}</field>
<field name="filter" eval="True"/> <field name="filter" eval="True"/>
<field name="help" type="html"> <field name="help" type="html">
@ -123,5 +136,26 @@
</record> </record>
<menuitem id="menu_easy_my_coop_cooperator_candidate" name="Cooperator Candidates" parent="menu_easy_my_coop_main_coop" action="action_partner_cooperator_candidate_form" sequence="150"/> <menuitem id="menu_easy_my_coop_cooperator_candidate" name="Cooperator Candidates" parent="menu_easy_my_coop_main_coop" action="action_partner_cooperator_candidate_form" sequence="150"/>
<record id="action_company_representative_form" model="ir.actions.act_window">
<field name="name">Company representative</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="domain">[('cooperator','=',True),('representative','=',True)]</field>
<field name="filter" eval="True"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to add a contact in your address book.
</p><p>
OpenERP helps you easily track all activities related to
a cooperator: discussions, history of business opportunities,
documents, etc.
</p>
</field>
</record>
<menuitem id="menu_easy_my_coop_company_representative" name="Company representative" parent="menu_easy_my_coop_main_coop" action="action_company_representative_form" sequence="160"/>
</data> </data>
</openerp> </openerp>
Loading…
Cancel
Save