New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
translating terms directly in the view (wizard) #31090
Conversation
016cd31
to
10f15fe
Compare
10f15fe
to
f18e31c
Compare
f18e31c
to
52e233d
Compare
c287586
to
52ba087
Compare
52ba087
to
5ef73ec
Compare
@mart-e |
@wtaferner this code is adding a new model so definitely not possible to backport in stable. Maybe some parts can be taken in a new module. |
… on translated field will open wizard with editable listview, where user will have two field(to have simple view), Language and Translation Value, added two transient model to meet to specification without changing JS code
5ef73ec
to
9c9d99e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The result looks good, it greatly improve the recording and update of translations 👍
However, the code still seems very complex. It looks like you are duplicating code in the wizard that suspiciously looks a lot like the one in translate_fields
. Can't we reuse some information we already got?
if field: | ||
fld = record._fields[field] | ||
if not fld.related: | ||
domain += ['|', ('name', '=', "%s,%s" % (fld.model_name, fld.name)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use expression.AND
and expression.OR
when creating domains with conditional clauses, it avoids errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when I said to use expression
, it was to avoid the +=
😉 (I will correct)
<field name="arch" type="xml"> | ||
<form string="Translations"> | ||
<field name="translation_lines" nolabel="1"> | ||
<tree string="Translations" editable="top" create="false" delete="false"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why preventing to delete? It actually is an easy way to get rid of old translations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mart-e this is o2m field and records of translations loaded in new TransientModel with default_get, even if we allow delete, we can not delete as it is in o2m using default_get, we still not have database ids for those records, so we simply remove delete button
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@msh-odoo so if I want to remove a bad translation (but I don't know how to fix it), how should I proceed? Put an empty string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mart-e Well, I have one way to delete translation but I am not sure we should go with it
Allow user to delete translation from wizard o2m, when Confirm button clicked, we will generate default lines again in confirm button method and match with Wizard record's o2m lines, whatever missing considered as deleted, what do you think? this is the only way currently I have
|
||
domain = self._prepare_domain() | ||
translations = IrTranslation.search(domain) | ||
res['translation_lines'] = [[0, False, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
detail: we usually a list of tuples for commands instead of a list of list
In this commit, - changed the conditional domains with expression.OR - changed method name - improved naming conventions
|
||
@api.model | ||
def default_get(self, fields_list): | ||
res = super(TranslationWizard, self).default_get(fields_list) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in python 3, super().default_get(fields_list)
is enough
Replaced by #33623 |
Description of the issue/feature this PR addresses:
Current behavior before PR:
Desired behavior after PR is merged:
--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr