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',
],
Comment on lines +6 to +8
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The new model translation.wizard is missing access rights. Without an ir.model.access.csv file, only the superuser will be able to access this wizard. It's a security best practice in Odoo to explicitly define access rights for all models. I recommend creating a security/ir.model.access.csv file for the translation.wizard model and adding it to the data list in this manifest file. This will ensure that users with the appropriate permissions can use the translation tool.

Suggested change
'data': [
'views/translation_wizard_view.xml',
],
'data': [
'security/ir.model.access.csv',
'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
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 @api.model decorator is used incorrectly here. This method is intended to be called on a specific record of the wizard, so it should be an instance method. With @api.model, self becomes a class proxy, not a record instance, and accessing self.source_text would fail. Removing the decorator will make it a regular instance method, which is the correct approach here. I've also added self.ensure_one() as a good practice for instance methods to ensure they operate on a single record.

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}"

Copy link

Choose a reason for hiding this comment

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

Bug: Decorator blocks instance access

The translate_text method uses @api.model decorator but accesses instance fields self.source_text and self.translated_text. When called from a button with type="object", the method receives a recordset but @api.model doesn't bind self to the record properly, causing the translation to fail. The decorator should be removed or changed to allow instance access.

Fix in Cursor Fix in Web

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 character 'o' at the end of this XML file, outside of the <odoo> root element. This will cause an XML parsing error when Odoo attempts to load the module, preventing it from being installed or updated. Please remove this character.

Copy link

Choose a reason for hiding this comment

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

Bug: Stray Character Pollutes Output

A stray character o appears after the closing </odoo> tag, which looks like accidentally committed content that should be removed.

Fix in Cursor Fix in Web


Loading