Browse Source

[ADD] Can shop field on res.partner that take into account the cooperator type and the cooperator status

pull/53/head
Thibault Francois 7 years ago
parent
commit
1fd2a6a439
  1. 12
      beesdoo_easy_my_coop/models/res_partner.py
  2. 7
      beesdoo_easy_my_coop/views/partner.xml

12
beesdoo_easy_my_coop/models/res_partner.py

@ -5,6 +5,18 @@ class Partner(models.Model):
_inherit = 'res.partner' _inherit = 'res.partner'
cooperator_type = fields.Selection(selection='_get_share_type', compute='_compute_share_type', string='Cooperator Type', store=True) cooperator_type = fields.Selection(selection='_get_share_type', compute='_compute_share_type', string='Cooperator Type', store=True)
can_shop = fields.Boolean(compute='_can_shop', store=True)
@api.depends('cooperator_type', 'cooperative_status_ids', 'cooperative_status_ids.can_shop')
def _can_shop(self):
for rec in self:
if rec.cooperator_type == 'share_b':
rec.can_shop = True
elif rec.cooperative_status_ids and rec.cooperative_status_ids[0].can_shop:
rec.can_shop = True
else:
rec.can_shop = False
@api.multi @api.multi
@api.depends('share_ids', 'share_ids.share_product_id', 'share_ids.share_product_id.default_code', 'share_ids.share_number') @api.depends('share_ids', 'share_ids.share_product_id', 'share_ids.share_product_id.default_code', 'share_ids.share_number')

7
beesdoo_easy_my_coop/views/partner.xml

@ -27,9 +27,9 @@
</record> </record>
<record model="ir.ui.view" id="beesdoo_partner_form_view_remove_duplicate_header"> <record model="ir.ui.view" id="beesdoo_partner_form_view_remove_duplicate_header">
<field name="name">beesdoo.partner.form.view.remove_duplicate_cooperator_type</field>
<field name="name">beesdoo.partner.form.view.remove_duplicate_header</field>
<field name="model">res.partner</field> <field name="model">res.partner</field>
<field name="inherit_id" ref="beesdoo_base.beesdoo_partner_form_view" />
<field name="inherit_id" ref="beesdoo_shift.super_coop_partner_inherited_view_form" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="header" position="replace" /> <xpath expr="header" position="replace" />
<xpath expr="//field[@name='state']" position="before"> <xpath expr="//field[@name='state']" position="before">
@ -38,6 +38,9 @@
<button string="Update info" name="%(easy_my_coop.action_view_update_partner_info)d" <button string="Update info" name="%(easy_my_coop.action_view_update_partner_info)d"
type="action" context="{'default_active_id': active_id}" groups="easy_my_coop.group_energiris_manager"/> type="action" context="{'default_active_id': active_id}" groups="easy_my_coop.group_energiris_manager"/>
</xpath> </xpath>
<xpath expr="//field[@name='info_session']" position="before">
<field name="can_shop" />
</xpath>
</field> </field>
<field name="priority">99</field> <field name="priority">99</field>
</record> </record>

Loading…
Cancel
Save