跳至内容
菜单
此问题已终结
1 回复
3669 查看

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

形象
丢弃
最佳答案
/** @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),
};
}
});
形象
丢弃
相关帖文 回复 查看 活动
3
12月 22
11589
5
4月 24
42148
6
4月 24
38997
3
3月 24
10603
2
7月 19
765