[ADD]GOLEM Member number : ability to fix number from

This commit is contained in:
Fabien Bourgeois 2017-06-05 15:55:50 +02:00
parent 203e6434aa
commit 4d99cd527f
5 changed files with 60 additions and 33 deletions

View File

@ -6,8 +6,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 10.0\n" "Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-06-05 08:24+0000\n" "POT-Creation-Date: 2017-06-05 13:53+0000\n"
"PO-Revision-Date: 2017-06-05 08:24+0000\n" "PO-Revision-Date: 2017-06-05 13:53+0000\n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -368,6 +368,11 @@ msgstr "Féminin"
msgid "First name" msgid "First name"
msgstr "Prénom" msgstr "Prénom"
#. module: golem_member
#: model:ir.model.fields,field_description:golem_member.field_golem_member_numberconfig_number_from
msgid "First number"
msgstr "Premier numéro"
#. module: golem_member #. module: golem_member
#: model:ir.model.fields,field_description:golem_member.field_golem_member_property_account_position_id #: model:ir.model.fields,field_description:golem_member.field_golem_member_property_account_position_id
msgid "Fiscal Position" msgid "Fiscal Position"
@ -426,7 +431,7 @@ msgid "GOLEM Members Tags"
msgstr "Catégories d'adhérents" msgstr "Catégories d'adhérents"
#. module: golem_member #. module: golem_member
#: code:addons/golem_member/models/golem_member.py:291 #: code:addons/golem_member/models/golem_member.py:296
#, python-format #, python-format
msgid "GOLEM Members merge has not been implemented yet. Please only merge partners, not members, or delete GOLEM Members manually before merging." msgid "GOLEM Members merge has not been implemented yet. Please only merge partners, not members, or delete GOLEM Members manually before merging."
msgstr "La fusion d'adhérents n'a pas encore été implémentée. Merci de ne fusionner que des contacts non adhérents, ou bien de supprimer les adhérents manuellement en premier lieu." msgstr "La fusion d'adhérents n'a pas encore été implémentée. Merci de ne fusionner que des contacts non adhérents, ou bien de supprimer les adhérents manuellement en premier lieu."
@ -698,8 +703,8 @@ msgid "Nationality"
msgstr "Nationalité" msgstr "Nationalité"
#. module: golem_member #. module: golem_member
#: code:addons/golem_member/models/golem_member.py:252 #: code:addons/golem_member/models/golem_member.py:254
#: code:addons/golem_member/models/golem_member.py:255 #: code:addons/golem_member/models/golem_member.py:257
#: selection:golem.member.numberconfig,is_automatic:0 #: selection:golem.member.numberconfig,is_automatic:0
#: selection:golem.member.numberconfig,is_per_season:0 #: selection:golem.member.numberconfig,is_per_season:0
#, python-format #, python-format
@ -716,6 +721,11 @@ msgstr "Notes"
msgid "Number" msgid "Number"
msgstr "Numéro d'adhérent" msgstr "Numéro d'adhérent"
#. module: golem_member
#: model:ir.model.fields,help:golem_member.field_golem_member_numberconfig_number_from
msgid "Number starting from, default to 1"
msgstr "Numéro de départ, par défaut 1"
#. module: golem_member #. module: golem_member
#: model:ir.model.fields,field_description:golem_member.field_golem_member_opt_out #: model:ir.model.fields,field_description:golem_member.field_golem_member_opt_out
msgid "Opt-Out" msgid "Opt-Out"
@ -909,7 +919,7 @@ msgstr "Rue..."
#. module: golem_member #. module: golem_member
#: model:ir.model.fields,field_description:golem_member.field_golem_member_street2 #: model:ir.model.fields,field_description:golem_member.field_golem_member_street2
msgid "Street2" msgid "Street2"
msgstr "Rue 2" msgstr "Complément de rue"
#. module: golem_member #. module: golem_member
#: model:ir.model.fields,field_description:golem_member.field_golem_member_vat #: model:ir.model.fields,field_description:golem_member.field_golem_member_vat
@ -1089,8 +1099,8 @@ msgid "Website of Partner or Company"
msgstr "Site Web pour les Partenaires ou les Sociétés" msgstr "Site Web pour les Partenaires ou les Sociétés"
#. module: golem_member #. module: golem_member
#: code:addons/golem_member/models/golem_member.py:252 #: code:addons/golem_member/models/golem_member.py:254
#: code:addons/golem_member/models/golem_member.py:255 #: code:addons/golem_member/models/golem_member.py:257
#: selection:golem.member.numberconfig,is_automatic:0 #: selection:golem.member.numberconfig,is_automatic:0
#: selection:golem.member.numberconfig,is_per_season:0 #: selection:golem.member.numberconfig,is_per_season:0
#, python-format #, python-format

View File

@ -6,8 +6,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 10.0\n" "Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-06-05 08:24+0000\n" "POT-Creation-Date: 2017-06-05 13:52+0000\n"
"PO-Revision-Date: 2017-06-05 08:24+0000\n" "PO-Revision-Date: 2017-06-05 13:52+0000\n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -367,6 +367,11 @@ msgstr ""
msgid "First name" msgid "First name"
msgstr "" msgstr ""
#. module: golem_member
#: model:ir.model.fields,field_description:golem_member.field_golem_member_numberconfig_number_from
msgid "First number"
msgstr ""
#. module: golem_member #. module: golem_member
#: model:ir.model.fields,field_description:golem_member.field_golem_member_property_account_position_id #: model:ir.model.fields,field_description:golem_member.field_golem_member_property_account_position_id
msgid "Fiscal Position" msgid "Fiscal Position"
@ -425,7 +430,7 @@ msgid "GOLEM Members Tags"
msgstr "" msgstr ""
#. module: golem_member #. module: golem_member
#: code:addons/golem_member/models/golem_member.py:291 #: code:addons/golem_member/models/golem_member.py:296
#, python-format #, python-format
msgid "GOLEM Members merge has not been implemented yet. Please only merge partners, not members, or delete GOLEM Members manually before merging." msgid "GOLEM Members merge has not been implemented yet. Please only merge partners, not members, or delete GOLEM Members manually before merging."
msgstr "" msgstr ""
@ -691,8 +696,8 @@ msgid "Nationality"
msgstr "" msgstr ""
#. module: golem_member #. module: golem_member
#: code:addons/golem_member/models/golem_member.py:252 #: code:addons/golem_member/models/golem_member.py:254
#: code:addons/golem_member/models/golem_member.py:255 #: code:addons/golem_member/models/golem_member.py:257
#: selection:golem.member.numberconfig,is_automatic:0 #: selection:golem.member.numberconfig,is_automatic:0
#: selection:golem.member.numberconfig,is_per_season:0 #: selection:golem.member.numberconfig,is_per_season:0
#, python-format #, python-format
@ -709,6 +714,11 @@ msgstr ""
msgid "Number" msgid "Number"
msgstr "" msgstr ""
#. module: golem_member
#: model:ir.model.fields,help:golem_member.field_golem_member_numberconfig_number_from
msgid "Number starting from, default to 1"
msgstr ""
#. module: golem_member #. module: golem_member
#: model:ir.model.fields,field_description:golem_member.field_golem_member_opt_out #: model:ir.model.fields,field_description:golem_member.field_golem_member_opt_out
msgid "Opt-Out" msgid "Opt-Out"
@ -1080,8 +1090,8 @@ msgid "Website of Partner or Company"
msgstr "" msgstr ""
#. module: golem_member #. module: golem_member
#: code:addons/golem_member/models/golem_member.py:252 #: code:addons/golem_member/models/golem_member.py:254
#: code:addons/golem_member/models/golem_member.py:255 #: code:addons/golem_member/models/golem_member.py:257
#: selection:golem.member.numberconfig,is_automatic:0 #: selection:golem.member.numberconfig,is_automatic:0
#: selection:golem.member.numberconfig,is_per_season:0 #: selection:golem.member.numberconfig,is_per_season:0
#, python-format #, python-format

View File

@ -127,7 +127,7 @@ class GolemMember(models.Model):
def _compute_is_number_manual(self): def _compute_is_number_manual(self):
conf = self.env['ir.config_parameter'] conf = self.env['ir.config_parameter']
is_num_man = (conf.get_param('golem_numberconfig_isautomatic') == '0') is_num_man = (conf.get_param('golem_numberconfig_isautomatic') == '0')
self.is_number_manual = is_num_man self.write({'is_number_manual': is_num_man})
@api.multi @api.multi
def generate_number_perseason(self): def generate_number_perseason(self):
@ -142,15 +142,15 @@ class GolemMember(models.Model):
('season_id', '=', season.id)] ('season_id', '=', season.id)]
member_num = member_number_obj.search(domain) member_num = member_number_obj.search(domain)
if not member_num: if not member_num:
season.member_counter += 1
season.write({'member_counter': season.member_counter}) season.write({'member_counter': season.member_counter})
pkey = 'golem_numberconfig_prefix' pkey = 'golem_numberconfig_prefix'
pfx = conf.get_param(pkey, '') pfx = conf.get_param(pkey, '')
number = pfx + str(season.member_counter) number = u'{}{}'.format(pfx, unicode(season.member_counter))
data = {'member_id': member.id, data = {'member_id': member.id,
'season_id': season.id, 'season_id': season.id,
'number': number} 'number': number}
member_num = member_number_obj.create(data) member_num = member_number_obj.create(data)
season.member_counter += 1
if season.is_default: if season.is_default:
res = member_num.number res = member_num.number
return res return res
@ -166,15 +166,17 @@ class GolemMember(models.Model):
member_number_obj = self.env['golem.member.number'] member_number_obj = self.env['golem.member.number']
member_num = member_number_obj.search(domain) member_num = member_number_obj.search(domain)
if not member_num: if not member_num:
last = int(conf.get_param('golem_number_counter', 0)) last = int(conf.get_param('golem_number_counter', 1))
last += 1
conf.set_param('golem_number_counter', str(last))
pfx = conf.get_param('golem_numberconfig_prefix', '') pfx = conf.get_param('golem_numberconfig_prefix', '')
number = pfx + str(last) number = pfx + str(last)
data = {'member_id': self[0].id, data = {'member_id': self[0].id,
'season_id': None, 'season_id': None,
'number': number} 'number': number}
member_num = member_number_obj.create(data) member_num = member_number_obj.create(data)
last += 1
conf.set_param('golem_number_counter', str(last))
else:
member_num = member_num[0]
return member_num.number return member_num.number
@api.multi @api.multi
@ -191,7 +193,7 @@ class GolemMember(models.Model):
else: else:
member_num = member.generate_number_global() member_num = member.generate_number_global()
if member_num: if member_num:
member.number = member_num[0] member.number = member_num
@api.model @api.model
def create(self, values): def create(self, values):
@ -256,6 +258,8 @@ class GolemNumberConfig(models.TransientModel):
string='Per season number?', string='Per season number?',
default=_default_is_per_season) default=_default_is_per_season)
prefix = fields.Char('Optional prefix', default=_default_prefix) prefix = fields.Char('Optional prefix', default=_default_prefix)
number_from = fields.Integer('First number', default=1,
help='Number starting from, default to 1')
@api.multi @api.multi
def apply_config(self): def apply_config(self):
@ -272,9 +276,11 @@ class GolemNumberConfig(models.TransientModel):
self.ensure_one() self.ensure_one()
self.apply_config() self.apply_config()
conf = self.env['ir.config_parameter'] conf = self.env['ir.config_parameter']
conf.set_param('golem_number_counter', '0') conf.set_param('golem_number_counter', self.number_from)
self.env['golem.member.number'].search([]).unlink() self.env['golem.member.number'].search([]).unlink()
self.env['golem.season'].search([]).write({'member_counter': 0}) self.env['golem.season'].search([]).write({
'member_counter': int(self.number_from)
})
self.env['golem.member'].search([]).generate_number() self.env['golem.member'].search([]).generate_number()
class MergePartnerAutomatic(models.TransientModel): class MergePartnerAutomatic(models.TransientModel):
@ -284,9 +290,8 @@ class MergePartnerAutomatic(models.TransientModel):
@api.multi @api.multi
def action_merge(self): def action_merge(self):
""" Merge adaptations : warn if there is a member """ """ Merge adaptations : warn if there is a member """
_LOGGER.warning(self.partner_ids) for merge in self:
for partner in self.partner_ids: for partner in merge.partner_ids:
_LOGGER.warning(partner.member_id)
if partner.member_id: if partner.member_id:
emsg = _('GOLEM Members merge has not been implemented yet. ' emsg = _('GOLEM Members merge has not been implemented yet. '
'Please only merge partners, not members, or delete ' 'Please only merge partners, not members, or delete '

View File

@ -33,6 +33,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
attrs="{'invisible': [('is_automatic', '=', '0')]}"/> attrs="{'invisible': [('is_automatic', '=', '0')]}"/>
<field name="prefix" <field name="prefix"
attrs="{'invisible': [('is_automatic', '=', '0')]}"/> attrs="{'invisible': [('is_automatic', '=', '0')]}"/>
<field name="number_from"
attrs="{'invisible': [('is_automatic', '=', '0')]}"/>
</group> </group>
</sheet> </sheet>
<footer> <footer>

View File

@ -29,7 +29,7 @@ class GolemSeason(models.Model):
name = fields.Char('Season name', copy=False) name = fields.Char('Season name', copy=False)
member_counter = fields.Integer('Counter for member number generation', member_counter = fields.Integer('Counter for member number generation',
readonly=True, default=0) readonly=True, default=1)
date_start = fields.Date('Period start') date_start = fields.Date('Period start')
date_end = fields.Date('Period end') date_end = fields.Date('Period end')