[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 ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-06-05 08:24+0000\n"
"PO-Revision-Date: 2017-06-05 08:24+0000\n"
"POT-Creation-Date: 2017-06-05 13:53+0000\n"
"PO-Revision-Date: 2017-06-05 13:53+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@ -368,6 +368,11 @@ msgstr "Féminin"
msgid "First name"
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
#: model:ir.model.fields,field_description:golem_member.field_golem_member_property_account_position_id
msgid "Fiscal Position"
@ -426,7 +431,7 @@ msgid "GOLEM Members Tags"
msgstr "Catégories d'adhérents"
#. module: golem_member
#: code:addons/golem_member/models/golem_member.py:291
#: code:addons/golem_member/models/golem_member.py:296
#, python-format
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."
@ -698,8 +703,8 @@ msgid "Nationality"
msgstr "Nationalité"
#. module: golem_member
#: code:addons/golem_member/models/golem_member.py:252
#: code:addons/golem_member/models/golem_member.py:255
#: code:addons/golem_member/models/golem_member.py:254
#: code:addons/golem_member/models/golem_member.py:257
#: selection:golem.member.numberconfig,is_automatic:0
#: selection:golem.member.numberconfig,is_per_season:0
#, python-format
@ -716,6 +721,11 @@ msgstr "Notes"
msgid "Number"
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
#: model:ir.model.fields,field_description:golem_member.field_golem_member_opt_out
msgid "Opt-Out"
@ -909,7 +919,7 @@ msgstr "Rue..."
#. module: golem_member
#: model:ir.model.fields,field_description:golem_member.field_golem_member_street2
msgid "Street2"
msgstr "Rue 2"
msgstr "Complément de rue"
#. module: golem_member
#: 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"
#. module: golem_member
#: code:addons/golem_member/models/golem_member.py:252
#: code:addons/golem_member/models/golem_member.py:255
#: code:addons/golem_member/models/golem_member.py:254
#: code:addons/golem_member/models/golem_member.py:257
#: selection:golem.member.numberconfig,is_automatic:0
#: selection:golem.member.numberconfig,is_per_season:0
#, python-format

View File

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

View File

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

View File

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

View File

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