Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions openspp_translations/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# OpenSPP Translations (AI Assisted Translation Wizard)

This module introduces a basic translation wizard that allows users to input
source text and generate translated output (stub implementation for now).
A follow-up iteration will integrate real translation providers.

- Wizard model: `translation.wizard`
- View: Form and menu entry under "Translations"
- Status: Scaffolding ready, awaiting integration with external providers.
Empty file.
16 changes: 16 additions & 0 deletions openspp_translations/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
'name': 'OpenSPP Translations',
'version': '1.0',
'summary': 'AI-assisted translation tool for OpenSPP',
'depends': ['base'],
'data': [
'views/translation_wizard_view.xml',
],
'installable': True,
'application': False,
}


'license': 'LGPL-3',
'author': 'Devendra Chauhan',
'website': 'https://github.com/devendra1973',
Comment on lines +1 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The manifest file has a syntax error. The license, author, and website keys are defined outside of the main dictionary, which makes the file invalid. These keys must be moved inside the dictionary for Odoo to correctly load the module.

{
    'name': 'OpenSPP Translations',
    'version': '1.0',
    'summary': 'AI-assisted translation tool for OpenSPP',
    'depends': ['base'],
    'data': [
        'views/translation_wizard_view.xml',
    ],
    'installable': True,
    'application': False,
    'license': 'LGPL-3',
    'author': 'Devendra Chauhan',
    'website': 'https://github.com/devendra1973',
}

1 change: 1 addition & 0 deletions openspp_translations/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import translation_wizard
Empty file.
13 changes: 13 additions & 0 deletions openspp_translations/models/translation_wizard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from odoo import models, fields, api

class TranslationWizard(models.TransientModel):
_name = 'translation.wizard'
_description = 'AI-Assisted Translation Wizard'

source_text = fields.Text("Source Text", required=True)
translated_text = fields.Text("Translated Text")

@api.model
def translate_text(self):
# Simple placeholder logic (we fake translation for now)
self.translated_text = f"TRANSLATED: {self.source_text}"
Comment on lines +10 to +13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The translate_text method is incorrectly decorated with @api.model. In a model-decorated method, self refers to the model class, not a record instance, so calling self.source_text will raise an AttributeError. This should be an instance method (i.e., remove the decorator).

Additionally, to improve usability, the method should return an action to reopen the wizard. This will refresh the view and display the translated_text to the user immediately after translation.

Suggested change
@api.model
def translate_text(self):
# Simple placeholder logic (we fake translation for now)
self.translated_text = f"TRANSLATED: {self.source_text}"
def translate_text(self):
self.ensure_one()
# Simple placeholder logic (we fake translation for now)
self.translated_text = f"TRANSLATED: {self.source_text}"
return {
'type': 'ir.actions.act_window',
'res_model': self._name,
'view_mode': 'form',
'res_id': self.id,
'target': 'new',
}

31 changes: 31 additions & 0 deletions openspp_translations/views/translation_provider_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="view_translation_provider_form" model="ir.ui.view">
<field name="name">translation.provider.form</field>
<field name="model">translation.provider</field>
<field name="arch" type="xml">
<form string="AI Translation Provider">
<sheet>
<group>
<field name="name"/>
<field name="provider_type"/>
<field name="api_key"/>
<field name="endpoint"/>
</group>
</sheet>
</form>
</field>
</record>

<record id="action_translation_provider" model="ir.actions.act_window">
<field name="name">AI Translation Providers</field>
<field name="res_model">translation.provider</field>
<field name="view_mode">tree,form</field>
</record>

<menuitem id="menu_translation_provider"
name="AI Translation Provider"
parent="base.menu_custom"
action="action_translation_provider"/>
</odoo>
30 changes: 30 additions & 0 deletions openspp_translations/views/translation_wizard_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<odoo>
<record id="view_translation_wizard" model="ir.ui.view">
<field name="name">translation.wizard.form</field>
<field name="model">translation.wizard</field>
<field name="arch" type="xml">
<form string="AI Translation Tool">
<group>
<field name="source_text"/>
<field name="translated_text" readonly="1"/>
</group>
<footer>
<button name="translate_text" string="Translate" type="object" class="btn-primary"/>
<button string="Close" class="btn-secondary" special="cancel"/>
</footer>
</form>
</field>
</record>

<record id="action_translation_wizard" model="ir.actions.act_window">
<field name="name">AI Translate</field>
<field name="res_model">translation.wizard</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>

<menuitem id="menu_translation_root" name="Translation" sequence="10"/>
<menuitem id="menu_translation_tool" name="AI Translator" parent="menu_translation_root" action="action_translation_wizard"/>
</odoo>
o
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

There is a stray 'o' character at the end of the file, outside the main <odoo> tag. This makes the XML file invalid and will cause a parsing error when Odoo tries to load this view. This character must be removed.


Loading