Browse Source

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

pull/161/head
Thibault Francois 7 years ago
committed by Cyrille Bollu
parent
commit
2204a8098d
  1. 4
      beesdoo_easy_my_coop/__openerp__.py
  2. 19
      beesdoo_easy_my_coop/models/res_partner.py
  3. 11
      beesdoo_easy_my_coop/views/partner.xml

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>
Loading…
Cancel
Save