Browse Source

[FIX] use existing field for cooperator type + [CLEAN] hide useless tab for physical person

pull/18/head
Thibault Francois 8 years ago
parent
commit
4d02b63623
  1. 2
      beesdoo_base/models/partner.py
  2. 7
      beesdoo_base/views/partner.xml
  3. 4
      beesdoo_easy_my_coop/__openerp__.py
  4. 19
      beesdoo_easy_my_coop/models/res_partner.py
  5. 11
      beesdoo_easy_my_coop/views/partner.xml
  6. 2
      beesdoo_shift/views/cooperative_status.xml

2
beesdoo_base/models/partner.py

@ -20,7 +20,7 @@ class Partner(models.Model):
member_card_to_be_printed = fields.Boolean('Print BEES card?')
last_printed = fields.Datetime('Last printed on')
share_type = fields.Selection([('share_a', 'Share A'), ('share_b', 'Share B'), ('share_c', 'Share C')])
cooperator_type = fields.Selection([('share_a', 'Share A'), ('share_b', 'Share B'), ('share_c', 'Share C')], store=True, compute=None)
@api.onchange('first_name', 'last_name')

7
beesdoo_base/views/partner.xml

@ -27,12 +27,15 @@
default_focus="1" />
</field>
<field name="website" position="after">
<field name="share_type" invisible="1"/>
<field name="cooperator_type"/>
<field name="eater" attrs="{'invisible': [('customer', '=', False)]}" />
<field name="parent_eater_id" attrs="{'invisible' : [('eater', '!=', 'eater')]}" />
</field>
<xpath expr="//notebook/page[1]" position="attributes">
<attribute name="attrs">{'invisible': [('cooperator_type', '=', 'share_a')]}</attribute>
</xpath>
<xpath expr="//notebook" position="inside">
<page string="Worker information" attrs="{'invisible': [('share_type', '!=', 'share_a')]}" name="work">
<page string="Worker information" attrs="{'invisible': [('cooperator_type', '!=', 'share_a')]}" name="work">
<group name="info_session" />
</page>
<page string="Member Card"

4
beesdoo_easy_my_coop/__openerp__.py

@ -19,12 +19,14 @@
'version': '1.0',
# any module necessary for this one to work correctly
'depends': ['beesdoo_base', 'beesdoo_shift', 'easy_my_coop'],
'depends': ['beesdoo_base', 'beesdoo_shift', 'easy_my_coop', ],
# always loaded
'data': [
'data/product_share.xml',
'views/partner.xml',
],
'auto_install': True,
# only loaded in demonstration mode
}

19
beesdoo_easy_my_coop/models/res_partner.py

@ -4,11 +4,24 @@ from openerp import models, fields, api, _
class Partner(models.Model):
_inherit = 'res.partner'
share_type = fields.Selection(compute='_get_share_product_type')
cooperator_type = fields.Selection(selection='_get_share_type', compute='_compute_share_type', string='Cooperator Type', store=True)
@api.multi
@api.depends('share_ids', 'share_ids.share_product_id', 'share_ids.share_product_id.default_code')
def _get_share_product_type(self):
def _compute_share_type(self):
for rec in self:
codes = rec.share_ids.mapped('share_product_id.default_code')
rec.share_type = codes[0] if codes else ''
rec.cooperator_type = codes[0] if codes else ''
@api.multi
def _get_share_type(self):
share_type_list = [('','')]
for share_type in self.env['product.product'].search([('is_share','=',True)]):
share_type_list.append((share_type.default_code, share_type.short_name))
return share_type_list
@api.noguess
def _auto_init(self, cr, context=None):
cr.execute("ALTER TABLE res_partner DROP COLUMN IF EXISTS cooperator_type")
res = super(Partner, self)._auto_init(cr, context=context)
return res

11
beesdoo_easy_my_coop/views/partner.xml

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record model="ir.ui.view" id="beesdoo_partner_form_view_remove_duplicate_cooperator_type">
<field name="name">beesdoo.partner.form.view.remove_duplicate_cooperator_type</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="beesdoo_base.beesdoo_partner_form_view" />
<field name="arch" type="xml">
<field name="cooperator_type" position="replace" />
</field>
</record>
</odoo>

2
beesdoo_shift/views/cooperative_status.xml

@ -8,7 +8,7 @@
<header>
<button name="coop_subscribe" string="Subscribe to shift" class="oe_highlight"
type="object" groups="beesdoo_shift.group_shift_management"
attrs="{'invisible': [('share_type', '!=', 'share_a')]}"/>
attrs="{'invisible': [('cooperator_type', '!=', 'share_a')]}"/>
</header>
</xpath>
<page name="work" position="inside">

Loading…
Cancel
Save