forked from Yaltik/golem
[REF]GOLEM Member : small ref
This commit is contained in:
parent
bf050e225f
commit
151fa26e6e
@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
# Copyright 2016-2018 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
# Copyright 2018 Michel Dessenne <michel@yaltik.com>
|
# Copyright 2018 Michel Dessenne <michel@yaltik.com>
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
@ -19,7 +19,7 @@
|
|||||||
{
|
{
|
||||||
'name': 'GOLEM non-profit members',
|
'name': 'GOLEM non-profit members',
|
||||||
'summary': 'Extends Odoo contacts for MJC',
|
'summary': 'Extends Odoo contacts for MJC',
|
||||||
'version': '10.0.1.1.5',
|
'version': '10.0.1.1.6',
|
||||||
'category': 'GOLEM',
|
'category': 'GOLEM',
|
||||||
'author': 'Fabien Bourgeois, Michel Dessenne',
|
'author': 'Fabien Bourgeois, Michel Dessenne',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
# Copyright 2016-2018 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Affero General Public License as
|
# it under the terms of the GNU Affero General Public License as
|
||||||
@ -40,8 +40,8 @@ class ResPartner(models.Model):
|
|||||||
|
|
||||||
member_id = fields.One2many('golem.member', 'partner_id', 'GOLEM Member',
|
member_id = fields.One2many('golem.member', 'partner_id', 'GOLEM Member',
|
||||||
readonly=True)
|
readonly=True)
|
||||||
is_member = fields.Boolean('Is member', compute='_compute_is_member')
|
is_member = fields.Boolean(compute='_compute_is_member')
|
||||||
member_number = fields.Char('Member number', related='member_id.number')
|
member_number = fields.Char(related='member_id.number')
|
||||||
|
|
||||||
@api.depends('member_id')
|
@api.depends('member_id')
|
||||||
def _compute_is_member(self):
|
def _compute_is_member(self):
|
||||||
@ -53,11 +53,10 @@ class ResPartner(models.Model):
|
|||||||
def view_member(self):
|
def view_member(self):
|
||||||
""" Go to member form """
|
""" Go to member form """
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
if self[0].member_id:
|
|
||||||
return {'type': 'ir.actions.act_window',
|
return {'type': 'ir.actions.act_window',
|
||||||
'res_model': 'golem.member',
|
'res_model': 'golem.member',
|
||||||
'view_mode': 'form',
|
'view_mode': 'form',
|
||||||
'res_id': self[0].member_id.id}
|
'res_id': self[0].member_id.id if self[0].member_id else False}
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def create_golem_member(self):
|
def create_golem_member(self):
|
||||||
@ -99,19 +98,19 @@ class GolemMember(models.Model):
|
|||||||
required=True, default=_default_season,
|
required=True, default=_default_season,
|
||||||
ondelete='restrict')
|
ondelete='restrict')
|
||||||
is_current = fields.Boolean('Current user?', default=False, readonly=True,
|
is_current = fields.Boolean('Current user?', default=False, readonly=True,
|
||||||
store=True, compute='compute_is_current')
|
store=True, compute='_compute_is_current')
|
||||||
is_number_manual = fields.Boolean('Is number manual?', store=False,
|
is_number_manual = fields.Boolean('Is number manual?', store=False,
|
||||||
compute='_compute_is_number_manual')
|
compute='_compute_is_number_manual')
|
||||||
image_permission = fields.Boolean('Image permission?', default=True)
|
image_permission = fields.Boolean('Image permission?', default=True)
|
||||||
|
|
||||||
@api.onchange('country_id')
|
@api.onchange('country_id')
|
||||||
def _onchange_country_id(self):
|
def onchange_country_domain_state(self):
|
||||||
|
""" On country change : adapts state domain """
|
||||||
member = self[0]
|
member = self[0]
|
||||||
if member.country_id:
|
if member.country_id:
|
||||||
return {
|
return {
|
||||||
'domain': {'state_id': [('country_id', '=', member.country_id.id)]}
|
'domain': {'state_id': [('country_id', '=', member.country_id.id)]}
|
||||||
}
|
}
|
||||||
else:
|
|
||||||
return {'domain': {'state_id': []}}
|
return {'domain': {'state_id': []}}
|
||||||
|
|
||||||
@api.depends('number', 'name')
|
@api.depends('number', 'name')
|
||||||
@ -123,15 +122,13 @@ class GolemMember(models.Model):
|
|||||||
else:
|
else:
|
||||||
member.number_name = u''
|
member.number_name = u''
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.depends('season_ids')
|
@api.depends('season_ids')
|
||||||
def compute_is_current(self):
|
def _compute_is_current(self):
|
||||||
""" Computes is current according to seasons """
|
""" Computes is current according to seasons """
|
||||||
default_s = self._default_season()
|
default_s = self._default_season()
|
||||||
for member in self:
|
for member in self:
|
||||||
member.is_current = default_s in member.season_ids
|
member.is_current = default_s in member.season_ids
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.depends('number')
|
@api.depends('number')
|
||||||
def _compute_is_number_manual(self):
|
def _compute_is_number_manual(self):
|
||||||
conf = self.env['ir.config_parameter']
|
conf = self.env['ir.config_parameter']
|
||||||
@ -226,15 +223,14 @@ class GolemMemberNumber(models.Model):
|
|||||||
_name = 'golem.member.number'
|
_name = 'golem.member.number'
|
||||||
_description = 'GOLEM Member Numbers'
|
_description = 'GOLEM Member Numbers'
|
||||||
|
|
||||||
name = fields.Char('Name', compute='_compute_name')
|
name = fields.Char(compute='_compute_name')
|
||||||
member_id = fields.Many2one('golem.member', string='Member', index=True,
|
member_id = fields.Many2one('golem.member', string='Member', index=True,
|
||||||
required=True, ondelete='cascade',
|
required=True, ondelete='cascade',
|
||||||
auto_join=True)
|
auto_join=True)
|
||||||
season_id = fields.Many2one('golem.season', string='Season', index=True,
|
season_id = fields.Many2one('golem.season', string='Season', index=True,
|
||||||
auto_join=True)
|
auto_join=True)
|
||||||
number = fields.Char('Number', index=True, readonly=True)
|
number = fields.Char(index=True, readonly=True)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.depends('season_id')
|
@api.depends('season_id')
|
||||||
def _compute_name(self):
|
def _compute_name(self):
|
||||||
for number in self:
|
for number in self:
|
||||||
@ -285,6 +281,7 @@ class GolemNumberConfig(models.TransientModel):
|
|||||||
self.env['golem.season'].search([]).write({
|
self.env['golem.season'].search([]).write({
|
||||||
'member_counter': self.number_from
|
'member_counter': self.number_from
|
||||||
})
|
})
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def apply_nocompute(self):
|
def apply_nocompute(self):
|
||||||
""" Apply new configuration only for new members (keep old numbers) """
|
""" Apply new configuration only for new members (keep old numbers) """
|
||||||
@ -306,6 +303,7 @@ class GolemNumberConfig(models.TransientModel):
|
|||||||
})
|
})
|
||||||
self.env['golem.member'].search([]).generate_number()
|
self.env['golem.member'].search([]).generate_number()
|
||||||
|
|
||||||
|
|
||||||
class MergePartnerAutomatic(models.TransientModel):
|
class MergePartnerAutomatic(models.TransientModel):
|
||||||
""" Merge Partner Automatic adaptations """
|
""" Merge Partner Automatic adaptations """
|
||||||
_inherit = 'base.partner.merge.automatic.wizard'
|
_inherit = 'base.partner.merge.automatic.wizard'
|
||||||
|
Loading…
Reference in New Issue
Block a user