Skip to content

Commit

Permalink
Merge pull request #68 from MickSandoz/master
Browse files Browse the repository at this point in the history
Little changes for letters treatment sent to translation platform
  • Loading branch information
ecino committed May 23, 2016
2 parents 9abc218 + 50c6a8c commit 91963c0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
18 changes: 17 additions & 1 deletion sbc_translation/models/correspondence.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@ def send_local_translate(self):
self._transfer_file_on_nas(file_name)
self.state = 'Global Partner translation queue'

@api.one
def remove_local_translate(self):
"""
Remove a letter from local translation platform and change state of
letter in Odoo
:return: None
"""
tc = translate_connector.TranslateConnect()
tc.remove_translation_with_odoo_id(self.id)
if self.direction == 'Supporter To Beneficiary':
self.state = 'Received in the system'
else:
self.state = 'Published to Global Partner'

@api.one
def update_translation(self, translate_lang, translate_text, translator):
"""
Expand Down Expand Up @@ -261,5 +275,7 @@ def check_local_translation_done(self):
correspondence.update_translation(letter["target_lang"],
letter["text"],
letter["translator"])
tc.remove_letter(letter["text_id"])
# tc.remove_letter(letter["text_id"])
# update: don't remove letter but set todo id to 'Traité'
tc.update_translation_to_treated(letter["id"])
return True
13 changes: 12 additions & 1 deletion sbc_translation/models/translate_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def get_translated_letters(self):
return res

def update_translation_to_not_in_odoo(self, translation_id):
"""update translation to set toDo_id in state "Not in Odoo"
"""update translation to set toDo_id in state "Pas sur Odoo"
"""

vals = {
Expand All @@ -133,6 +133,17 @@ def update_translation_to_not_in_odoo(self, translation_id):
}
return self.upsert("translation", vals)

def update_translation_to_treated(self, translation_id):
"""update translation to set toDo_id in state "Traité"
"""

vals = {
'id': translation_id,
'toDo_id': 4,
'updatedat': self.current_time,
}
return self.upsert("translation", vals)

def remove_letter(self, id):
""" Delete a letter record with the text_id given """
self.remove_from_text(id)
Expand Down
4 changes: 3 additions & 1 deletion sbc_translation/views/correspondence_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
<field name="model">correspondence</field>
<field name="inherit_id" ref="sbc_compassion.view_correspondence_form" />
<field name="arch" type="xml">
<button name="compose_letter_image" position="before">
<button name="compose_letter_image" position="before">
<button name="remove_local_translate" type="object" string="Remove from translation" class="oe_red"
states="Global Partner translation queue"/>
<button name="send_local_translate" type="object" string="To Translate" class="oe_red"
states="Published to Global Partner,Received in the system"/>
</button>
Expand Down

0 comments on commit 91963c0

Please sign in to comment.