Skip to content

Commit

Permalink
[ADD] refs #15908 add a new wizard to change the type of a phone number
Browse files Browse the repository at this point in the history
  • Loading branch information
Cedric-Pigeon committed Sep 17, 2015
1 parent ebec44f commit 2eb3a63
Show file tree
Hide file tree
Showing 9 changed files with 371 additions and 8 deletions.
23 changes: 17 additions & 6 deletions mozaik_coordinate/abstract_coordinate.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,19 +462,24 @@ def get_fields_to_update(self, cr, uid, mode, context=None):
})
return res

def action_invalidate(self, cr, uid, ids, context=None, vals=None):
context = context.copy() if context else {}
def ensure_one_main_coordinate(self, cr, uid, ids, invalidate=False,
vals=False, context=None):
'''
This method ensure that a main coordinate will remain after
an action
'''
context = context.copy() or {}
limit = 1 if not invalidate else False
rejected_ids = []
for coordinate in self.browse(cr, uid, ids, context=context):
coord_ids = self.search(
cr, uid, [('partner_id', '=', coordinate.partner_id.id),
('coordinate_type', '=', coordinate.coordinate_type),
('id', '!=', coordinate.id)], context=context)
('id', '!=', coordinate.id)], limit=limit,
context=context)
if coordinate.is_main and len(coord_ids) == 1:
# only one coordinate will remain after invalidate -> set it
# automatically as new main
new_main = self.browse(cr, uid, coord_ids[0], context=context)
context['invalidate'] = True
context['invalidate'] = invalidate
coordinate_field = self._discriminant_field
coordinate_value = self._is_discriminant_m2o() and \
new_main[coordinate_field].id or \
Expand All @@ -486,5 +491,11 @@ def action_invalidate(self, cr, uid, ids, context=None, vals=None):
self.write(cr, uid, coordinate.id, vals, context=context)
else:
rejected_ids.append(coordinate.id)
return rejected_ids

def action_invalidate(self, cr, uid, ids, context=None, vals=None):
context = context.copy() if context else {}
rejected_ids = self.ensure_one_main_coordinate(
cr, uid, ids, invalidate=True, context=context)
return super(abstract_coordinate, self). action_invalidate(
cr, uid, rejected_ids, context=context, vals=vals)
1 change: 1 addition & 0 deletions mozaik_phone/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
'wizard/change_main_phone.xml',
'wizard/allow_duplicate_view.xml',
'wizard/bounce_editor_view.xml',
'wizard/change_phone_type.xml',
],
'qweb': [
],
Expand Down
46 changes: 44 additions & 2 deletions mozaik_phone/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mozaik_phone
# * mozaik_phone
#
msgid ""
msgstr ""
Expand Down Expand Up @@ -49,6 +49,16 @@ msgstr "Autoriser les doublons"
msgid "Also for Fax"
msgstr "Également pour fax"

#. module: mozaik_phone
#: view:change.phone.type:mozaik_phone.change_phone_type_form
msgid "Cancel"
msgstr "Annuler"

#. module: mozaik_phone
#: view:change.phone.type:mozaik_phone.change_phone_type_form
msgid "Change"
msgstr "Modifier"

#. module: mozaik_phone
#: field:change.main.phone,change_allowed:0
msgid "Change Allowed"
Expand All @@ -64,6 +74,17 @@ msgstr "Changer le téléphone principal"
msgid "Change Main Phone Wizard"
msgstr "Assistant de changement de téléphone principal"

#. module: mozaik_phone
#: view:change.phone.type:mozaik_phone.change_phone_type_form
#: model:ir.actions.act_window,name:mozaik_phone.change_phone_type_action
msgid "Change Phone Type"
msgstr "Changement du type de téléphone"

#. module: mozaik_phone
#: model:ir.model,name:mozaik_phone.model_change_phone_type
msgid "Change Phone Type Wizard"
msgstr "Assistant de changement de type de téléphone"

#. module: mozaik_phone
#: field:phone.coordinate,partner_id:0
msgid "Contact"
Expand All @@ -81,13 +102,15 @@ msgstr "Coordonnées"

#. module: mozaik_phone
#: field:change.main.phone,create_uid:0
#: field:change.phone.type,create_uid:0
#: field:phone.coordinate,create_uid:0
#: field:phone.phone,create_uid:0
msgid "Created by"
msgstr "Créé par"

#. module: mozaik_phone
#: field:change.main.phone,create_date:0
#: field:change.phone.type,create_date:0
msgid "Created on"
msgstr "Date de création"

Expand Down Expand Up @@ -127,6 +150,7 @@ msgid "Failures Counter"
msgstr "Compteur d'échecs"

#. module: mozaik_phone
#: selection:change.phone.type,type:0
#: selection:phone.coordinate,coordinate_type:0
#: selection:phone.phone,type:0
#: field:res.partner,fax_coordinate_id:0
Expand All @@ -139,6 +163,7 @@ msgid "Faxes"
msgstr "Fax"

#. module: mozaik_phone
#: selection:change.phone.type,type:0
#: selection:phone.coordinate,coordinate_type:0
#: selection:phone.phone,type:0
msgid "Fix"
Expand Down Expand Up @@ -169,6 +194,7 @@ msgstr "Contient le résumé de la discussion (nombre de messages, ...). Ce rés

#. module: mozaik_phone
#: field:change.main.phone,id:0
#: field:change.phone.type,id:0
#: field:phone.coordinate,id:0
#: field:phone.phone,id:0
msgid "ID"
Expand Down Expand Up @@ -236,13 +262,15 @@ msgstr "Date du dernier message"

#. module: mozaik_phone
#: field:change.main.phone,write_uid:0
#: field:change.phone.type,write_uid:0
#: field:phone.coordinate,write_uid:0
#: field:phone.phone,write_uid:0
msgid "Last Updated by"
msgstr "Dernière mise à jour par"

#. module: mozaik_phone
#: field:change.main.phone,write_date:0
#: field:change.phone.type,write_date:0
#: field:phone.coordinate,write_date:0
#: field:phone.phone,write_date:0
msgid "Last Updated on"
Expand All @@ -267,6 +295,7 @@ msgid "Messages and communication history"
msgstr "Historique des messages et communications"

#. module: mozaik_phone
#: selection:change.phone.type,type:0
#: selection:phone.coordinate,coordinate_type:0
#: selection:phone.phone,type:0
#: field:res.partner,mobile_coordinate_id:0
Expand All @@ -283,6 +312,12 @@ msgstr "Plus d'info"
msgid "New Main Phone"
msgstr "Nouveau téléphone principal"

#. module: mozaik_phone
#: code:addons/mozaik_phone/wizard/change_phone_type.py:58
#, python-format
msgid "New phone type should be different than current one!"
msgstr "Le nouveau type de téléphone doit être différent de l'actuel!"

#. module: mozaik_phone
#: field:phone.phone,name:0
msgid "Number"
Expand All @@ -295,6 +330,7 @@ msgid "Partner"
msgstr "Partenaire"

#. module: mozaik_phone
#: field:change.phone.type,phone_id:0
#: view:phone.coordinate:mozaik_phone.phone_coordinate_search_view
#: field:phone.coordinate,phone_id:0
#: view:phone.phone:mozaik_phone.phone_phone_form_view
Expand Down Expand Up @@ -346,6 +382,7 @@ msgid "Phones"
msgstr "Téléphones"

#. module: mozaik_phone
#: field:change.phone.type,is_main:0
#: model:ir.actions.act_window,name:mozaik_phone.set_as_main_action
msgid "Set as main"
msgstr "Positionner comme principale"
Expand All @@ -362,6 +399,7 @@ msgid "This Phone Coordinate seems to be down"
msgstr "Cette coordonnée téléphonique semble obsolète"

#. module: mozaik_phone
#: field:change.phone.type,type:0
#: view:phone.phone:mozaik_phone.phone_phone_search_view
#: field:phone.phone,type:0
msgid "Type"
Expand Down Expand Up @@ -407,10 +445,14 @@ msgstr "Messages de site web"
msgid "Website communication history"
msgstr "Historique de communication de site web"

#. module: mozaik_phone
#: view:change.phone.type:mozaik_phone.change_phone_type_form
msgid "or"
msgstr "ou"

#. module: mozaik_phone
#: view:phone.coordinate:mozaik_phone.phone_coordinate_form_view
msgid "{'search_default_duplicate': True,\n"
" 'search_default_phone_id': phone_id,\n"
" 'default_phone_id': phone_id}"
msgstr ""

1 change: 1 addition & 0 deletions mozaik_phone/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@
from . import test_phone_coordinate
from . import test_phone_coordinate_wizard
from . import test_res_partner
from . import test_change_phone_type
40 changes: 40 additions & 0 deletions mozaik_phone/tests/data/phone_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,31 @@
<field name="type">mobile</field>
</record>

<record id="mobile_four" model="phone.phone">
<field name="name">+32 473 78 10 79</field>
<field name="type">mobile</field>
</record>

<record id="mobile_five" model="phone.phone">
<field name="name">+32 473 78 10 80</field>
<field name="type">mobile</field>
</record>

<record id="fax_one" model="phone.phone">
<field name="name">061548799</field>
<field name="type">fax</field>
</record>

<record id="fix_one" model="phone.phone">
<field name="name">063458978</field>
<field name="type">fix</field>
</record>

<record id="fix_two" model="phone.phone">
<field name="name">063458688</field>
<field name="type">fix</field>
</record>

<record id="fix_for_test_update_1" model="phone.phone">
<field name="name">061458978</field>
<field name="type">fix</field>
Expand Down Expand Up @@ -96,5 +116,25 @@
<field name="partner_id" ref="res_partner_nouvelobs" />
</record>

<!-- Partner Jacques -->
<record id="mobile_coordinate_for_jacques_1" model="phone.coordinate">
<field name="phone_id" ref="mobile_four" />
<field name="partner_id" ref="res_partner_jacques" />
</record>

<record id="mobile_coordinate_for_jacques_2" model="phone.coordinate">
<field name="phone_id" ref="mobile_five" />
<field name="partner_id" ref="res_partner_jacques" />
</record>

<record id="fix_coordinate_for_jacques_1" model="phone.coordinate">
<field name="phone_id" ref="fix_one" />
<field name="partner_id" ref="res_partner_jacques" />
</record>

<record id="fix_coordinate_for_jacques_2" model="phone.coordinate">
<field name="phone_id" ref="fix_two" />
<field name="partner_id" ref="res_partner_jacques" />
</record>
</data>
</openerp>
Loading

0 comments on commit 2eb3a63

Please sign in to comment.