[REF] *: Replace env._t() by _t()

In this commit, all usages of env._t() are replaced by _t().
In templates files, env._t() didn't work because terms used
in attributes where not extracted into the translation files.
Only string are exported from .xml files to translation files.
So, to make it works, we set a variable that is then used
in attributes.
For example :

<t t-set="string_to_translate">String to translate</t>
<Dialog title="string_to_translate>...</Dialog>

task-3292454

closes odoo/odoo#131390

Related: odoo/enterprise#45631
Signed-off-by: Michaël Mattiello (mcm) <mcm@odoo.com>
This commit is contained in:
Pierre Pulinckx (pipu)
2023-08-18 19:17:16 +02:00
parent 48e3f725a2
commit c07181b20b
237 changed files with 1103 additions and 998 deletions
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog";
import { escape } from "@web/core/utils/strings";
import { markup } from "@odoo/owl";
@@ -13,7 +14,7 @@ export const accountMove = {
async addDeletionDialog(component, moveIds) {
const isMoveEndOfChain = await orm.call('account.move', 'check_move_sequence_chain', [moveIds]);
if (!isMoveEndOfChain) {
const message = env._t("This operation will create a gap in the sequence.");
const message = _t("This operation will create a gap in the sequence.");
const confirmationDialogProps = component.deleteConfirmationDialogProps;
confirmationDialogProps.body = markup(`<div class="text-danger">${escape(message)}</div>${escape(confirmationDialogProps.body)}`);
dialog.add(ConfirmationDialog, confirmationDialogProps);
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { registry } from "@web/core/registry";
import { usePopover } from "@web/core/popover/popover_hook";
import { useService } from "@web/core/utils/hooks";
@@ -53,7 +54,7 @@ export class AccountPaymentField extends Component {
onInfoClick(ev, idx) {
this.popover.open(ev.currentTarget, {
title: this.env._t("Journal Entry Info"),
title: _t("Journal Entry Info"),
...this.lines[idx],
_onRemoveMoveReconcile: this.removeMoveReconcile.bind(this),
_onOpenMove: this.openMove.bind(this),
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { registry } from "@web/core/registry";
import { SelectionField, selectionField } from "@web/views/fields/selection/selection_field";
@@ -7,14 +8,14 @@ export class AccountTypeSelection extends SelectionField {
get hierarchyOptions() {
const opts = this.options;
return [
{ name: this.env._t('Balance Sheet') },
{ name: this.env._t('Assets'), children: opts.filter(x => x[0] && x[0].startsWith('asset')) },
{ name: this.env._t('Liabilities'), children: opts.filter(x => x[0] && x[0].startsWith('liability')) },
{ name: this.env._t('Equity'), children: opts.filter(x => x[0] && x[0].startsWith('equity')) },
{ name: this.env._t('Profit & Loss') },
{ name: this.env._t('Income'), children: opts.filter(x => x[0] && x[0].startsWith('income')) },
{ name: this.env._t('Expense'), children: opts.filter(x => x[0] && x[0].startsWith('expense')) },
{ name: this.env._t('Other'), children: opts.filter(x => x[0] && x[0] === 'off_balance') },
{ name: _t('Balance Sheet') },
{ name: _t('Assets'), children: opts.filter(x => x[0] && x[0].startsWith('asset')) },
{ name: _t('Liabilities'), children: opts.filter(x => x[0] && x[0].startsWith('liability')) },
{ name: _t('Equity'), children: opts.filter(x => x[0] && x[0].startsWith('equity')) },
{ name: _t('Profit & Loss') },
{ name: _t('Income'), children: opts.filter(x => x[0] && x[0].startsWith('income')) },
{ name: _t('Expense'), children: opts.filter(x => x[0] && x[0].startsWith('expense')) },
{ name: _t('Other'), children: opts.filter(x => x[0] && x[0] === 'off_balance') },
];
}
}
@@ -105,7 +105,7 @@ export class AccountDropZone extends Component {
uploadInput.dispatchEvent(new Event("change"));
} else {
this.notificationService.add(
this.env._t("Could not upload files"),
_t("Could not upload files"),
{
type: "danger",
});
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { registry } from "@web/core/registry";
import { useService } from "@web/core/utils/hooks";
import { standardFieldProps } from "@web/views/fields/standard_field_props";
@@ -27,7 +28,7 @@ export class JournalDashboardActivity extends Component {
async openActivity(activity) {
this.action.doAction({
type: 'ir.actions.act_window',
name: this.env._t('Journal Entry'),
name: _t('Journal Entry'),
target: 'current',
res_id: activity.res_id,
res_model: 'account.move',
@@ -38,7 +39,7 @@ export class JournalDashboardActivity extends Component {
openAllActivities(e) {
this.action.doAction({
type: 'ir.actions.act_window',
name: this.env._t('Journal Entries'),
name: _t('Journal Entries'),
res_model: 'account.move',
views: [[false, 'kanban'], [false, 'form']],
search_view_id: [false],
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { registry } from "@web/core/registry";
import { useService } from "@web/core/utils/hooks";
import { FileInput } from "@web/core/file_input/file_input";
@@ -37,7 +38,7 @@ export class MailAttachments extends Component {
for (const file of files) {
if (file.error) {
return this.notification.add(file.error, {
title: this.env._t("Uploading error"),
title: _t("Uploading error"),
type: "danger",
});
}
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { escape } from "@web/core/utils/strings";
import { registry } from "@web/core/registry";
import { pick } from "@web/core/utils/objects";
@@ -55,8 +56,8 @@ class PeppolSettingsButtons extends Component {
}
showConfirmation(warning, methodName) {
const message = this.env._t(warning);
const confirmMessage = this.env._t("You will not be able to send or receive Peppol documents in Odoo anymore. Are you sure you want to proceed?");
const message = _t(warning);
const confirmMessage = _t("You will not be able to send or receive Peppol documents in Odoo anymore. Are you sure you want to proceed?");
this.dialogService.add(ConfirmationDialog, {
body: markup(
`<div class="text-danger">${escape(message)}</div>
@@ -90,7 +91,7 @@ class PeppolSettingsButtons extends Component {
// changes on both the client side and the iap side need to be saved within one method
await this._callConfigMethod("button_update_peppol_user_data", true);
this.notification.add(
this.env._t("Contact details were updated."),
_t("Contact details were updated."),
{ type: "success" }
);
}
@@ -69,7 +69,7 @@ export class AnalyticDistribution extends Component {
onClose: () => {
this.mainRef.el.focus();
},
fieldString: this.env._t("Analytic Distribution Template"),
fieldString: _t("Analytic Distribution Template"),
});
this.allPlans = [];
this.lastAccount = this.props.account_field && this.props.record.data[this.props.account_field] || false;
@@ -202,7 +202,7 @@ export class AnalyticDistribution extends Component {
optionsSourceAnalytic(groupId) {
return {
placeholder: this.env._t("Loading..."),
placeholder: _t("Loading..."),
options:(searchTerm) => this.loadOptionsSourceAnalytic(groupId, searchTerm),
};
}
@@ -249,7 +249,7 @@ export class AnalyticDistribution extends Component {
if (records.length) {
options.push({
label: this.env._t("View all"),
label: _t("View all"),
action: (editedTag) => this.onViewAll(searchTerm, editedTag),
classList: "o_m2o_dropdown_option o_m2o_dropdown_option_view_all",
});
@@ -257,7 +257,7 @@ export class AnalyticDistribution extends Component {
else {
options.push({
label: this.env._t("No Analytic Accounts for this plan"),
label: _t("No Analytic Accounts for this plan"),
classList: "o_m2o_no_result",
unselectable: true,
});
@@ -271,14 +271,14 @@ export class AnalyticDistribution extends Component {
if (searchTerm.length) {
dynamicFilters = [
{
description: this.env._t("Quick search: %s", searchTerm),
description: _t("Quick search: %s", searchTerm),
domain: this.searchAnalyticDomain(searchTerm),
},
];
}
this.selectCreateIsOpen = true;
this.addDialog(SelectCreateDialog, {
title: this.env._t("Search: Analytic Account"),
title: _t("Search: Analytic Account"),
noCreate: true,
multiSelect: true,
resModel: 'account.analytic.account',
@@ -1,14 +1,15 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { computeScore } from "./password_policy";
const { Component, xml } = owl;
export class Meter extends Component {
get title() {
return this.env._t(
return _t(
"Required: %s\n\nHint: to increase password strength, increase length, use multiple words, and use non-letter characters.",
String(this.props.required) || this.env._t("no requirements")
String(this.props.required) || _t("no requirements")
);
}
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { registry } from "@web/core/registry";
import { getVisibleElements } from "@web/core/utils/ui";
import { MacroEngine } from "@web/core/macro";
@@ -78,8 +79,8 @@ export const barcodeGenericHandlers = {
if (fn) {
fn();
} else {
notification.add(env._t("Barcode: ") + `'${barcode}'`, {
title: env._t("Unknown barcode command"),
notification.add(_t("Barcode: ") + `'${barcode}'`, {
title: _t("Unknown barcode command"),
type: "danger"
});
}
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { isBarcodeScannerSupported, scanBarcode } from "@web/webclient/barcode/barcode_scanner";
import { Component } from "@odoo/owl";
import { useService } from "@web/core/utils/hooks";
@@ -29,7 +30,7 @@ export class BarcodeScanner extends Component {
window.navigator.vibrate(100);
}
} else {
this.notification.add(error || this.env._t("Please, Scan again!"), {
this.notification.add(error || _t("Please, Scan again!"), {
type: "warning",
});
}
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { Component, onWillStart, onMounted, useState } from "@odoo/owl";
import { registry } from "@web/core/registry";
import { useService } from "@web/core/utils/hooks";
@@ -26,7 +27,7 @@ export class ImportAction extends Component {
this.router = useService("router");
this.user = useService("user");
this.env.config.setDisplayName(this.props.action.name || this.env._t("Import a File"));
this.env.config.setDisplayName(this.props.action.name || _t("Import a File"));
this.resModel = this.props.action.params.model;
this.model = useImportModel({
env: this.env,
@@ -124,7 +125,7 @@ export class ImportAction extends Component {
this.state.filename = files[0].name;
this.state.importMessages = [];
this.model.block(this.env._t("Loading file..."));
this.model.block(_t("Loading file..."));
const { res, error } = await this.model.updateData(true);
if (error) {
@@ -137,7 +138,7 @@ export class ImportAction extends Component {
}
async handleImport(isTest = true) {
const message = isTest ? this.env._t("Testing") : this.env._t("Importing");
const message = isTest ? _t("Testing") : _t("Importing");
let blockComponent;
if (this.isBatched) {
@@ -170,7 +171,7 @@ export class ImportAction extends Component {
}
if (!isTest && res.ids.length) {
this.notification.add(this.env._t("%s records successfully imported", res.ids.length), {
this.notification.add(_t("%s records successfully imported", res.ids.length), {
type: "success",
});
this.exit();
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { Dropdown } from "@web/core/dropdown/dropdown";
import { registry } from "@web/core/registry";
import { useAutofocus, useService } from "@web/core/utils/hooks";
@@ -35,12 +36,8 @@ export class AddToBoard extends Component {
async addToBoard() {
const { domain, globalContext } = this.env.searchModel;
const {
comparison,
context,
groupBys,
orderBy,
} = this.env.searchModel.getPreFavoriteValues();
const { comparison, context, groupBys, orderBy } =
this.env.searchModel.getPreFavoriteValues();
const contextToSave = {
...globalContext,
...context,
@@ -60,15 +57,15 @@ export class AddToBoard extends Component {
if (result) {
this.notification.add(
this.env._t("Please refresh your browser for the changes to take effect."),
_t("Please refresh your browser for the changes to take effect."),
{
title: this.env._t("“%s” added to dashboard", this.state.name),
title: _t("“%s” added to dashboard", this.state.name),
type: "warning",
}
);
this.state.name = this.env.config.getDisplayName();
} else {
this.notification.add(this.env._t("Could not add filter to dashboard"), {
this.notification.add(_t("Could not add filter to dashboard"), {
type: "danger",
});
}
+2 -1
View File
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { browser } from "@web/core/browser/browser";
import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog";
import { Dropdown } from "@web/core/dropdown/dropdown";
@@ -92,7 +93,7 @@ export class BoardController extends Component {
closeAction(column, action) {
this.dialogService.add(ConfirmationDialog, {
body: this.env._t("Are you sure that you want to remove this item?"),
body: _t("Are you sure that you want to remove this item?"),
confirm: () => {
const index = column.actions.indexOf(action);
column.actions.splice(index, 1);
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { browser } from "@web/core/browser/browser";
import { registry } from "@web/core/registry";
import { session } from "@web/session";
@@ -28,13 +29,13 @@ export const assetsWatchdogService = {
// We wait until things settle down
browser.clearTimeout(bundleNotifTimerID);
bundleNotifTimerID = browser.setTimeout(() => {
notification.add(env._t("The page appears to be out of date."), {
title: env._t("Refresh"),
notification.add(_t("The page appears to be out of date."), {
title: _t("Refresh"),
type: "warning",
sticky: true,
buttons: [
{
name: env._t("Refresh"),
name: _t("Refresh"),
primary: true,
onClick: () => {
browser.location.reload();
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { browser } from "@web/core/browser/browser";
import { ConnectionLostError } from "@web/core/network/rpc_service";
import { registry } from "@web/core/registry";
@@ -44,7 +45,7 @@ export const calendarNotificationService = {
},
buttons: [
{
name: env._t("OK"),
name: _t("OK"),
primary: true,
onClick: async () => {
await rpc("/calendar/notify_ack");
@@ -52,7 +53,7 @@ export const calendarNotificationService = {
},
},
{
name: env._t("Details"),
name: _t("Details"),
onClick: async () => {
await action.doAction({
type: 'ir.actions.act_window',
@@ -65,7 +66,7 @@ export const calendarNotificationService = {
},
},
{
name: env._t("Snooze"),
name: _t("Snooze"),
onClick: () => {
notificationRemove();
},
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { Dialog } from "@web/core/dialog/dialog";
const { Component } = owl;
@@ -9,15 +10,15 @@ export class AskRecurrenceUpdatePolicyDialog extends Component {
this.possibleValues = {
self_only: {
checked: true,
label: this.env._t("This event"),
label: _t("This event"),
},
future_events: {
checked: false,
label: this.env._t("This and following events"),
label: _t("This and following events"),
},
all_events: {
checked: false,
label: this.env._t("All events"),
label: _t("All events"),
},
};
}
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-name="calendar.AskRecurrenceUpdatePolicyDialog">
<Dialog size="'sm'" title="env._t('Edit Recurrent event')">
<t t-set="edit_recurrent_event">Edit Recurrent event</t>
<Dialog size="'sm'" title="edit_recurrent_event">
<t t-foreach="Object.entries(possibleValues)" t-as="value" t-key="value[0]">
<t t-set="name" t-value="value[0]"/>
<t t-set="state" t-value="value[1]"/>
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { CalendarController } from "@web/views/calendar/calendar_controller";
import { useService } from "@web/core/utils/hooks";
import { onWillStart } from "@odoo/owl";
@@ -101,7 +102,7 @@ export class AttendeeCalendarController extends CalendarController {
configureCalendarProviderSync(providerName) {
this.actionService.doAction({
name: this.env._t('Connect your Calendar'),
name: _t('Connect your Calendar'),
type: 'ir.actions.act_window',
res_model: 'calendar.provider.config',
views: [[false, "form"]],
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { CalendarModel } from "@web/views/calendar/calendar_model";
import { askRecurrenceUpdatePolicy } from "@calendar/views/ask_recurrence_update_policy_hook";
import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog";
@@ -141,7 +142,7 @@ export class AttendeeCalendarModel extends CalendarModel {
} else {
const confirm = await new Promise((resolve) => {
this.dialog.add(ConfirmationDialog, {
body: this.env._t("Are you sure you want to delete this record?"),
body: _t("Are you sure you want to delete this record?"),
confirm: resolve.bind(null, true),
}, {
onClose: resolve.bind(null, false),
+2 -1
View File
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog";
import { registry } from "@web/core/registry";
import { FormController } from "@web/views/form/form_controller";
@@ -13,7 +14,7 @@ export class FleetFormController extends FormController {
const menuItems = super.getStaticActionMenuItems();
menuItems.archive.callback = () => {
const dialogProps = {
body: this.env._t(
body: _t(
"Every service and contract of this vehicle will be considered as archived. Are you sure that you want to archive this record?"
),
confirm: () => this.model.root.archive(),
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { AttendeeCalendarController } from "@calendar/views/attendee_calendar/attendee_calendar_controller";
import { patch } from "@web/core/utils/patch";
import { useService } from "@web/core/utils/hooks";
@@ -24,14 +25,14 @@ patch(AttendeeCalendarController.prototype, {
} else if (syncResult.status === "need_config_from_admin") {
if (this.isSystemUser) {
this.dialog.add(ConfirmationDialog, {
title: this.env._t("Configuration"),
body: this.env._t("The Google Synchronization needs to be configured before you can use it, do you want to do it now?"),
title: _t("Configuration"),
body: _t("The Google Synchronization needs to be configured before you can use it, do you want to do it now?"),
confirm: this.actionService.doAction.bind(this.actionService, syncResult.action),
});
} else {
this.dialog.add(AlertDialog, {
title: this.env._t("Configuration"),
body: this.env._t("An administrator needs to configure Google Synchronization before you can use it!"),
title: _t("Configuration"),
body: _t("An administrator needs to configure Google Synchronization before you can use it!"),
});
}
} else if (syncResult.status === "need_refresh") {
@@ -41,7 +42,7 @@ patch(AttendeeCalendarController.prototype, {
async onStopGoogleSynchronization() {
this.dialog.add(ConfirmationDialog, {
body: this.env._t("You are about to stop the synchronization of your calendar with Google. Are you sure you want to continue?"),
body: _t("You are about to stop the synchronization of your calendar with Google. Are you sure you want to continue?"),
confirm: async () => {
await this.orm.call(
"res.users",
@@ -49,9 +50,9 @@ patch(AttendeeCalendarController.prototype, {
[[this.user.userId]],
);
this.notification.add(
this.env._t("The synchronization with Google calendar was successfully stopped."),
_t("The synchronization with Google calendar was successfully stopped."),
{
title: this.env._t("Success"),
title: _t("Success"),
type: "success",
},
);
+2 -1
View File
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { registry } from "@web/core/registry";
import { preferencesItem } from "@web/webclient/user_menu/user_menu_items";
@@ -8,7 +9,7 @@ export function hrPreferencesItem(env) {
{},
preferencesItem(env),
{
description: env._t('My Profile'),
description: _t('My Profile'),
}
);
}
@@ -1,17 +1,17 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { useService } from "@web/core/utils/hooks";
const { useComponent, useEnv } = owl;
const { useComponent } = owl;
export function useArchiveEmployee() {
const component = useComponent();
const env = useEnv();
const action = useService("action");
return (id) => {
action.doAction({
type: 'ir.actions.act_window',
name: env._t('Employee Termination'),
name: _t('Employee Termination'),
res_model: 'hr.departure.wizard',
views: [[false, 'form']],
view_mode: 'form',
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { CardLayout } from "@hr_attendance/components/card_layout/card_layout";
import { Component, onWillStart, onWillUnmount, useState } from "@odoo/owl";
import { deserializeDateTime } from "@web/core/l10n/dates";
@@ -72,7 +73,7 @@ export class GreetingMessage extends Component {
.toFormat("hh-mm")
.split("-");
this.hours_today = this.env._t("%(hours)s hours, %(minutes)s minutes", {
this.hours_today = _t("%(hours)s hours, %(minutes)s minutes", {
hours: duration[0],
minutes: duration[1],
});
@@ -133,7 +134,6 @@ export class GreetingMessage extends Component {
}
setWelcomeMessage() {
const { _t } = this.env;
const now = this.attendance.check_in;
if (now.hour < 5) {
this.state.message = _t("Good night");
@@ -169,7 +169,6 @@ export class GreetingMessage extends Component {
}
setFarewellMessage() {
const { _t } = this.env;
const now = this.attendance.check_out;
if (this.previous_attendance_change_date) {
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { useBus, useService } from '@web/core/utils/hooks';
const { useRef, useEffect, useState } = owl;
@@ -93,7 +94,7 @@ export const ExpenseDocumentUpload = (T) => class ExpenseDocumentUpload extends
const attachmentIds = attachments.map((a) => a.id);
if (!attachmentIds.length) {
this.notification.add(
this.env._t('An error occurred during the upload')
_t('An error occurred during the upload')
);
return;
}
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { useService } from "@web/core/utils/hooks";
const { onMounted, onPatched, useRef } = owl;
@@ -33,7 +34,7 @@ export const ExpenseMobileQRCode = (T) => class ExpenseMobileQRCode extends T {
const url = ev.currentTarget && ev.currentTarget.href;
if (!this.env.isSmall) {
this.actionService.doAction({
name: this.env._t("Download our App"),
name: _t("Download our App"),
type: "ir.actions.client",
tag: 'expense_qr_code_modal',
target: "new",
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { useService } from "@web/core/utils/hooks";
import { registry } from "@web/core/registry";
import { FormController } from "@web/views/form/form_controller";
@@ -25,7 +26,7 @@ export class ExpenseFormController extends FormController {
) {
return new Promise((resolve) => {
this.dialogService.add(ConfirmationDialog, {
body: this.env._t("An expense of same category, amount and date already exists."),
body: _t("An expense of same category, amount and date already exists."),
confirm: async () => {
await this.orm.call("hr.expense", "action_approve_duplicates", [record.resId]);
resolve(true);
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog";
import { CalendarController } from '@web/views/calendar/calendar_controller';
import { FormViewDialog } from '@web/views/view_dialogs/form_view_dialog';
@@ -49,7 +50,7 @@ export class TimeOffCalendarController extends CalendarController {
this.displayDialog(FormViewDialog, {
resModel: 'hr.leave',
title: this.env._t('New Time Off'),
title: _t('New Time Off'),
viewId: this.model.formViewId,
onRecordSaved: () => {
this.model.load();
@@ -71,7 +72,7 @@ export class TimeOffCalendarController extends CalendarController {
this.displayDialog(FormViewDialog, {
resModel: 'hr.leave.allocation',
title: this.env._t('New Allocation'),
title: _t('New Allocation'),
context: context,
});
}
@@ -79,8 +80,8 @@ export class TimeOffCalendarController extends CalendarController {
deleteRecord(record) {
if (!record.can_cancel) {
this.displayDialog(ConfirmationDialog, {
title: this.env._t("Confirmation"),
body: this.env._t("Are you sure you want to delete this record?"),
title: _t("Confirmation"),
body: _t("Are you sure you want to delete this record?"),
confirm: async () => {
await this.model.unlinkRecord(record.id);
this.env.timeOffBus.trigger('update_dashboard');
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { CalendarYearRenderer } from '@web/views/calendar/calendar_year/calendar_year_renderer';
import { useService } from "@web/core/utils/hooks";
@@ -35,7 +36,7 @@ export class TimeOffCalendarYearRenderer extends CalendarYearRenderer {
return Object.assign(super.options, {
weekNumbers: true,
weekNumbersWithinDays: false,
weekLabel: this.env._t('Week'),
weekLabel: _t('Week'),
});
}
+3 -5
View File
@@ -1,9 +1,8 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { useService } from "@web/core/utils/hooks";
const { useEnv } = owl;
export function useMandatoryDays(props) {
return (info) => {
const date = luxon.DateTime.fromJSDate(info.date).toISODate();
@@ -24,11 +23,10 @@ export function useMandatoryDays(props) {
export function useLeaveCancelWizard() {
const action = useService('action');
const env = useEnv();
return (leaveId, callback) => {
action.doAction({
name: env._t('Delete Confirmation'),
name: _t('Delete Confirmation'),
type: "ir.actions.act_window",
res_model: "hr.holidays.cancel.leave",
target: "new",
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { patch } from "@web/core/utils/patch";
import { useService } from "@web/core/utils/hooks";
import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog";
@@ -14,7 +15,7 @@ patch(AttendeeCalendarController.prototype, {
async editRecord(record, context = {}, shouldFetchFormViewId = true) {
if ('rawRecord' in record && 'date' in record.rawRecord) {
return this.action.doAction('hr_homeworking.hr_employee_location_action',{
name: this.env._t("Edit Record"),
name: _t("Edit Record"),
additionalContext: {
'default_start_date': serializeDate(record.start),
'default_end_date_create': serializeDate(record.end),
@@ -31,7 +32,7 @@ patch(AttendeeCalendarController.prototype, {
createRecord(record) {
if (record.homework) {
return this.action.doAction('hr_homeworking.hr_employee_location_action',{
name: this.env._t("Create Record"),
name: _t("Create Record"),
additionalContext: {
'default_start_date': serializeDate(record.start),
'default_end_date_create': serializeDate(record.start),
@@ -51,8 +52,8 @@ patch(AttendeeCalendarController.prototype, {
this.openRecurringDeletionWizardForHomework(record);
} else {
this.displayDialog(ConfirmationDialog, {
title: this.env._t("Confirmation"),
body: this.env._t("Are you sure you want to delete this work location?"),
title: _t("Confirmation"),
body: _t("Are you sure you want to delete this work location?"),
confirm: () => {
this.orm.call('hr.employee.location', "unlink", [
record.rawRecord.idInDB,
@@ -1,8 +1,8 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import session from 'web.session'
import { useService } from "@web/core/utils/hooks";
import { useEnv } from "@odoo/owl";
/**
* Redirect to the sub employee kanban view.
@@ -16,7 +16,6 @@ export function onEmployeeSubRedirect() {
const actionService = useService('action');
const orm = useService('orm');
const rpc = useService('rpc');
const env = useEnv();
return async (event) => {
const employeeId = parseInt(event.currentTarget.dataset.employeeId);
@@ -32,7 +31,7 @@ export function onEmployeeSubRedirect() {
});
let action = await orm.call('hr.employee', 'get_formview_action', [employeeId]);
action = {...action,
name: env._t('Team'),
name: _t('Team'),
view_mode: 'kanban,list,form',
views: [[false, 'kanban'], [false, 'list'], [false, 'form']],
domain: [['id', 'in', subordinateIds]],
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { ListRenderer } from "@web/views/list/list_renderer";
export class CommonSkillsListRenderer extends ListRenderer {
@@ -26,7 +27,7 @@ export class CommonSkillsListRenderer extends ListRenderer {
if (grouped[group[1]] === undefined) {
grouped[group[1]] = {
id: parseInt(group[0]),
name: group[1] || this.env._t('Other'),
name: group[1] || _t('Other'),
list: {
records: [],
},
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { CalendarModel } from "@web/views/calendar/calendar_model";
import { useWorkEntry } from "@hr_work_entry_contract/views/work_entry_hook";
@@ -22,7 +23,7 @@ export class WorkEntryCalendarModel extends CalendarModel {
makeFilterAll() {
return {
...super.makeFilterAll(...arguments),
label: this.env._t("Everybody's work entries"),
label: _t("Everybody's work entries"),
active: true,
};
}
@@ -2,6 +2,7 @@
import { Dialog } from "@web/core/dialog/dialog";
import { registry } from "@web/core/registry";
import { useService } from "@web/core/utils/hooks";
import { _t } from "@web/core/l10n/translation";
const { Component, onWillStart } = owl;
@@ -20,7 +21,6 @@ class InsufficientCreditDialog extends Component {
trial: errorData.trial,
});
this.style = errorData.body ? "padding:0;" : "";
const { _t } = this.env;
const { isEnterprise } = odoo.info;
if (errorData.trial && isEnterprise) {
this.buttonMessage = _t("Start a Trial at Odoo");
@@ -3,7 +3,7 @@
import { makeRoot, makeShadow } from "@im_livechat/embed/boot_helpers";
import { LivechatRoot } from "@im_livechat/embed/frontend/livechat_root";
import { serverUrl, isAvailable } from "@im_livechat/embed/livechat_data";
import { _t } from "@web/core/l10n/translation";
import { App } from "@odoo/owl";
import { templates } from "@web/core/assets";
@@ -34,7 +34,7 @@ export const livechatBootService = {
env,
templates,
translatableAttributes: ["data-tooltip"],
translateFn: env._t,
translateFn: _t,
dev: env.debug,
}).mount(shadow);
});
@@ -2,11 +2,11 @@
import { AlertDialog } from "@web/core/confirmation_dialog/confirmation_dialog";
import { registry } from "@web/core/registry";
import { _t } from "@web/core/l10n/translation";
async function actionGetDrive(env, action, type) {
const { drive_id, sign_host: host } = action.params;
const { orm, http, dialog, action: actionService } = env.services;
const { _t } = env;
let route = host;
let key, method;
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { useBus, useService } from "@web/core/utils/hooks";
export const LunchRendererMixin = (T) => class LunchRendererMixin extends T {
@@ -19,7 +20,7 @@ export const LunchRendererMixin = (T) => class LunchRendererMixin extends T {
let action = {
res_model: 'lunch.order',
name: this.env._t('Configure Your Order'),
name: _t('Configure Your Order'),
type: 'ir.actions.act_window',
views: [[false, 'form']],
target: 'new',
@@ -511,10 +511,9 @@ export class Composer extends Component {
this.state.active = true;
el.focus();
} else if (attachments.some(({ uploading }) => Boolean(uploading))) {
this.env.services.notification.add(
this.env._t("Please wait while the file is uploading."),
{ type: "warning" }
);
this.env.services.notification.add(_t("Please wait while the file is uploading."), {
type: "warning",
});
}
}
@@ -1,5 +1,6 @@
/* @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { registry } from "@web/core/registry";
export function manageMessages({ component, env }) {
@@ -7,7 +8,7 @@ export function manageMessages({ component, env }) {
if (!resId) {
return null; // No record
}
const description = env._t("Manage Messages");
const description = _t("Manage Messages");
return {
type: "item",
description,
@@ -1,5 +1,6 @@
/* @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { useMessaging } from "@mail/core/common/messaging_hook";
import { Component, useState } from "@odoo/owl";
@@ -47,7 +48,7 @@ export class ActivityController extends Component {
resModel: this.props.resModel,
searchViewId: this.env.searchModel.searchViewId,
domain: this.model.originalDomain,
title: this.env._t("Search: %s", this.props.archInfo.title),
title: _t("Search: %s", this.props.archInfo.title),
multiSelect: false,
context: this.props.context,
onSelected: async (resIds) => {
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { Domain } from '@web/core/domain';
import { registry } from '@web/core/registry';
import { Dropdown } from "@web/core/dropdown/dropdown";
@@ -132,7 +133,7 @@ export class FieldMany2OneMailingFilter extends Many2OneField {
const filterName = filterInput.value.trim();
if (filterName.length === 0) {
this.notification.add(
this.env._t("Please provide a name for the filter"),
_t("Please provide a name for the filter"),
{type: 'danger'}
);
// Keep the drop-down open, and re-focus the input
@@ -274,7 +274,7 @@ export class MassMailingHtmlField extends HtmlField {
el.style.setProperty('pointer-events', 'none');
});
this.mobilePreview = this.dialog.add(MassMailingMobilePreviewDialog, {
title: this.env._t("Mobile Preview"),
title: _t("Mobile Preview"),
preview: mailingHtml.body.innerHTML,
}, {
onClose: () => $previewBtn.prop('disabled', false),
@@ -382,7 +382,7 @@ export class MassMailingHtmlField extends HtmlField {
const $editable = this.wysiwyg.$editable.find('.o_editable');
this.$editorMessageElements = $editable
.not('[data-editor-message]')
.attr('data-editor-message', this.env._t('DRAG BUILDING BLOCKS HERE'));
.attr('data-editor-message', _t('DRAG BUILDING BLOCKS HERE'));
$editable.filter(':empty').attr('contenteditable', false);
// Wait the next tick because some mutation have to be processed by
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { AttendeeCalendarController } from "@calendar/views/attendee_calendar/attendee_calendar_controller";
import { patch } from "@web/core/utils/patch";
import { useService } from "@web/core/utils/hooks";
@@ -24,14 +25,14 @@ patch(AttendeeCalendarController.prototype, {
} else if (syncResult.status === "need_config_from_admin") {
if (this.isSystemUser) {
this.dialog.add(ConfirmationDialog, {
title: this.env._t("Configuration"),
body: this.env._t("The Outlook Synchronization needs to be configured before you can use it, do you want to do it now?"),
title: _t("Configuration"),
body: _t("The Outlook Synchronization needs to be configured before you can use it, do you want to do it now?"),
confirm: this.actionService.doAction.bind(this.actionService, syncResult.action),
});
} else {
this.dialog.add(AlertDialog, {
title: this.env._t("Configuration"),
body: this.env._t("An administrator needs to configure Outlook Synchronization before you can use it!"),
title: _t("Configuration"),
body: _t("An administrator needs to configure Outlook Synchronization before you can use it!"),
});
}
} else if (syncResult.status === "need_refresh") {
@@ -41,7 +42,7 @@ patch(AttendeeCalendarController.prototype, {
async onStopMicrosoftSynchronization() {
this.dialog.add(ConfirmationDialog, {
body: this.env._t("You are about to stop the synchronization of your calendar with Outlook. Are you sure you want to continue?"),
body: _t("You are about to stop the synchronization of your calendar with Outlook. Are you sure you want to continue?"),
confirm: async () => {
await this.orm.call(
"res.users",
@@ -49,9 +50,9 @@ patch(AttendeeCalendarController.prototype, {
[[this.user.userId]],
);
this.notification.add(
this.env._t("The synchronization with Outlook calendar was successfully stopped."),
_t("The synchronization with Outlook calendar was successfully stopped."),
{
title: this.env._t("Success"),
title: _t("Success"),
type: "success",
},
);
@@ -1,4 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { Dropdown } from "@web/core/dropdown/dropdown";
import { DropdownItem } from "@web/core/dropdown/dropdown_item";
@@ -7,10 +9,10 @@ const { Component } = owl;
export class BomOverviewDisplayFilter extends Component {
setup() {
this.displayOptions = {
availabilities: this.env._t('Availabilities'),
leadTimes: this.env._t('Lead Times'),
costs: this.env._t('Costs'),
operations: this.env._t('Operations'),
availabilities: _t('Availabilities'),
leadTimes: _t('Lead Times'),
costs: _t('Costs'),
operations: _t('Operations'),
};
}
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { useService } from "@web/core/utils/hooks";
import { formatFloat, formatFloatTime, formatMonetary } from "@web/views/fields/formatters";
@@ -53,7 +54,7 @@ export class BomOverviewLine extends Component {
async goToAttachment() {
return this.actionService.doAction({
name: this.env._t("Attachments"),
name: _t("Attachments"),
type: "ir.actions.act_window",
res_model: "mrp.document",
domain: [["id", "in", this.data.attachment_ids]],
@@ -1,19 +1,21 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { BomOverviewDisplayFilter } from "../bom_overview_display_filter/mrp_bom_overview_display_filter";
export class MoOverviewDisplayFilter extends BomOverviewDisplayFilter {
setup() {
if (!this.props.limited) {
this.displayOptions = {
replenishments: this.env._t("Replenishments"),
availabilities: this.env._t("Availabilities"),
receipts: this.env._t("Receipts"),
replenishments: _t("Replenishments"),
availabilities: _t("Availabilities"),
receipts: _t("Receipts"),
};
}
this.displayOptions = {
...(this.displayOptions || {}),
moCosts: this.env._t("MO Costs"),
productCosts: this.env._t("Product Costs"),
moCosts: _t("MO Costs"),
productCosts: _t("Product Costs"),
};
}
}
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { Component } from "@odoo/owl";
import { useService } from "@web/core/utils/hooks";
import { formatFloat, formatFloatTime, formatMonetary } from "@web/views/fields/formatters";
@@ -111,7 +112,7 @@ export class MoOverviewLine extends Component {
}
get foldButtonTitle() {
return this.props.isFolded ? this.env._t("Unfold") : this.env._t("Fold");
return this.props.isFolded ? _t("Unfold") : _t("Fold");
}
get forecastAction() {
@@ -45,7 +45,7 @@ export class SlidesViewer extends CharField {
onLoadFailed() {
this.state.isValid = false;
this.notification.add(this.env._t("Could not display the selected spreadsheet"), {
this.notification.add(_t("Could not display the selected spreadsheet"), {
type: "danger",
});
}
@@ -1,12 +1,13 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { registry } from "@web/core/registry";
import { Mutex } from "@web/core/utils/concurrency";
import { session } from "@web/session";
import { ErrorPopup } from "@point_of_sale/app/errors/popups/error_popup";
import { ErrorBarcodePopup } from "@point_of_sale/app/barcode/error_popup/barcode_error_popup";
import { BarcodeParser } from "@barcodes/js/barcode_parser";
import { GS1BarcodeError } from '@barcodes_gs1_nomenclature/js/barcode_parser';
import { GS1BarcodeError } from "@barcodes_gs1_nomenclature/js/barcode_parser";
export class BarcodeReader {
static serviceDependencies = ["popup", "hardware_proxy"];
@@ -130,7 +131,9 @@ export const barcodeReaderService = {
orm,
session.fallback_nomenclature_id
);
barcodeReader.fallbackParser = new BarcodeParser({ nomenclature: fallbackNomenclature });
barcodeReader.fallbackParser = new BarcodeParser({
nomenclature: fallbackNomenclature,
});
}
barcode.bus.addEventListener("barcode_scanned", (ev) => {
@@ -138,8 +141,8 @@ export const barcodeReaderService = {
barcodeReader.scan(ev.detail.barcode);
} else {
popup.add(ErrorPopup, {
title: env._t("Unable to parse barcode"),
body: env._t(
title: _t("Unable to parse barcode"),
body: _t(
"No barcode nomenclature has been configured. This can be changed in the configuration settings."
),
});
@@ -16,6 +16,6 @@ export class ErrorBarcodePopup extends ErrorPopup {
};
get translatedMessage() {
return this.env._t(this.props.message);
return _t(this.props.message);
}
}
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { parseFloat } from "@web/views/fields/parsers";
import { Transition } from "@web/core/transition";
import { constrain, getLimits, useMovable } from "@point_of_sale/app/utils/movable_hook";
@@ -93,8 +94,8 @@ export class DebugWidget extends Component {
}
async deleteOrders() {
const { confirmed } = await this.popup.add(ConfirmPopup, {
title: this.env._t("Delete Paid Orders?"),
body: this.env._t(
title: _t("Delete Paid Orders?"),
body: _t(
"This operation will permanently destroy all paid orders from the local storage. You will lose all the data. This operation cannot be undone."
),
});
@@ -105,8 +106,8 @@ export class DebugWidget extends Component {
}
async deleteUnpaidOrders() {
const { confirmed } = await this.popup.add(ConfirmPopup, {
title: this.env._t("Delete Unpaid Orders?"),
body: this.env._t(
title: _t("Delete Unpaid Orders?"),
body: _t(
"This operation will destroy all unpaid orders in the browser. You will lose all the unsaved data and exit the point of sale. This operation cannot be undone."
),
});
@@ -132,7 +133,10 @@ export class DebugWidget extends Component {
}
}
get paidOrdersFilename() {
return `${this.env._t("paid orders")} ${serializeDateTime(DateTime.now()).replace(/:|\s/gi, "-")}.json`;
return `${_t("paid orders")} ${serializeDateTime(DateTime.now()).replace(
/:|\s/gi,
"-"
)}.json`;
}
get paidOrdersURL() {
var URL = window.URL || window.webkitURL;
@@ -148,7 +152,10 @@ export class DebugWidget extends Component {
}
}
get unpaidOrdersFilename() {
return `${this.env._t("unpaid orders")} ${serializeDateTime(DateTime.now()).replace(/:|\s/gi, "-")}.json`;
return `${_t("unpaid orders")} ${serializeDateTime(DateTime.now()).replace(
/:|\s/gi,
"-"
)}.json`;
}
get unpaidOrdersURL() {
var URL = window.URL || window.webkitURL;
@@ -29,11 +29,11 @@ export class ErrorTracebackPopup extends ErrorPopup {
return URL.createObjectURL(blob);
}
get tracebackFilename() {
return `${this.env._t("error")} ${serializeDateTime(DateTime.now()).replace(/:|\s/gi, "-")}.txt`;
return `${_t("error")} ${serializeDateTime(DateTime.now()).replace(/:|\s/gi, "-")}.txt`;
}
emailTraceback() {
const address = this.pos.company.email;
const subject = this.env._t("IMPORTANT: Bug Report From Odoo Point Of Sale");
const subject = _t("IMPORTANT: Bug Report From Odoo Point Of Sale");
window.open(
"mailto:" +
address +
@@ -40,11 +40,11 @@ export class CashMovePopup extends AbstractAwaitablePopup {
if (!(err instanceof InvalidNumberError)) {
throw err;
}
this.state.errorMessage = this.env._t("Invalid amount");
this.state.errorMessage = _t("Invalid amount");
return;
}
if (amount < 0) {
this.state.errorMessage = this.env._t("Insert a positive amount");
this.state.errorMessage = _t("Insert a positive amount");
return;
}
const formattedAmount = this.env.utils.formatCurrency(amount);
@@ -92,7 +92,7 @@ export class CashMovePopup extends AbstractAwaitablePopup {
}
this.props.close();
this.notification.add(
this.env._t("Successfully made a cash %s of %s.", type, formattedAmount),
_t("Successfully made a cash %s of %s.", type, formattedAmount),
3000
);
}
@@ -114,6 +114,8 @@ export class CashMovePopup extends AbstractAwaitablePopup {
this.amountInput.el.focus();
}
format(value) {
return this.env.utils.isValidFloat(value) ? this.env.utils.formatCurrency(parseFloat(value)) : "!!!";
return this.env.utils.isValidFloat(value)
? this.env.utils.formatCurrency(parseFloat(value))
: "!!!";
}
}
@@ -38,11 +38,14 @@ export class ClosePosPopup extends AbstractAwaitablePopup {
Object.assign(this.state, this.props.info.state);
useValidateCashInput("closingCashInput");
if (this.otherPaymentMethods && this.otherPaymentMethods.length > 0) {
this.otherPaymentMethods.forEach(pm => {
this.otherPaymentMethods.forEach((pm) => {
if (this._getShowDiff(pm)) {
useValidateCashInput("closingCashInput_" + pm.id, this.state.payments[pm.id].counted);
useValidateCashInput(
"closingCashInput_" + pm.id,
this.state.payments[pm.id].counted
);
}
})
});
}
}
//@override
@@ -51,8 +54,8 @@ export class ClosePosPopup extends AbstractAwaitablePopup {
this.closeSession();
} else if (this.hasUserAuthority()) {
const { confirmed } = await this.popup.add(ConfirmPopup, {
title: this.env._t("Payments Difference"),
body: this.env._t(
title: _t("Payments Difference"),
body: _t(
"Do you want to accept payments difference and post a profit/loss journal entry?"
),
});
@@ -61,13 +64,13 @@ export class ClosePosPopup extends AbstractAwaitablePopup {
}
} else {
await this.popup.add(ConfirmPopup, {
title: this.env._t("Payments Difference"),
body: this.env._t(
title: _t("Payments Difference"),
body: _t(
"The maximum difference allowed is %s.\n\
Please contact your manager to accept the closing difference.",
this.env.utils.formatCurrency(this.amountAuthorizedDiff)
),
confirmText: this.env._t("OK"),
confirmText: _t("OK"),
});
}
}
@@ -103,12 +106,12 @@ export class ClosePosPopup extends AbstractAwaitablePopup {
}
}
async downloadSalesReport() {
return this.report.download("point_of_sale.sale_details_report", [
this.pos.pos_session.id,
]);
return this.report.download("point_of_sale.sale_details_report", [this.pos.pos_session.id]);
}
handleInputChange(paymentId, event) {
if (event.target.classList.contains('invalid-cash-input')) return;
if (event.target.classList.contains("invalid-cash-input")) {
return;
}
let expectedAmount;
if (paymentId === this.defaultCashDetails?.id) {
this.manualInputCashCount = true;
@@ -87,10 +87,8 @@ export class PartnerDetailsEdit extends Component {
const file = event.target.files[0];
if (!file.type.match(/image.*/)) {
await this.popup.add(ErrorPopup, {
title: this.env._t("Unsupported File Format"),
body: this.env._t(
"Only web-compatible Image formats such as .png or .jpeg are supported."
),
title: _t("Unsupported File Format"),
body: _t("Only web-compatible Image formats such as .png or .jpeg are supported."),
});
} else {
const imageUrl = await getDataURLFromFile(file);
@@ -133,8 +131,8 @@ export class PartnerDetailsEdit extends Component {
img.addEventListener("load", () => resolve(img));
img.addEventListener("error", () => {
this.popup.add(ErrorPopup, {
title: this.env._t("Loading Image Error"),
body: this.env._t("Encountered error when loading image. Please try again."),
title: _t("Loading Image Error"),
body: _t("Encountered error when loading image. Please try again."),
});
resolve(false);
});
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { registry } from "@web/core/registry";
import { debounce } from "@web/core/utils/timing";
import { useService } from "@web/core/utils/hooks";
@@ -127,14 +128,11 @@ export class PartnerListScreen extends Component {
const result = await this.searchPartner();
if (result.length > 0) {
this.notification.add(
this.env._t('%s customer(s) found for "%s".', result.length, this.state.query),
_t('%s customer(s) found for "%s".', result.length, this.state.query),
3000
);
} else {
this.notification.add(
this.env._t('No more customer found for "%s".', this.state.query),
3000
);
this.notification.add(_t('No more customer found for "%s".', this.state.query), 3000);
}
}
_clearSearch() {
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { NumberPopup } from "@point_of_sale/app/utils/input_popups/number_popup";
import { useService } from "@web/core/utils/hooks";
import { Component, useState } from "@odoo/owl";
@@ -28,7 +29,7 @@ export class PaymentScreenPaymentLines extends Component {
if (this.ui.isSmall) {
const { confirmed, payload } = await this.popup.add(NumberPopup, {
title: this.env._t("New amount"),
title: _t("New amount"),
startingValue: parseFloat(paymentline.amount),
isInputSelected: true,
nbrDecimal: this.pos.currency.decimal_places,
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { parseFloat } from "@web/views/fields/parsers";
import { useErrorHandlers } from "@point_of_sale/app/utils/hooks";
import { registry } from "@web/core/registry";
@@ -46,8 +47,8 @@ export class PaymentScreen extends Component {
showMaxValueError() {
this.popup.add(ErrorPopup, {
title: this.env._t("Maximum value reached"),
body: this.env._t(
title: _t("Maximum value reached"),
body: _t(
"The amount cannot be higher than the due amount if you don't have a cash payment method configured."
),
});
@@ -95,8 +96,8 @@ export class PaymentScreen extends Component {
return true;
} else {
this.popup.add(ErrorPopup, {
title: this.env._t("Error"),
body: this.env._t("There is already an electronic payment in progress."),
title: _t("Error"),
body: _t("There is already an electronic payment in progress."),
});
return false;
}
@@ -157,7 +158,7 @@ export class PaymentScreen extends Component {
const value = tip === 0 && change > 0 ? change : tip;
const { confirmed, payload } = await this.popup.add(NumberPopup, {
title: tip ? this.env._t("Change Tip") : this.env._t("Add Tip"),
title: tip ? _t("Change Tip") : _t("Add Tip"),
startingValue: value,
isInputSelected: true,
nbrDecimal: this.pos.currency.decimal_places,
@@ -171,7 +172,7 @@ export class PaymentScreen extends Component {
async toggleShippingDatePicker() {
if (!this.currentOrder.getShippingDate()) {
const { confirmed, payload: shippingDate } = await this.popup.add(DatePickerPopup, {
title: this.env._t("Select the shipping date"),
title: _t("Select the shipping date"),
});
if (confirmed) {
this.currentOrder.setShippingDate(shippingDate);
@@ -208,8 +209,8 @@ export class PaymentScreen extends Component {
if (this.pos.config.cash_rounding) {
if (!this.pos.get_order().check_paymentlines_rounding()) {
this.popup.add(ErrorPopup, {
title: this.env._t("Rounding error in payment lines"),
body: this.env._t(
title: _t("Rounding error in payment lines"),
body: _t(
"The amount of your payment lines must be rounded to validate the transaction."
),
});
@@ -283,8 +284,8 @@ export class PaymentScreen extends Component {
const postPushResult = await this._postPushOrderResolve(this.currentOrder, ordersServerId);
if (!postPushResult) {
this.popup.add(ErrorPopup, {
title: this.env._t("Error: no internet connection."),
body: this.env._t("Some, if not all, post-processing after syncing order failed."),
title: _t("Error: no internet connection."),
body: _t("Some, if not all, post-processing after syncing order failed."),
});
}
}
@@ -296,8 +297,8 @@ export class PaymentScreen extends Component {
// Ask the user to sync the remaining unsynced orders.
if (suggestToSync && this.pos.db.get_orders().length) {
const { confirmed } = await this.popup.add(ConfirmPopup, {
title: this.env._t("Remaining unsynced orders"),
body: this.env._t("There are unsynced orders. Do you want to sync these orders?"),
title: _t("Remaining unsynced orders"),
body: _t("There are unsynced orders. Do you want to sync these orders?"),
});
if (confirmed) {
// NOTE: Not yet sure if this should be awaited or not.
@@ -327,8 +328,8 @@ export class PaymentScreen extends Component {
async _isOrderValid(isForceValidate) {
if (this.currentOrder.get_orderlines().length === 0 && this.currentOrder.is_to_invoice()) {
this.popup.add(ErrorPopup, {
title: this.env._t("Empty Order"),
body: this.env._t(
title: _t("Empty Order"),
body: _t(
"There must be at least one product in your order before it can be validated and invoiced."
),
});
@@ -341,11 +342,8 @@ export class PaymentScreen extends Component {
if (splitPayments.length && !this.currentOrder.get_partner()) {
const paymentMethod = splitPayments[0].payment_method;
const { confirmed } = await this.popup.add(ConfirmPopup, {
title: this.env._t("Customer Required"),
body: this.env._t(
"Customer is required for %s payment method.",
paymentMethod.name
),
title: _t("Customer Required"),
body: _t("Customer is required for %s payment method.", paymentMethod.name),
});
if (confirmed) {
this.selectPartner();
@@ -358,8 +356,8 @@ export class PaymentScreen extends Component {
!this.currentOrder.get_partner()
) {
const { confirmed } = await this.popup.add(ConfirmPopup, {
title: this.env._t("Please select the Customer"),
body: this.env._t(
title: _t("Please select the Customer"),
body: _t(
"You need to select the customer before you can invoice or ship an order."
),
});
@@ -375,8 +373,8 @@ export class PaymentScreen extends Component {
!(partner.name && partner.street && partner.city && partner.country_id)
) {
this.popup.add(ErrorPopup, {
title: this.env._t("Incorrect address for shipping"),
body: this.env._t("The selected customer needs an address."),
title: _t("Incorrect address for shipping"),
body: _t("The selected customer needs an address."),
});
return false;
}
@@ -385,7 +383,7 @@ export class PaymentScreen extends Component {
this.currentOrder.get_total_with_tax() != 0 &&
this.currentOrder.get_paymentlines().length === 0
) {
this.notification.add(this.env._t("Select a payment method to validate the order."));
this.notification.add(_t("Select a payment method to validate the order."));
return false;
}
@@ -396,8 +394,8 @@ export class PaymentScreen extends Component {
if (this.currentOrder.has_not_valid_rounding()) {
var line = this.currentOrder.has_not_valid_rounding();
this.popup.add(ErrorPopup, {
title: this.env._t("Incorrect rounding"),
body: this.env._t(
title: _t("Incorrect rounding"),
body: _t(
"You have to round your payments lines." + line.amount + " is not rounded."
),
});
@@ -414,8 +412,8 @@ export class PaymentScreen extends Component {
) {
if (!this.pos.payment_methods.some((pm) => pm.is_cash_count)) {
this.popup.add(ErrorPopup, {
title: this.env._t("Cannot return change without a cash payment method"),
body: this.env._t(
title: _t("Cannot return change without a cash payment method"),
body: _t(
"There is no cash payment method available in this point of sale to handle the change.\n\n Please pay the exact amount or add a cash payment method in the point of sale configuration"
),
});
@@ -431,17 +429,17 @@ export class PaymentScreen extends Component {
) {
this.popup
.add(ConfirmPopup, {
title: this.env._t("Please Confirm Large Amount"),
title: _t("Please Confirm Large Amount"),
body:
this.env._t("Are you sure that the customer wants to pay") +
_t("Are you sure that the customer wants to pay") +
" " +
this.env.utils.formatCurrency(this.currentOrder.get_total_paid()) +
" " +
this.env._t("for an order of") +
_t("for an order of") +
" " +
this.env.utils.formatCurrency(this.currentOrder.get_total_with_tax()) +
" " +
this.env._t('? Clicking "Confirm" will validate the payment.'),
_t('? Clicking "Confirm" will validate the payment.'),
})
.then(({ confirmed }) => {
if (confirmed) {
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen";
import { useService } from "@web/core/utils/hooks";
import { TextAreaPopup } from "@point_of_sale/app/utils/input_popups/textarea_popup";
@@ -21,7 +22,7 @@ export class OrderlineCustomerNoteButton extends Component {
}
const { confirmed, payload: inputNote } = await this.popup.add(TextAreaPopup, {
startingValue: selectedOrderline.get_customer_note(),
title: this.env._t("Add Customer Note"),
title: _t("Add Customer Note"),
});
if (confirmed) {
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen";
import { useService } from "@web/core/utils/hooks";
import { SelectionPopup } from "@point_of_sale/app/utils/input_popups/selection_popup";
@@ -19,14 +20,14 @@ export class SetFiscalPositionButton extends Component {
get currentFiscalPositionName() {
return this.currentOrder && this.currentOrder.fiscal_position
? this.currentOrder.fiscal_position.display_name
: this.env._t("Tax");
: _t("Tax");
}
async click() {
const currentFiscalPosition = this.currentOrder.fiscal_position;
const fiscalPosList = [
{
id: -1,
label: this.env._t("None"),
label: _t("None"),
isSelected: !currentFiscalPosition,
},
];
@@ -43,7 +44,7 @@ export class SetFiscalPositionButton extends Component {
const { confirmed, payload: selectedFiscalPosition } = await this.popup.add(
SelectionPopup,
{
title: this.env._t("Select Fiscal Position"),
title: _t("Select Fiscal Position"),
list: fiscalPosList,
}
);
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen";
import { useService } from "@web/core/utils/hooks";
import { SelectionPopup } from "@point_of_sale/app/utils/input_popups/selection_popup";
@@ -18,7 +19,7 @@ export class SetPricelistButton extends Component {
}
get currentPricelistName() {
const order = this.currentOrder;
return order && order.pricelist ? order.pricelist.display_name : this.env._t("Pricelist");
return order && order.pricelist ? order.pricelist.display_name : _t("Pricelist");
}
async click() {
// Create the list to be passed to the SelectionPopup.
@@ -35,14 +36,14 @@ export class SetPricelistButton extends Component {
if (!this.pos.default_pricelist) {
selectionList.push({
id: null,
label: this.env._t("Default Price"),
label: _t("Default Price"),
isSelected: !this.currentOrder.pricelist,
item: null,
});
}
const { confirmed, payload: selectedPricelist } = await this.popup.add(SelectionPopup, {
title: this.env._t("Select the pricelist"),
title: _t("Select the pricelist"),
list: selectionList,
});
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { Component } from "@odoo/owl";
import { usePos } from "@point_of_sale/app/store/pos_hook";
import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen";
@@ -15,11 +16,11 @@ export class SaveButton extends Component {
onClick() {
const orderline = this.pos.get_order().get_selected_orderline();
if (!orderline) {
this.notification.add(this.env._t("You cannot save an empty order"), 3000);
this.notification.add(_t("You cannot save an empty order"), 3000);
return;
}
this._selectEmptyOrder();
this.notification.add(this.env._t("Order saved for later"), 3000);
this.notification.add(_t("Order saved for later"), 3000);
}
_selectEmptyOrder() {
const orders = this.pos.get_order_list();
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { useService } from "@web/core/utils/hooks";
import { EditListPopup } from "@point_of_sale/app/store/select_lot_popup/select_lot_popup";
@@ -50,7 +51,7 @@ export class OrderWidget extends Component {
const isAllowOnlyOneLot = orderline.product.isAllowOnlyOneLot();
const packLotLinesToEdit = orderline.getPackLotLinesToEdit(isAllowOnlyOneLot);
const { confirmed, payload } = await this.popup.add(EditListPopup, {
title: this.env._t("Lot/Serial Number(s) Required"),
title: _t("Lot/Serial Number(s) Required"),
name: orderline.product.display_name,
isSingleItem: isAllowOnlyOneLot,
array: packLotLinesToEdit,
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { usePos } from "@point_of_sale/app/store/pos_hook";
import { useService } from "@web/core/utils/hooks";
import { identifyError } from "@point_of_sale/app/errors/error_handlers";
@@ -80,14 +81,11 @@ export class ProductsWidget extends Component {
const result = await this.loadProductFromDB();
if (result.length > 0) {
this.notification.add(
this.env._t('%s product(s) found for "%s".', result.length, searchProductWord),
_t('%s product(s) found for "%s".', result.length, searchProductWord),
3000
);
} else {
this.notification.add(
this.env._t('No more product found for "%s".', searchProductWord),
3000
);
this.notification.add(_t('No more product found for "%s".', searchProductWord), 3000);
}
if (this.state.previousSearchWord === searchProductWord) {
this.state.currentOffset += result.length;
@@ -135,8 +133,8 @@ export class ProductsWidget extends Component {
identifiedError instanceof ConnectionAbortedError
) {
return this.popup.add(OfflineErrorPopup, {
title: this.env._t("Network Error"),
body: this.env._t(
title: _t("Network Error"),
body: _t(
"Product is not loaded. Tried loading the product from the server but there is a network error."
),
});
@@ -153,8 +151,8 @@ export class ProductsWidget extends Component {
);
if (!successful) {
this.popup.add(ErrorPopup, {
title: this.env._t("Demo products are no longer available"),
body: this.env._t(
title: _t("Demo products are no longer available"),
body: _t(
"A valid product already exists for Point of Sale. Therefore, demonstration products cannot be loaded."
),
});
@@ -110,8 +110,8 @@ export class ProductScreen extends ControlButtonsMixin(Component) {
if (selectedLine.noDecrease) {
this.popup.add(ErrorPopup, {
title: this.env._t("Invalid action"),
body: this.env._t("You are not allowed to change this quantity"),
title: _t("Invalid action"),
body: _t("You are not allowed to change this quantity"),
});
return;
}
@@ -205,7 +205,7 @@ export class ProductScreen extends ControlButtonsMixin(Component) {
if (!partner) {
// find the partner in the backend by the barcode
const foundPartnerIds = await this.orm.search("res.partner", [
["barcode", "=", code.code]
["barcode", "=", code.code],
]);
if (foundPartnerIds.length) {
await this.pos._loadPartners(foundPartnerIds);
@@ -263,7 +263,7 @@ export class ProductScreen extends ControlButtonsMixin(Component) {
this.numberBuffer.reset();
const { confirmed, payload: inputNumber } = await this.popup.add(NumberPopup, {
startingValue: 0,
title: this.env._t("Set the new quantity"),
title: _t("Set the new quantity"),
});
const newQuantity = inputNumber && inputNumber !== "" ? parseFloat(inputNumber) : null;
if (confirmed && newQuantity !== null) {
@@ -341,7 +341,7 @@ export class ProductScreen extends ControlButtonsMixin(Component) {
this.pos.showScreen("TicketScreen", {
ui: { filter: "SYNCED", searchDetails },
});
this.notification.add(this.env._t("The order has been already paid."), 3000);
this.notification.add(_t("The order has been already paid."), 3000);
this.pos.removeOrder(this.pos.get_order(), false);
this.pos.add_new_order();
return;
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { useService } from "@web/core/utils/hooks";
import { ConfirmPopup } from "@point_of_sale/app/utils/confirm_popup/confirm_popup";
import { ErrorPopup } from "@point_of_sale/app/errors/popups/error_popup";
@@ -51,8 +52,8 @@ export class AbstractReceiptScreen extends Component {
return true;
} catch {
await this.popup.add(ErrorPopup, {
title: this.env._t("Printing is not supported on some browsers"),
body: this.env._t(
title: _t("Printing is not supported on some browsers"),
body: _t(
"Printing is not supported on some browsers due to no default printing protocol " +
"is available. It is possible to print your tickets by making use of an IoT Box."
),
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { useErrorHandlers } from "@point_of_sale/app/utils/hooks";
import { AbstractReceiptScreen } from "@point_of_sale/app/screens/receipt_screen/abstract_receipt_screen";
import { OfflineErrorPopup } from "@point_of_sale/app/errors/popups/offline_error_popup";
@@ -61,7 +62,7 @@ export class ReceiptScreen extends AbstractReceiptScreen {
onSendEmail() {
if (this.buttonMailReceipt.el.classList.contains("fa-spin")) {
this.orderUiState.emailSuccessful = false;
this.orderUiState.emailNotice = this.env._t("Sending in progress.");
this.orderUiState.emailNotice = _t("Sending in progress.");
return;
}
this.buttonMailReceipt.el.className = "fa fa-fw fa-spin fa-circle-o-notch";
@@ -70,7 +71,7 @@ export class ReceiptScreen extends AbstractReceiptScreen {
if (!this.isValidEmail()) {
this.orderUiState.emailSuccessful = false;
this.buttonMailReceipt.el.className = "fa fa-paper-plane";
this.orderUiState.emailNotice = this.env._t("Invalid email.");
this.orderUiState.emailNotice = _t("Invalid email.");
return;
}
@@ -79,12 +80,10 @@ export class ReceiptScreen extends AbstractReceiptScreen {
try {
await this._sendReceiptToCustomer();
this.orderUiState.emailSuccessful = true;
this.orderUiState.emailNotice = this.env._t("Email sent.");
this.orderUiState.emailNotice = _t("Email sent.");
} catch {
this.orderUiState.emailSuccessful = false;
this.orderUiState.emailNotice = this.env._t(
"Sending email failed. Please try again."
);
this.orderUiState.emailNotice = _t("Sending email failed. Please try again.");
}
this.buttonMailReceipt.el.className = "fa fa-paper-plane";
}, 1000);
@@ -196,8 +195,8 @@ export class ReceiptScreen extends AbstractReceiptScreen {
const order_server_id = this.pos.validated_orders_name_server_id_map[orderName];
if (!order_server_id) {
this.popup.add(OfflineErrorPopup, {
title: this.env._t("Unsynced order"),
body: this.env._t(
title: _t("Unsynced order"),
body: _t(
"This order is not yet synced to server. Make sure it is synced then try again."
),
});
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { useService } from "@web/core/utils/hooks";
import { ErrorPopup } from "@point_of_sale/app/errors/popups/error_popup";
import { ConfirmPopup } from "@point_of_sale/app/utils/confirm_popup/confirm_popup";
@@ -24,9 +25,9 @@ export class InvoiceButton extends Component {
}
get commandName() {
if (!this.props.order) {
return this.env._t("Invoice");
return _t("Invoice");
} else {
return this.isAlreadyInvoiced ? this.env._t("Reprint Invoice") : this.env._t("Invoice");
return this.isAlreadyInvoiced ? _t("Reprint Invoice") : _t("Invoice");
}
}
async _downloadInvoice(orderId) {
@@ -48,8 +49,8 @@ export class InvoiceButton extends Component {
} else {
// NOTE: error here is most probably undefined
this.popup.add(ErrorPopup, {
title: this.env._t("Network Error"),
body: this.env._t("Unable to download invoice."),
title: _t("Network Error"),
body: _t("Unable to download invoice."),
});
}
}
@@ -75,8 +76,8 @@ export class InvoiceButton extends Component {
// Write to pos.order the selected partner.
if (!order.get_partner()) {
const { confirmed: confirmedPopup } = await this.popup.add(ConfirmPopup, {
title: this.env._t("Need customer to invoice"),
body: this.env._t("Do you want to open the customer list to select customer?"),
title: _t("Need customer to invoice"),
body: _t("Do you want to open the customer list to select customer?"),
});
if (!confirmedPopup) {
return;
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { Component } from "@odoo/owl";
import { formatFloat } from "@web/views/fields/formatters";
import { roundPrecision as round_pr } from "@web/core/utils/numbers";
@@ -71,9 +72,9 @@ export class OrderlineDetails extends Component {
return this.env.utils.formatProductQty(toRefundDetail && toRefundDetail.qty);
}
getRefundingMessage() {
return this.env._t("Refunding %s in ", this.getFormattedToRefundQty());
return _t("Refunding %s in ", this.getFormattedToRefundQty());
}
getToRefundMessage() {
return this.env._t("To Refund: %s", this.getFormattedToRefundQty());
return _t("To Refund: %s", this.getFormattedToRefundQty());
}
}
@@ -126,8 +126,8 @@ export class TicketScreen extends Component {
order.get_orderlines().length > 0
) {
const { confirmed } = await this.popup.add(ConfirmPopup, {
title: this.env._t("Existing orderlines"),
body: this.env._t(
title: _t("Existing orderlines"),
body: _t(
"%s has a total amount of %s, are you sure you want to delete this order?",
order.name,
this.getTotal(order)
@@ -208,8 +208,8 @@ export class TicketScreen extends Component {
if (quantity > refundableQty) {
this.numberBuffer.reset();
this.popup.add(ErrorPopup, {
title: this.env._t("Maximum Exceeded"),
body: this.env._t(
title: _t("Maximum Exceeded"),
body: _t(
"The requested quantity to be refunded is higher than the ordered quantity. %s is requested while only %s can be refunded.",
quantity,
refundableQty
@@ -344,7 +344,7 @@ export class TicketScreen extends Component {
}
getStatus(order) {
if (order.locked) {
return this.env._t("Paid");
return _t("Paid");
} else {
const screen = order.get_screen_data();
return this._getOrderStates().get(this._getScreenToStatusMap()[screen.name]).text;
@@ -561,7 +561,7 @@ export class TicketScreen extends Component {
}
_getFilterOptions() {
const orderStates = this._getOrderStates();
orderStates.set("SYNCED", { text: this.env._t("Paid") });
orderStates.set("SYNCED", { text: _t("Paid") });
return orderStates;
}
/**
@@ -571,18 +571,18 @@ export class TicketScreen extends Component {
const fields = {
RECEIPT_NUMBER: {
repr: (order) => order.name,
displayName: this.env._t("Receipt Number"),
displayName: _t("Receipt Number"),
modelField: "pos_reference",
},
DATE: {
repr: (order) =>
deserializeDate(order.creation_date).toFormat("yyyy-MM-dd HH:mm a"),
displayName: this.env._t("Date"),
displayName: _t("Date"),
modelField: "date_order",
},
PARTNER: {
repr: (order) => order.get_partner_name(),
displayName: this.env._t("Customer"),
displayName: _t("Customer"),
modelField: "partner_id.complete_name",
},
};
@@ -590,7 +590,7 @@ export class TicketScreen extends Component {
if (this.showCardholderName()) {
fields.CARDHOLDER_NAME = {
repr: (order) => order.get_cardholder_name(),
displayName: this.env._t("Cardholder Name"),
displayName: _t("Cardholder Name"),
modelField: "payment_ids.cardholder_name",
};
}
@@ -620,20 +620,20 @@ export class TicketScreen extends Component {
// We need the items to be ordered, therefore, Map is used instead of normal object.
const states = new Map();
states.set("ACTIVE_ORDERS", {
text: this.env._t("All active orders"),
text: _t("All active orders"),
});
// The spaces are important to make sure the following states
// are under the category of `All active orders`.
states.set("ONGOING", {
text: this.env._t("Ongoing"),
text: _t("Ongoing"),
indented: true,
});
states.set("PAYMENT", {
text: this.env._t("Payment"),
text: _t("Payment"),
indented: true,
});
states.set("RECEIPT", {
text: this.env._t("Receipt"),
text: _t("Receipt"),
indented: true,
});
return states;
@@ -4,7 +4,12 @@ import { formatFloat } from "@web/views/fields/formatters";
import { uuidv4 } from "@point_of_sale/utils";
// FIXME POSREF - unify use of native parseFloat and web's parseFloat. We probably don't need the native version.
import { parseFloat as oParseFloat } from "@web/views/fields/parsers";
import { formatDate, formatDateTime, serializeDateTime, deserializeDate } from "@web/core/l10n/dates";
import {
formatDate,
formatDateTime,
serializeDateTime,
deserializeDate,
} from "@web/core/l10n/dates";
import {
roundDecimals as round_di,
roundPrecision as round_pr,
@@ -169,7 +174,7 @@ export class Product extends PosModel {
const { confirmed, payload } = await this.pos.env.services.popup.add(
EditListPopup,
{
title: this.pos.env._t("Lot/Serial Number(s) Required"),
title: _t("Lot/Serial Number(s) Required"),
name: this.display_name,
isSingleItem: isAllowOnlyOneLot,
array: packLotLinesToEdit,
@@ -309,22 +314,14 @@ export class Product extends PosModel {
}
get_display_price(pricelist, quantity) {
const order = this.pos.get_order();
const taxes = this.pos.get_taxes_after_fp(
this.taxes_id,
order && order.fiscal_position
);
const taxes = this.pos.get_taxes_after_fp(this.taxes_id, order && order.fiscal_position);
const currentTaxes = this.pos.getTaxesByIds(this.taxes_id);
const priceAfterFp = this.pos.computePriceAfterFp(
this.get_price(pricelist, quantity),
this.get_price(pricelist, quantity),
currentTaxes
);
const allPrices = this.pos.compute_all(
taxes,
priceAfterFp,
1,
this.pos.currency.rounding
);
if (this.pos.config.iface_tax_included === 'total') {
const allPrices = this.pos.compute_all(taxes, priceAfterFp, 1, this.pos.currency.rounding);
if (this.pos.config.iface_tax_included === "total") {
return allPrices.total_included;
} else {
return allPrices.total_excluded;
@@ -840,8 +837,8 @@ export class Orderline extends PosModel {
return this.get_all_prices(1).priceWithoutTax;
}
}
getUnitDisplayPriceBeforeDiscount(){
if (this.pos.config.iface_tax_included === 'total') {
getUnitDisplayPriceBeforeDiscount() {
if (this.pos.config.iface_tax_included === "total") {
return this.get_all_prices(1).priceWithTaxBeforeDiscount;
} else {
return this.get_all_prices(1).priceWithoutTaxBeforeDiscount;
@@ -880,13 +877,13 @@ export class Orderline extends PosModel {
return this.get_price_without_tax();
}
}
get_taxed_lst_unit_price(){
get_taxed_lst_unit_price() {
const lstPrice = this.compute_fixed_price(this.get_lst_price());
const product = this.get_product();
const product = this.get_product();
const taxesIds = product.taxes_id;
const productTaxes = this.pos.get_taxes_after_fp(taxesIds, this.order.fiscal_position);
const unitPrices = this.compute_all(productTaxes, lstPrice, 1, this.pos.currency.rounding);
if (this.pos.config.iface_tax_included === 'total') {
const unitPrices = this.compute_all(productTaxes, lstPrice, 1, this.pos.currency.rounding);
if (this.pos.config.iface_tax_included === "total") {
return unitPrices.total_included;
} else {
return unitPrices.total_excluded;
@@ -1017,7 +1014,7 @@ export class Orderline extends PosModel {
display_discount_policy() {
return this.order.pricelist ? this.order.pricelist.discount_policy : "with_discount";
}
compute_fixed_price (price) {
compute_fixed_price(price) {
return this.pos.computePriceAfterFp(price, this.get_taxes());
}
get_fixed_lst_price() {
@@ -2190,10 +2187,13 @@ export class Order extends PosModel {
_get_ignored_product_ids_total_discount() {
return [];
}
_reduce_total_discount_callback(sum, orderLine){
let discountUnitPrice = orderLine.getUnitDisplayPriceBeforeDiscount() * (orderLine.get_discount()/100);
if (orderLine.display_discount_policy() === 'without_discount'){
discountUnitPrice += orderLine.get_taxed_lst_unit_price() - orderLine.getUnitDisplayPriceBeforeDiscount();
_reduce_total_discount_callback(sum, orderLine) {
let discountUnitPrice =
orderLine.getUnitDisplayPriceBeforeDiscount() * (orderLine.get_discount() / 100);
if (orderLine.display_discount_policy() === "without_discount") {
discountUnitPrice +=
orderLine.get_taxed_lst_unit_price() -
orderLine.getUnitDisplayPriceBeforeDiscount();
}
return sum + discountUnitPrice * orderLine.get_quantity();
}
@@ -2208,7 +2208,8 @@ export class Order extends PosModel {
orderLine.get_quantity();
if (orderLine.display_discount_policy() === "without_discount") {
sum +=
(orderLine.get_taxed_lst_unit_price() - orderLine.getUnitDisplayPriceBeforeDiscount()) *
(orderLine.get_taxed_lst_unit_price() -
orderLine.getUnitDisplayPriceBeforeDiscount()) *
orderLine.get_quantity();
}
}
@@ -1,4 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { OfflineErrorPopup } from "@point_of_sale/app/errors/popups/offline_error_popup";
import { ConfirmPopup } from "@point_of_sale/app/utils/confirm_popup/confirm_popup";
import { ErrorTracebackPopup } from "@point_of_sale/app/errors/popups/error_traceback_popup";
@@ -21,36 +23,34 @@ export function useErrorHandlers() {
// This error handler receives `error` equivalent to `error.message` of the rpc error.
if (error.message === "Backend Invoice") {
await popup.add(ConfirmPopup, {
title: this.env._t("Please print the invoice from the backend"),
title: _t("Please print the invoice from the backend"),
body:
this.env._t(
_t(
"The order has been synchronized earlier. Please make the invoice from the backend for the order: "
) + error.data.order.name,
});
} else if (error.code < 0) {
// XmlHttpRequest Errors
const title = this.env._t("Unable to sync order");
const body = this.env._t(
const title = _t("Unable to sync order");
const body = _t(
"Check the internet connection then try to sync again by clicking on the red wifi button (upper right of the screen)."
);
await popup.add(OfflineErrorPopup, { title, body });
} else if (error.code === 200) {
// OpenERP Server Errors
await popup.add(ErrorTracebackPopup, {
title: error.data.message || this.env._t("Server Error"),
title: error.data.message || _t("Server Error"),
body:
error.data.debug ||
this.env._t("The server encountered an error while receiving your order."),
_t("The server encountered an error while receiving your order."),
});
} else if (error.code === 700) {
// Sweden Fiscal module errors
await popup.add(ErrorPopup, {
title: this.env._t("Fiscal data module error"),
title: _t("Fiscal data module error"),
body:
error.data.error.status ||
this.env._t(
"The fiscal data module encountered an error while receiving your order."
),
_t("The fiscal data module encountered an error while receiving your order."),
});
} else if (error.code === 701) {
// Belgian Fiscal module errors
@@ -61,16 +61,14 @@ export function useErrorHandlers() {
bodyMessage = "Fiscal data module is not on.";
}
await popup.add(ErrorPopup, {
title: this.env._t("Fiscal data module error"),
title: _t("Fiscal data module error"),
body: bodyMessage,
});
} else {
// ???
await popup.add(ErrorPopup, {
title: this.env._t("Unknown Error"),
body: this.env._t(
"The order could not be sent to the server due to an unknown error"
),
title: _t("Unknown Error"),
body: _t("The order could not be sent to the server due to an unknown error"),
});
}
};
@@ -1,14 +1,15 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { registry } from "@web/core/registry";
function runPoSJSTests({ env }) {
return {
type: "item",
description: env._t("Run Point of Sale JS Tests"),
description: _t("Run Point of Sale JS Tests"),
callback: () => {
env.services.action.doAction({
name: env._t("JS Tests"),
name: _t("JS Tests"),
target: "new",
type: "ir.actions.act_url",
url: "/pos/ui/tests?debug=assets",
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen";
import { useService } from "@web/core/utils/hooks";
import { NumberPopup } from "@point_of_sale/app/utils/input_popups/number_popup";
@@ -17,7 +18,7 @@ export class DiscountButton extends Component {
async click() {
var self = this;
const { confirmed, payload } = await this.popup.add(NumberPopup, {
title: this.env._t("Discount Percentage"),
title: _t("Discount Percentage"),
startingValue: this.pos.config.discount_pc,
isInputSelected: true,
});
@@ -33,8 +34,8 @@ export class DiscountButton extends Component {
const product = this.pos.db.get_product_by_id(this.pos.config.discount_product_id[0]);
if (product === undefined) {
await this.popup.add(ErrorPopup, {
title: this.env._t("No discount product found"),
body: this.env._t(
title: _t("No discount product found"),
body: _t(
"The discount product seems misconfigured. Make sure it is flagged as 'Can be Sold' and 'Available in Point of Sale'."
),
});
@@ -72,13 +73,13 @@ export class DiscountButton extends Component {
description:
`${pc}%, ` +
(tax_ids_array.length
? this.env._t(
? _t(
"Tax: %s",
tax_ids_array
.map((taxId) => this.pos.taxes_by_id[taxId].amount + "%")
.join(", ")
)
: this.env._t("No tax")),
: _t("No tax")),
extras: {
price_type: "automatic",
},
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen";
import { SelectionPopup } from "@point_of_sale/app/utils/input_popups/selection_popup";
import { ErrorPopup } from "@point_of_sale/app/errors/popups/error_popup";
@@ -27,9 +28,7 @@ export class eWalletButton extends Component {
}
async _onClickWalletButton() {
const order = this.pos.get_order();
const eWalletPrograms = this.pos.programs.filter(
(p) => p.program_type == "ewallet"
);
const eWalletPrograms = this.pos.programs.filter((p) => p.program_type == "ewallet");
const orderTotal = order.get_total_with_tax();
const eWalletRewards = this._getEWalletRewards(order);
if (orderTotal < 0 && eWalletPrograms.length >= 1) {
@@ -38,7 +37,7 @@ export class eWalletButton extends Component {
selectedProgram = eWalletPrograms[0];
} else {
const { confirmed, payload } = await this.popup.add(SelectionPopup, {
title: this.env._t("Refund with eWallet"),
title: _t("Refund with eWallet"),
list: eWalletPrograms.map((program) => ({
id: program.id,
item: program,
@@ -65,7 +64,7 @@ export class eWalletButton extends Component {
eWalletReward = eWalletRewards[0];
} else {
const { confirmed, payload } = await this.popup.add(SelectionPopup, {
title: this.env._t("Use eWallet to pay"),
title: _t("Use eWallet to pay"),
list: eWalletRewards.map(({ reward, coupon_id }) => ({
id: reward.id,
item: { reward, coupon_id },
@@ -85,7 +84,7 @@ export class eWalletButton extends Component {
if (result !== true) {
// Returned an error
this.popup.add(ErrorPopup, {
title: this.env._t("Error"),
title: _t("Error"),
body: result,
});
}
@@ -98,11 +97,11 @@ export class eWalletButton extends Component {
}
_getText(orderTotal, eWalletPrograms, eWalletRewards) {
if (orderTotal < 0 && eWalletPrograms.length >= 1) {
return this.env._t("eWallet Refund");
return _t("eWallet Refund");
} else if (eWalletRewards.length >= 1) {
return this.env._t("eWallet Pay");
return _t("eWallet Pay");
} else {
return this.env._t("eWallet");
return _t("eWallet");
}
}
}
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen";
import { useService } from "@web/core/utils/hooks";
import { TextInputPopup } from "@point_of_sale/app/utils/input_popups/text_input_popup";
@@ -16,9 +17,9 @@ export class PromoCodeButton extends Component {
async click() {
let { confirmed, payload: code } = await this.popup.add(TextInputPopup, {
title: this.env._t("Enter Code"),
title: _t("Enter Code"),
startingValue: "",
placeholder: this.env._t("Gift card or Discount code"),
placeholder: _t("Gift card or Discount code"),
});
if (confirmed) {
code = code.trim();
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen";
import { useService } from "@web/core/utils/hooks";
import { SelectionPopup } from "@point_of_sale/app/utils/input_popups/selection_popup";
@@ -72,7 +73,7 @@ export class RewardButton extends Component {
item: product_id,
}));
const { confirmed, payload: selectedProduct } = await this.popup.add(SelectionPopup, {
title: this.env._t("Please select a product for this reward"),
title: _t("Please select a product for this reward"),
list: productsList,
});
if (!confirmed) {
@@ -107,7 +108,7 @@ export class RewardButton extends Component {
item: reward,
}));
const { confirmed, payload: selectedReward } = await this.popup.add(SelectionPopup, {
title: this.env._t("Please select a reward"),
title: _t("Please select a reward"),
list: rewardsList,
});
if (confirmed) {
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { usePos } from "@point_of_sale/app/store/pos_hook";
import { PartnerLine } from "@point_of_sale/app/screens/partner_list/partner_line/partner_line";
import { patch } from "@web/core/utils/patch";
@@ -19,6 +20,6 @@ patch(PartnerLine.prototype, {
if (program.portal_visible) {
return `${balanceRepr} ${program.portal_point_name}`;
}
return this.env._t("%s Points", balanceRepr);
return _t("%s Points", balanceRepr);
},
});
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { PaymentScreen } from "@point_of_sale/app/screens/payment_screen/payment_screen";
import { patch } from "@web/core/utils/patch";
import { PosLoyaltyCard } from "@pos_loyalty/overrides/models/loyalty";
@@ -61,7 +62,7 @@ patch(PaymentScreen.prototype, {
}
if (!successful) {
this.popup.add(ErrorPopup, {
title: this.env._t("Error validating rewards"),
title: _t("Error validating rewards"),
body: payload.message,
});
return;
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen";
import { useBarcodeReader } from "@point_of_sale/app/barcode/barcode_reader_hook";
import { patch } from "@web/core/utils/patch";
@@ -25,9 +26,7 @@ patch(ProductScreen.prototype, {
// Do not allow negative quantity or price in a gift card or ewallet orderline.
// Refunding gift card or ewallet is not supported.
this.notification.add(
this.env._t(
"You cannot set negative quantity or price to gift card or ewallet."
),
_t("You cannot set negative quantity or price to gift card or ewallet."),
4000
);
return;
@@ -41,13 +40,13 @@ patch(ProductScreen.prototype, {
) {
const reward = this.pos.reward_by_id[selectedLine.reward_id];
const { confirmed } = await this.popup.add(ConfirmPopup, {
title: this.env._t("Deactivating reward"),
body: this.env._t(
title: _t("Deactivating reward"),
body: _t(
"Are you sure you want to remove %s from this order?\n You will still be able to claim it through the reward button.",
reward.description
),
cancelText: this.env._t("No"),
confirmText: this.env._t("Yes"),
cancelText: _t("No"),
confirmText: _t("Yes"),
});
if (confirmed) {
buffer = null;
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { TicketScreen } from "@point_of_sale/app/screens/ticket_screen/ticket_screen";
import { useService } from "@web/core/utils/hooks";
import { patch } from "@web/core/utils/patch";
@@ -36,7 +37,7 @@ patch(TicketScreen.prototype, {
},
_showNotAllowedRefundNotification() {
this.notification.add(
this.env._t(
_t(
"Refunding a top up or reward product for an eWallet or gift card program is not allowed."
),
5000
@@ -178,9 +178,9 @@ patch(PaymentScreen.prototype, {
response.message;
} else {
if (can_connect_to_server) {
message = self.env._t("No response from Vantiv (Vantiv down?)");
message = _t("No response from Vantiv (Vantiv down?)");
} else {
message = self.env._t("No response from server (connected to network?)");
message = _t("No response from server (connected to network?)");
}
}
def.resolve({
@@ -194,8 +194,8 @@ patch(PaymentScreen.prototype, {
const order = this.pos.get_order();
if (order.get_due(order.selected_paymentline) < 0) {
this.popup.add(ErrorPopup, {
title: this.env._t("Refunds not supported"),
body: this.env._t(
title: _t("Refunds not supported"),
body: _t(
"Credit card refunds are not supported. Instead select your credit card payment method, click 'Validate' and refund the original charge manually through the Vantiv backend."
),
});
@@ -210,8 +210,8 @@ patch(PaymentScreen.prototype, {
if (!decodedMagtek) {
this.popup.add(ErrorPopup, {
title: this.env._t("Could not read card"),
body: this.env._t(
title: _t("Could not read card"),
body: _t(
"This can be caused by a badly executed swipe or by not having your keyboard layout set to US QWERTY (not US International)."
),
});
@@ -248,7 +248,7 @@ patch(PaymentScreen.prototype, {
transaction: def,
});
def.notify({
message: this.env._t("Handling transaction..."),
message: _t("Handling transaction..."),
});
}
// FIXME POSREF timeout
@@ -270,14 +270,14 @@ patch(PaymentScreen.prototype, {
if (data === "not setup") {
def.resolve({
message: this.env._t("Please setup your Vantiv merchant account."),
message: _t("Please setup your Vantiv merchant account."),
});
return;
}
if (data === "internal error") {
def.resolve({
message: this.env._t("Odoo error while processing transaction."),
message: _t("Odoo error while processing transaction."),
});
return;
}
@@ -330,7 +330,7 @@ patch(PaymentScreen.prototype, {
if (response.message === "PARTIAL AP") {
def.resolve({
message: this.env._t("Partially approved"),
message: _t("Partially approved"),
auto_close: false,
});
} else {
@@ -393,7 +393,7 @@ patch(PaymentScreen.prototype, {
}));
this.popup
.add(SelectionPopup, {
title: this.env._t("Pay with: "),
title: _t("Pay with: "),
list: selectionList,
})
.then(({ confirmed, payload: selectedPaymentMethod }) => {
@@ -433,10 +433,10 @@ patch(PaymentScreen.prototype, {
var rpc_method = "";
if (is_voidsale) {
message = this.env._t("Reversal failed, sending VoidSale...");
message = _t("Reversal failed, sending VoidSale...");
rpc_method = "do_voidsale";
} else {
message = this.env._t("Sending reversal...");
message = _t("Sending reversal...");
rpc_method = "do_reversal";
}
@@ -461,7 +461,7 @@ patch(PaymentScreen.prototype, {
if (data === "internal error") {
def.resolve({
message: self.env._t("Odoo error while processing transaction."),
message: _t("Odoo error while processing transaction."),
});
return;
}
@@ -475,7 +475,7 @@ patch(PaymentScreen.prototype, {
} else {
// reversal was successful
def.resolve({
message: self.env._t("Reversal succeeded"),
message: _t("Reversal succeeded"),
});
self.remove_paymentline_by_ref(line);
@@ -484,7 +484,7 @@ patch(PaymentScreen.prototype, {
// voidsale ended, nothing more we can do
if (response.status === "Approved") {
def.resolve({
message: self.env._t("VoidSale succeeded"),
message: _t("VoidSale succeeded"),
});
self.remove_paymentline_by_ref(line);
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen";
import { useBarcodeReader } from "@point_of_sale/app/barcode/barcode_reader_hook";
import { patch } from "@web/core/utils/patch";
@@ -14,7 +15,7 @@ patch(ProductScreen.prototype, {
},
credit_error_action() {
this.popup.add(ErrorPopup, {
body: this.env._t("Go to payment screen to use cards"),
body: _t("Go to payment screen to use cards"),
});
},
});
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { PaymentScreen } from "@point_of_sale/app/screens/payment_screen/payment_screen";
import { patch } from "@web/core/utils/patch";
import { OnlinePaymentPopup } from "@pos_online_payment/app/utils/online_payment_popup/online_payment_popup";
@@ -21,8 +22,8 @@ patch(PaymentScreen.prototype, {
amount = line.get_amount();
if (amount <= 0) {
this.popup.add(ErrorPopup, {
title: this.env._t("Invalid online payment"),
body: this.env._t(
title: _t("Invalid online payment"),
body: _t(
"Online payments cannot have a negative amount (%s: %s).",
line.payment_method.name,
this.env.utils.formatCurrency(amount)
@@ -34,8 +35,8 @@ patch(PaymentScreen.prototype, {
}
if (!floatIsZero(unpaidAmount - remainingAmount, this.pos.currency.decimal_places)) {
this.popup.add(ErrorPopup, {
title: this.env._t("Invalid online payments"),
body: this.env._t(
title: _t("Invalid online payments"),
body: _t(
"The total amount of remaining online payments to execute (%s) doesn't correspond to the remaining unpaid amount of the order (%s).",
this.env.utils.formatCurrency(remainingAmount),
this.env.utils.formatCurrency(unpaidAmount)
@@ -99,8 +100,8 @@ patch(PaymentScreen.prototype, {
if (!qrCodeData || qrCodeData.length == 0) {
this.cancelOnlinePayment(this.currentOrder);
this.popup.add(ErrorPopup, {
title: this.env._t("Online payment unavailable"),
body: this.env._t("The QR Code for paying could not be generated."),
title: _t("Online payment unavailable"),
body: _t("The QR Code for paying could not be generated."),
});
return false;
}
@@ -113,8 +114,8 @@ patch(PaymentScreen.prototype, {
lastOrderServerOPData = await this.currentOrder.update_online_payments_data_with_server(this.pos.orm, onlinePaymentLineAmount);
if (!lastOrderServerOPData) {
this.popup.add(ErrorPopup, {
title: this.env._t("Online payment unavailable"),
body: this.env._t("There is a problem with the server. The order online payment status cannot be retrieved."),
title: _t("Online payment unavailable"),
body: _t("There is a problem with the server. The order online payment status cannot be retrieved."),
});
return false;
}
@@ -152,9 +153,9 @@ patch(PaymentScreen.prototype, {
const orderServerOPData = await this.currentOrder.update_online_payments_data_with_server(this.pos.orm, 0);
if (!orderServerOPData) {
const { confirmed } = await this.popup.add(ConfirmPopup, {
title: this.env._t("Online payment unavailable"),
body: this.env._t("There is a problem with the server. The order online payment status cannot be retrieved. Are you sure there is no online payment for this order ?"),
confirmText: this.env._t("Yes"),
title: _t("Online payment unavailable"),
body: _t("There is a problem with the server. The order online payment status cannot be retrieved. Are you sure there is no online payment for this order ?"),
confirmText: _t("Yes"),
});
if (!confirmed) {
return false;
@@ -178,14 +179,14 @@ patch(PaymentScreen.prototype, {
},
showSaveOrderOnServerErrorPopup() {
this.popup.add(ErrorPopup, {
title: this.env._t("Online payment unavailable"),
body: this.env._t("There is a problem with the server. The order cannot be saved and therefore the online payment is not possible."),
title: _t("Online payment unavailable"),
body: _t("There is a problem with the server. The order cannot be saved and therefore the online payment is not possible."),
});
},
showModifiedOnlinePaymentsPopup() {
this.popup.add(ErrorPopup, {
title: this.env._t("Updated online payments"),
body: this.env._t("There are online payments that were missing in your view."),
title: _t("Updated online payments"),
body: _t("There are online payments that were missing in your view."),
});
},
async showOnlinePaymentQrCode(qrCodeData, amount) {
@@ -212,8 +213,8 @@ patch(PaymentScreen.prototype, {
async afterPaidOrderSavedOnServer(orderJSON) {
if (!orderJSON) {
this.popup.add(ErrorPopup, {
title: this.env._t("Server error"),
body: this.env._t("The saved order could not be retrieved."),
title: _t("Server error"),
body: _t("The saved order could not be retrieved."),
});
return;
}
@@ -232,8 +233,8 @@ patch(PaymentScreen.prototype, {
const updatedOrder = this.pos.createReactiveOrder(orderJSON);
if (!updatedOrder || this.currentOrder.server_id !== updatedOrder.backendId) {
this.popup.add(ErrorPopup, {
title: this.env._t("Order saving issue"),
body: this.env._t("The order has not been saved correctly on the server."),
title: _t("Order saving issue"),
body: _t("The order has not been saved correctly on the server."),
});
return;
}
@@ -253,8 +254,8 @@ patch(PaymentScreen.prototype, {
if (isInvoiceRequested) {
if (!this.currentOrder.account_move) {
this.popup.add(ErrorPopup, {
title: this.env._t("Invoice could not be generated"),
body: this.env._t("The invoice could not be generated."),
title: _t("Invoice could not be generated"),
body: _t("The invoice could not be generated."),
});
} else {
await this.report.download("account.account_invoices", [
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen";
import { useService } from "@web/core/utils/hooks";
import { TextAreaPopup } from "@point_of_sale/app/utils/input_popups/textarea_popup";
@@ -23,7 +24,7 @@ export class OrderlineNoteButton extends Component {
const { confirmed, payload: inputNote } = await this.popup.add(TextAreaPopup, {
startingValue: this.selectedOrderline.getNote(),
title: this.env._t("Add internal Note"),
title: _t("Add internal Note"),
});
if (confirmed) {
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen";
import { useService } from "@web/core/utils/hooks";
import { NumberPopup } from "@point_of_sale/app/utils/input_popups/number_popup";
@@ -24,7 +25,7 @@ export class TableGuestsButton extends Component {
const { confirmed, payload: inputNumber } = await this.popup.add(NumberPopup, {
startingValue: this.nGuests,
cheap: true,
title: this.env._t("Guests?"),
title: _t("Guests?"),
isInputSelected: true,
});
@@ -34,8 +35,8 @@ export class TableGuestsButton extends Component {
const max_capacity = 2 ** 31 - 1;
if (guestCount > max_capacity) {
await this.popup.add(ErrorPopup, {
title: this.env._t("Blocked action"),
body: this.env._t("You cannot put a number that exceeds %s ", max_capacity),
title: _t("Blocked action"),
body: _t("You cannot put a number that exceeds %s ", max_capacity),
});
return;
}
@@ -1,5 +1,7 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { sprintf } from "@web/core/utils/strings";
import { ConnectionLostError } from "@web/core/network/rpc_service";
import { debounce } from "@web/core/utils/timing";
import { registry } from "@web/core/registry";
@@ -378,8 +380,8 @@ export class FloorScreen extends Component {
}
async addFloor() {
const { confirmed, payload: newName } = await this.popup.add(TextInputPopup, {
title: this.env._t("New Floor"),
placeholder: this.env._t("Floor name"),
title: _t("New Floor"),
placeholder: _t("Floor name"),
});
if (!confirmed) {
return;
@@ -441,7 +443,7 @@ export class FloorScreen extends Component {
if (selectedTables.length == 0) {
const { confirmed, payload: newName } = await this.popup.add(TextInputPopup, {
startingValue: selectedFloor.name,
title: this.env._t("Floor Name ?"),
title: _t("Floor Name ?"),
});
if (!confirmed) {
return;
@@ -455,7 +457,7 @@ export class FloorScreen extends Component {
const selectedTable = selectedTables[0];
const { confirmed, payload: newName } = await this.popup.add(TextInputPopup, {
startingValue: selectedTable.name,
title: this.env._t("Table Name?"),
title: _t("Table Name?"),
});
if (!confirmed) {
return;
@@ -473,7 +475,7 @@ export class FloorScreen extends Component {
const { confirmed, payload: inputNumber } = await this.popup.add(NumberPopup, {
startingValue: 0,
cheap: true,
title: this.env._t("Number of Seats?"),
title: _t("Number of Seats?"),
isInputSelected: true,
});
if (!confirmed) {
@@ -525,8 +527,8 @@ export class FloorScreen extends Component {
if (this.selectedTables.length == 0) {
const { confirmed } = await this.popup.add(ConfirmPopup, {
title: `Removing floor ${this.activeFloor.name}`,
body: this.env._t(
"Removing a floor cannot be undone. Do you still want to remove %s?",
body: sprintf(
_t("Removing a floor cannot be undone. Do you still want to remove %s?"),
this.activeFloor.name
),
});
@@ -563,8 +565,8 @@ export class FloorScreen extends Component {
return;
}
const { confirmed } = await this.popup.add(ConfirmPopup, {
title: this.env._t("Are you sure?"),
body: this.env._t("Removing a table cannot be undone"),
title: _t("Are you sure?"),
body: _t("Removing a table cannot be undone"),
});
if (!confirmed) {
return;
@@ -587,8 +589,8 @@ export class FloorScreen extends Component {
delete this.pos.tables_by_id[id];
} else {
await this.popup.add(ErrorPopup, {
title: this.env._t("Delete Error"),
body: this.env._t(
title: _t("Delete Error"),
body: _t(
"You cannot delete a table with orders still in draft for this table."
),
});
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { parseFloat } from "@web/views/fields/parsers";
import { renderToElement } from "@web/core/utils/render";
import { registry } from "@web/core/registry";
@@ -51,8 +52,8 @@ export class TipScreen extends Component {
if (!serverId) {
this.popup.add(ErrorPopup, {
title: this.env._t("Unsynced order"),
body: this.env._t(
title: _t("Unsynced order"),
body: _t(
"This order is not yet synced to server. Make sure it is synced then try again."
),
});
@@ -143,8 +144,8 @@ export class TipScreen extends Component {
window.print();
} catch {
await this.popup.add(ErrorPopup, {
title: this.env._t("Printing is not supported on some browsers"),
body: this.env._t(
title: _t("Printing is not supported on some browsers"),
body: _t(
"Printing is not supported on some browsers due to no default printing protocol " +
"is available. It is possible to print your tickets by making use of an IoT Box."
),
@@ -1,4 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { TicketScreen } from "@point_of_sale/app/screens/ticket_screen/ticket_screen";
import { useAutofocus } from "@web/core/utils/hooks";
import { patch } from "@web/core/utils/patch";
@@ -36,7 +38,7 @@ patch(TicketScreen.prototype, {
return Object.assign({}, super._getSearchFields(...arguments), {
TABLE: {
repr: this.getTable.bind(this),
displayName: this.env._t("Table"),
displayName: _t("Table"),
modelField: "table_id.name",
},
});
@@ -118,8 +120,8 @@ patch(TicketScreen.prototype, {
const result = super._getOrderStates(...arguments);
if (this.pos.config.set_tip_after_payment) {
result.delete("PAYMENT");
result.set("OPEN", { text: this.env._t("Open"), indented: true });
result.set("TIPPING", { text: this.env._t("Tipping"), indented: true });
result.set("OPEN", { text: _t("Open"), indented: true });
result.set("TIPPING", { text: _t("Tipping"), indented: true });
}
return result;
},
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { sprintf } from "@web/core/utils/strings";
import { parseFloat } from "@web/views/fields/parsers";
import { useBus, useService } from "@web/core/utils/hooks";
@@ -92,17 +93,17 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(Component) {
}
async onClickSaleOrder(clickedOrder) {
const { confirmed, payload: selectedOption } = await this.popup.add(SelectionPopup, {
title: this.env._t("What do you want to do?"),
title: _t("What do you want to do?"),
list: [
{ id: "0", label: this.env._t("Settle the order"), item: "settle" },
{ id: "0", label: _t("Settle the order"), item: "settle" },
{
id: "1",
label: this.env._t("Apply a down payment (percentage)"),
label: _t("Apply a down payment (percentage)"),
item: "dpPercentage",
},
{
id: "2",
label: this.env._t("Apply a down payment (fixed amount)"),
label: _t("Apply a down payment (fixed amount)"),
item: "dpAmount",
},
],
@@ -124,7 +125,7 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(Component) {
getId(linkedSO.partner_shipping_id) !== getId(sale_order.partner_shipping_id)
) {
currentPOSOrder = this.pos.add_new_order();
this.notification.add(this.env._t("A new order has been created."), 4000);
this.notification.add(_t("A new order has been created."), 4000);
}
}
@@ -140,8 +141,8 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(Component) {
try {
await this.pos._loadPartners([sale_order.partner_id[0]]);
} catch {
const title = this.env._t("Customer loading error");
const body = this.env._t(
const title = _t("Customer loading error");
const body = _t(
"There was a problem in loading the %s customer.",
sale_order.partner_id[1]
);
@@ -176,12 +177,12 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(Component) {
.map((line) => line.product_id[0]);
if (product_to_add_in_pos.length) {
const { confirmed } = await this.popup.add(ConfirmPopup, {
title: this.env._t("Products not available in POS"),
body: this.env._t(
title: _t("Products not available in POS"),
body: _t(
"Some of the products in your Sale Order are not available in POS, do you want to import them?"
),
confirmText: this.env._t("Yes"),
cancelText: this.env._t("No"),
confirmText: _t("Yes"),
cancelText: _t("No"),
});
if (confirmed) {
await this.pos._addProducts(product_to_add_in_pos);
@@ -232,12 +233,12 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(Component) {
const { confirmed } =
useLoadedLots === undefined
? await this.popup.add(ConfirmPopup, {
title: this.env._t("SN/Lots Loading"),
body: this.env._t(
title: _t("SN/Lots Loading"),
body: _t(
"Do you want to load the SN/Lots linked to the Sales Order?"
),
confirmText: this.env._t("Yes"),
cancelText: this.env._t("No"),
confirmText: _t("Yes"),
cancelText: _t("No"),
})
: { confirmed: useLoadedLots };
useLoadedLots = confirmed;
@@ -271,9 +272,7 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(Component) {
this.pos.config.down_payment_product_id[0]
);
if (!down_payment_product) {
await this.pos._addProducts([
this.pos.config.down_payment_product_id[0],
]);
await this.pos._addProducts([this.pos.config.down_payment_product_id[0]]);
down_payment_product = this.pos.db.get_product_by_id(
this.pos.config.down_payment_product_id[0]
);
@@ -293,12 +292,12 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(Component) {
let popupInputSuffix = "";
const popupTotalDue = sale_order.amount_total;
let getInputBufferReminder = () => false;
const popupSubtitle = this.env._t("Due balance: %s");
const popupSubtitle = _t("Due balance: %s");
if (selectedOption == "dpAmount") {
popupTitle = this.env._t("Down Payment");
popupTitle = _t("Down Payment");
popupInputSuffix = this.pos.currency.symbol;
} else {
popupTitle = this.env._t("Down Payment");
popupTitle = _t("Down Payment");
popupInputSuffix = "%";
getInputBufferReminder = (buffer) => {
if (buffer && buffer.length > 0) {
@@ -335,7 +334,7 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(Component) {
}
if (down_payment > sale_order.amount_unpaid) {
const errorBody = this.env._t(
const errorBody = _t(
"You have tried to charge a down payment of %s but only %s remains to be paid, %s will be applied to the purchase order line.",
this.env.utils.formatCurrency(down_payment),
this.env.utils.formatCurrency(sale_order.amount_unpaid),
@@ -365,8 +364,8 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(Component) {
new_line.set_unit_price(down_payment);
this.pos.get_order().add_orderline(new_line);
} else {
const title = this.env._t("No down payment product");
const body = this.env._t(
const title = _t("No down payment product");
const body = _t(
"It seems that you didn't configure a down payment product in your point of sale.\
You can go to your point of sale configuration to choose one."
);
@@ -1,4 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { Component, useState } from "@odoo/owl";
import { useService } from "@web/core/utils/hooks";
import { deserializeDateTime } from "@web/core/l10n/dates";
@@ -52,11 +54,11 @@ export class SaleOrderRow extends Component {
}
get state() {
const state_mapping = {
draft: this.env._t("Quotation"),
sent: this.env._t("Quotation Sent"),
sale: this.env._t("Sales Order"),
done: this.env._t("Locked"),
cancel: this.env._t("Cancelled"),
draft: _t("Quotation"),
sent: _t("Quotation Sent"),
sale: _t("Sales Order"),
done: _t("Locked"),
cancel: _t("Cancelled"),
};
return state_mapping[this.order.state];
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { Component, onWillUnmount, useState } from "@odoo/owl";
import { useSelfOrder } from "@pos_self_order/self_order_service";
import { NavBar } from "@pos_self_order/components/navbar/navbar";
@@ -90,7 +91,7 @@ export class ProductMainView extends Component {
if (!increase && sentQty === currentQty) {
this.selfOrder.notification.add(
this.env._t(
_t(
"You cannot reduce the quantity of an order that has already been sent!"
),
{ type: "danger" }
@@ -1,6 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { Component, markup, onRendered, onWillStart, useState } from "@odoo/owl";
import { Layout } from "@web/search/layout";
import { registry } from "@web/core/registry";
@@ -46,7 +46,7 @@ export class ProductPricelistReport extends Component {
});
onRendered(() => {
this.env.config.setDisplayName(this.env._t("Pricelist Report"));
this.env.config.setDisplayName(_t("Pricelist Report"));
});
/*
@@ -122,7 +122,7 @@ export class ProductPricelistReport extends Component {
ev.preventDefault(); // avoid automatic reloading of the page
if (this.quantities.length >= this.MAX_QTY) {
let message = this.env._t(
let message = _t(
"At most %s quantities can be displayed simultaneously. Remove a selected quantity to add others.",
this.MAX_QTY
);
@@ -138,12 +138,12 @@ export class ProductPricelistReport extends Component {
this.quantities = this.quantities.sort((a, b) => a - b);
this.renderHtml();
} else {
let message = this.env._t("Quantity already present (%s).", qty);
let message = _t("Quantity already present (%s).", qty);
await this.action.doAction(sendCustomNotification("info", message));
}
} else {
await this.action.doAction(
sendCustomNotification("info", this.env._t("Please enter a positive whole number."))
sendCustomNotification("info", _t("Please enter a positive whole number."))
);
}
}
@@ -179,7 +179,7 @@ export class ProductPricelistReport extends Component {
async onClickRemoveQty(ev) {
if (this.quantities.length <= 1) {
await this.action.doAction(
sendCustomNotification("warning", this.env._t("You must leave at least one quantity."))
sendCustomNotification("warning", _t("You must leave at least one quantity."))
);
return;
}
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { Dialog } from '@web/core/dialog/dialog';
import { formatMonetary } from "@web/views/fields/formatters";
import { useHotkey } from "@web/core/hotkeys/hotkey_hook";
@@ -9,7 +10,7 @@ const { Component, onMounted, markup, useRef } = owl;
export class ProductMatrixDialog extends Component {
setup() {
this.size = 'xl';
this.title = this.env._t("Choose Product Variants");
this.title = _t("Choose Product Variants");
const productMatrixRef = useRef('productMatrix');
useHotkey("enter", () => this._onConfirm(), {
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { registry } from '@web/core/registry';
import { Many2OneField, many2OneField } from '@web/views/fields/many2one/many2one_field';
@@ -8,7 +9,7 @@ export class ProjectMany2OneField extends Many2OneField {
const props = super.Many2XAutocompleteProps;
const { project_id, parent_id } = this.props.record.data;
if (!project_id && !parent_id) {
props.placeholder = this.env._t("Private");
props.placeholder = _t("Private");
}
return props;
}
@@ -3,6 +3,7 @@
import { formatDate } from "@web/core/l10n/dates";
import { useService } from '@web/core/utils/hooks';
import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog";
import { _t } from "@web/core/l10n/translation";
const { Component, useState, onWillUpdateProps, status } = owl;
const { DateTime } = luxon;
@@ -49,7 +50,7 @@ export class ProjectMilestone extends Component {
async onDeleteMilestone() {
this.dialog.add(ConfirmationDialog, {
body: this.env._t("Are you sure you want to delete this record?"),
body: _t("Are you sure you want to delete this record?"),
confirm: async () => {
await this.orm.call('project.milestone', 'unlink', [this.milestone.id]);
await this.props.load();
@@ -64,7 +65,7 @@ export class ProjectMilestone extends Component {
this.props.open({
resModel: this.resModel,
resId: this.milestone.id,
title: this.env._t("Milestone"),
title: _t("Milestone"),
}, {
onClose: async () => {
if (status(this) === "mounted") {
@@ -1,5 +1,6 @@
/** @odoo-module */
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { useService } from '@web/core/utils/hooks';
import { formatFloat } from '@web/views/fields/formatters';
import { ViewButton } from '@web/views/view_button/view_button';
@@ -52,8 +53,8 @@ export class ProjectRightSidePanel extends Component {
get sectionNames() {
return {
'milestones': this.env._t('Milestones'),
'profitability': this.env._t('Profitability'),
'milestones': _t('Milestones'),
'profitability': _t('Profitability'),
};
}
@@ -115,7 +116,7 @@ export class ProjectRightSidePanel extends Component {
};
this.openFormViewDialog({
context,
title: this.env._t('New Milestone'),
title: _t('New Milestone'),
resModel: 'project.milestone',
onRecordSaved: async () => {
await this.loadMilestones();
@@ -1,12 +1,13 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { registry } from "@web/core/registry";
import { PriorityField, priorityField } from "@web/views/fields/priority/priority_field";
export class PrioritySwitchField extends PriorityField {
get commands() {
return this.options.map(([id, name]) => [
this.env._t("Set priority as %s", name),
_t("Set priority as %s", name),
() => this.updateRecord(id),
{
category: "smart_action",

Some files were not shown because too many files have changed in this diff Show More