forked from Yaltik/golem
[ADD]GOLEM families functional now, with filters, smart button from GOLEM member...
This commit is contained in:
parent
3f860bb095
commit
5f13c7e95e
@ -15,40 +15,63 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from openerp import models, fields
|
from openerp import models, fields, api, _
|
||||||
|
|
||||||
|
|
||||||
class ResPartner(models.Model):
|
class GolemMember(models.Model):
|
||||||
_inherit = 'res.partner'
|
_inherit = 'golem.member'
|
||||||
|
|
||||||
family_ids = fields.Many2many('golem.member.family',
|
family_count = fields.Integer('Family', compute='_compute_family_count')
|
||||||
string='Family member')
|
|
||||||
|
|
||||||
# @api.multi
|
@api.one
|
||||||
# def button_family_members(self):
|
def _compute_family_count(self):
|
||||||
# self.ensure_one()
|
pid = self.partner_id.id
|
||||||
# return {'name': _('Family Members'),
|
dmn = ['|', ('partnerfrom_id', '=', pid), ('partnerto_id', '=', pid)]
|
||||||
# 'type': 'ir.actions.act_window',
|
self.family_count = self.env['golem.member.family'].search_count(dmn)
|
||||||
# 'res_model': 'golem.member.family',
|
|
||||||
# 'view_mode': 'tree',
|
@api.multi
|
||||||
# 'domain': [('memberfrom_id', '=', self[0].id)]}
|
def button_family_members(self):
|
||||||
|
self.ensure_one()
|
||||||
|
pid = self.partner_id.id
|
||||||
|
return {'name': _('Family Members'),
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'res_model': 'golem.member.family',
|
||||||
|
'view_mode': 'tree',
|
||||||
|
'context': {'default_partnerfrom_id': pid},
|
||||||
|
'domain': ['|',
|
||||||
|
('partnerfrom_id', '=', pid),
|
||||||
|
('partnerto_id', '=', pid)]}
|
||||||
|
|
||||||
|
|
||||||
class GolemFamily(models.Model):
|
class GolemFamily(models.Model):
|
||||||
_name = 'golem.member.family'
|
_name = 'golem.member.family'
|
||||||
_description = 'GOLEM Member Family'
|
_description = 'GOLEM Member Family'
|
||||||
|
|
||||||
memberfrom_id = fields.Many2one('golem.member', 'Family member 1')
|
partnerfrom_id = fields.Many2one('res.partner', 'Family member from',
|
||||||
memberto_id = fields.Many2one('golem.member', string='Family member 2')
|
required=True, index=True,
|
||||||
|
domain=[('is_company', '=', False)])
|
||||||
|
partnerto_id = fields.Many2one('res.partner', 'Family member to',
|
||||||
|
required=True, index=True,
|
||||||
|
domain=[('is_company', '=', False)])
|
||||||
relation_id = fields.Many2one('golem.member.family.relation',
|
relation_id = fields.Many2one('golem.member.family.relation',
|
||||||
|
required=True, index=True,
|
||||||
string='Family relation')
|
string='Family relation')
|
||||||
|
fullrelation = fields.Char('Full relation string',
|
||||||
|
compute='_compute_fullrelation', store=True)
|
||||||
|
|
||||||
# @api.onchange('member_id')
|
@api.depends('partnerfrom_id', 'partnerto_id', 'relation_id')
|
||||||
# def onchange_member_id(self):
|
def _compute_fullrelation(self):
|
||||||
# mid = self.env.context.get('default_member_id')
|
for r in self:
|
||||||
# member = self.env['golem.member'].browse([mid])
|
r.fullrelation = '{} -> {} -> {}'.format(r.partnerfrom_id.name,
|
||||||
# self.member_id = member.partner_id.id
|
r.relation_id.name,
|
||||||
# return self
|
r.partnerto_id.name)
|
||||||
|
|
||||||
|
@api.onchange('partnerfrom_id')
|
||||||
|
def onchange_partnerfrom_id(self):
|
||||||
|
""" If tree from member, use ctx default partner to populate from """
|
||||||
|
default_pid = self.env.context.get('default_partnerfrom_id')
|
||||||
|
if default_pid:
|
||||||
|
self.partnerfrom_id = default_pid
|
||||||
|
|
||||||
|
|
||||||
class GolemFamilyRelation(models.Model):
|
class GolemFamilyRelation(models.Model):
|
||||||
|
@ -25,27 +25,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<field name="model">golem.member</field>
|
<field name="model">golem.member</field>
|
||||||
<field name="inherit_id" ref="golem_member.view_form" />
|
<field name="inherit_id" ref="golem_member.view_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<!--
|
<div class="oe_title" position="after">
|
||||||
<div class="oe_title" position="before">
|
|
||||||
<div class="oe_right oe_button_box">
|
<div class="oe_right oe_button_box">
|
||||||
<button
|
<button
|
||||||
class="oe_inline oe_stat_button" type="object"
|
class="oe_inline oe_stat_button" type="object"
|
||||||
context="{'default_memberfrom_id': partner_id}"
|
name="button_family_members" icon="fa-users">
|
||||||
name="button_family_members" icon="fa-list">
|
<field string="Family Relations" name="family_count" widget="statinfo" />
|
||||||
<field string="Family" name="family_count" widget="statinfo"/>
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
-->
|
|
||||||
<page name="contact_details" position="after">
|
|
||||||
<page name="family" string="Family">
|
|
||||||
<field name="family_ids" widget="one2many"
|
|
||||||
domain="['|',
|
|
||||||
('memberfrom_id', '=', active_id),
|
|
||||||
('memberto_id', '=', active_id)]"
|
|
||||||
context="{'default_memberfrom_id': active_id}" />
|
|
||||||
</page>
|
|
||||||
</page>
|
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@ -55,14 +43,28 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<field name="model">golem.member.family</field>
|
<field name="model">golem.member.family</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree editable="top">
|
<tree editable="top">
|
||||||
<field name="memberfrom_id" string="Family Member From" />
|
<field name="partnerfrom_id" string="Family Member From" />
|
||||||
<field name="relation_id" string="is the ... of" />
|
<field name="relation_id" string="is the ... of" />
|
||||||
<field name="memberto_id" string="Family Member To" />
|
<field name="partnerto_id" string="Family Member To" />
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- Searches -->
|
<!-- Searches -->
|
||||||
|
<record id="view_filter" model="ir.ui.view">
|
||||||
|
<field name="name">GOLEM Families Filters</field>
|
||||||
|
<field name="model">golem.member.family</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<search>
|
||||||
|
<field name="fullrelation" />
|
||||||
|
<field name="relation_id" widget="many2one" />
|
||||||
|
<group string="Group By">
|
||||||
|
<filter name="group_relation" string="By relation"
|
||||||
|
context="{'group_by': 'relation_id'}"/>
|
||||||
|
</group>
|
||||||
|
</search>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
<!-- Actions -->
|
<!-- Actions -->
|
||||||
<act_window id="family_action_list" name="GOLEM Family Relations List"
|
<act_window id="family_action_list" name="GOLEM Family Relations List"
|
||||||
|
Loading…
Reference in New Issue
Block a user