Skip to content

Commit fb46f61

Browse files
author
John75SunCity
committed
fix: Add translation import and remove _() from static strings in server actions
1 parent 8e40a54 commit fb46f61

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

records_management/data/container_bulk_actions.xml

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
<field name="binding_view_types">list</field>
1010
<field name="state">code</field>
1111
<field name="code">
12+
# Import translation function
13+
from odoo.tools.translate import _
14+
1215
# Bulk create retrieval work order from selected containers
1316
if records:
1417
# Get partner from first container (all should be same customer)
@@ -25,7 +28,7 @@ if records:
2528

2629
# Create new retrieval work order
2730
work_order = env['records.retrieval.work.order'].create({
28-
'name': _('Retrieval - %s (%s containers)') % (partner.name, len(records)),
31+
'name': 'Retrieval - %s (%s containers)' % (partner.name, len(records)),
2932
'partner_id': partner.id,
3033
'user_id': env.user.id,
3134
'state': 'draft',
@@ -35,13 +38,13 @@ if records:
3538

3639
# Post message
3740
work_order.message_post(
38-
body=_('📦 Created from bulk action with %d container(s): %s') % (len(records), ', '.join(records.mapped('name'))),
39-
subject=_('Bulk Retrieval Order Created')
41+
body='📦 Created from bulk action with %d container(s): %s' % (len(records), ', '.join(records.mapped('name'))),
42+
subject='Bulk Retrieval Order Created'
4043
)
4144

4245
# Return action to open the new work order
4346
action = {
44-
'name': _('Retrieval Work Order'),
47+
'name': 'Retrieval Work Order',
4548
'type': 'ir.actions.act_window',
4649
'res_model': 'records.retrieval.work.order',
4750
'res_id': work_order.id,
@@ -59,6 +62,9 @@ if records:
5962
<field name="binding_view_types">list</field>
6063
<field name="state">code</field>
6164
<field name="code">
65+
# Import translation function
66+
from odoo.tools.translate import _
67+
6268
# Bulk create destruction work order from selected containers
6369
if records:
6470
# Get partner from first container
@@ -75,7 +81,7 @@ if records:
7581

7682
# Create new destruction work order
7783
work_order = env['container.destruction.work.order'].create({
78-
'name': _('Destruction - %s (%s containers)') % (partner.name, len(records)),
84+
'name': 'Destruction - %s (%s containers)' % (partner.name, len(records)),
7985
'partner_id': partner.id,
8086
'user_id': env.user.id,
8187
'state': 'draft',
@@ -85,13 +91,13 @@ if records:
8591

8692
# Post message
8793
work_order.message_post(
88-
body=_('🔥 Created from bulk action with %d container(s): %s') % (len(records), ', '.join(records.mapped('name'))),
89-
subject=_('Bulk Destruction Order Created')
94+
body='🔥 Created from bulk action with %d container(s): %s' % (len(records), ', '.join(records.mapped('name'))),
95+
subject='Bulk Destruction Order Created'
9096
)
9197

9298
# Return action to open the new work order
9399
action = {
94-
'name': _('Destruction Work Order'),
100+
'name': 'Destruction Work Order',
95101
'type': 'ir.actions.act_window',
96102
'res_model': 'container.destruction.work.order',
97103
'res_id': work_order.id,
@@ -109,6 +115,9 @@ if records:
109115
<field name="binding_view_types">list</field>
110116
<field name="state">code</field>
111117
<field name="code">
118+
# Import translation function
119+
from odoo.tools.translate import _
120+
112121
# Bulk create container access request from selected containers
113122
if records:
114123
# Get partner from first container
@@ -125,23 +134,23 @@ if records:
125134

126135
# Create new portal request for container access
127136
request = env['portal.request'].create({
128-
'name': _('Container Access - %s (%s containers)') % (partner.name, len(records)),
137+
'name': 'Container Access - %s (%s containers)' % (partner.name, len(records)),
129138
'partner_id': partner.id,
130-
'request_type': 'other', # Container access type
139+
'request_type': 'other',
131140
'state': 'submitted',
132-
'description': _('Container Access Request\n\nBulk access request for containers:\n%s') % '\n'.join('• ' + c.name for c in records),
141+
'description': 'Container Access Request\n\nBulk access request for containers:\n%s' % '\n'.join('• ' + c.name for c in records),
133142
'container_ids': [(6, 0, records.ids)],
134143
})
135144

136145
# Post message
137146
request.message_post(
138-
body=_('🔑 Created from bulk action with %d container(s)') % len(records),
139-
subject=_('Bulk Access Request Created')
147+
body='🔑 Created from bulk action with %d container(s)' % len(records),
148+
subject='Bulk Access Request Created'
140149
)
141150

142151
# Return action to open the new request
143152
action = {
144-
'name': _('Container Access Request'),
153+
'name': 'Container Access Request',
145154
'type': 'ir.actions.act_window',
146155
'res_model': 'portal.request',
147156
'res_id': request.id,
@@ -159,6 +168,9 @@ if records:
159168
<field name="binding_view_types">list</field>
160169
<field name="state">code</field>
161170
<field name="code">
171+
# Import translation function
172+
from odoo.tools.translate import _
173+
162174
# Open wizard to add selected containers to existing work order
163175
if records:
164176
# Get partner from first container
@@ -176,7 +188,7 @@ if records:
176188

177189
# Return action to open wizard
178190
action = {
179-
'name': _('Add to Existing Work Order'),
191+
'name': 'Add to Existing Work Order',
180192
'type': 'ir.actions.act_window',
181193
'res_model': 'add.to.work.order.wizard',
182194
'res_id': wizard.id,

0 commit comments

Comments
 (0)