Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
3691 Visualizzazioni

Hai to all,

 I will add analytic account to Sales Order form. the how will add domain filter for the Analytic Account in Sale Order where Analytic Account is parent Account of Order Number

Avatar
Abbandona
Risposta migliore
/** @odoo-module */

import { patch } from "@web/core/utils/patch";
import { _t } from "@web/core/l10n/translation";
import { AnalyticDistribution } from "@analytic/components/analytic_distribution/analytic_distribution";

patch(AnalyticDistribution.prototype, {
recordProps(line) {
const analyticAccountFields = {
id: { type: "int" },
display_name: { type: "char" },
color: { type: "int" },
plan_id: { type: "many2one" },
root_plan_id: { type: "many2one" },
};
let recordFields = {};
const values = {};
// Analytic Account fields
line.analyticAccounts.map((account) => {
const fieldName = `x_plan${account.planId}_id`;
recordFields[fieldName] = {
string: account.planName,
relation: "account.analytic.account",
type: "many2one",
related: {
fields: analyticAccountFields,
activeFields: analyticAccountFields,
},
// company domain might be required here
domain: [["root_plan_id", "=", account.planId]], (ADD DOMAIN)
};
values[fieldName] = account?.accountId || false;
});
// Percentage field
recordFields['percentage'] = {
string: _t("Percentage"),
type: "percentage",
cellClass: "numeric_column_width",
...this.decimalPrecision,
};
values['percentage'] = line.percentage;
// Value field copied from original
if (this.props.amount_field) {
const { string, name, type, currency_field } = this.props.record.fields[this.props.amount_field];
recordFields[name] = { string, name, type, currency_field, cellClass: "numeric_column_width" };
values[name] = this.props.record.data[name] * values['percentage'];
// Currency field
if (currency_field) {
// TODO: check web_read network request
const { string, name, type, relation } = this.props.record.fields[currency_field];
recordFields[currency_field] = { name, string, type, relation, invisible: true };
values[currency_field] = this.props.record.data[currency_field][0];
}
}
return {
fields: recordFields,
values: values,
activeFields: recordFields,
onRecordChanged: async (record, changes) => await this.lineChanged(record, changes, line),
};
}
});
Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
3
dic 22
11609
5
apr 24
42169
6
apr 24
39015
3
mar 24
10616
2
lug 19
765