This commit is contained in:
2026-11-08 20:08:53 +08:00
parent 7526a5fe4d
commit 9b924747c5
2692 changed files with 394867 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="ir_actions_server_ai_esg_get_emission_sources" model="ir.actions.server">
<field name="name">AI Tool: Get Emission Sources</field>
<field name="ai_tool_name">ai_tool_get_emission_sources</field>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="code">ai['result'] = record.sudo()._ai_get_emission_sources(scope)</field>
<field name="model_id" ref="esg.model_esg_carbon_emission_report"/>
<field name="ai_tool_description">Get the most relevant Emission Sources.</field>
<field name="ai_tool_schema">
{
"properties": {
"scope": {
"type": "string",
"description": "Description of the emission scope"
}
},
"required": ["scope"],
"type": "object"
}
</field>
</record>
<record id="ir_actions_server_ai_esg_get_emission_factor" model="ir.actions.server">
<field name="name">AI Tool: Get Emission Factor</field>
<field name="ai_tool_name">ai_tool_get_emission_factor</field>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="code">ai['result'] = record.sudo()._ai_get_emission_factor(source_ids)</field>
<field name="model_id" ref="esg.model_esg_carbon_emission_report"/>
<field name="ai_tool_description">Get the most relevant Emission Factor.</field>
<field name="ai_tool_schema">
{
"properties": {
"source_ids": {
"type": "array",
"items": {
"type": "number"
},
"description": "Ids of the emission sources"
}
},
"required": ["source_ids"],
"type": "object"
}
</field>
</record>
<record id="ir_actions_server_ai_esg_assign_emission_factors_to_carbon_line" model="ir.actions.server">
<field name="name">AI Tool: Assign Emission Factors to Emission Line</field>
<field name="ai_tool_name">ai_tool_assign_emission_factors_to_emission_line</field>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="code">ai['result'] = record.sudo()._ai_assign_emission_factor(factor_id)</field>
<field name="model_id" ref="esg.model_esg_carbon_emission_report"/>
<field name="ai_tool_description">Assign Emission Factor to Emission Line.</field>
<field name="ai_tool_schema">
{
"properties": {
"factor_id": {
"type": "number",
"description": "Id of the emission factor"
}
},
"required": ["factor_id"],
"type": "object"
}
</field>
</record>
</odoo>

View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="action_emission_factors_ai_auto_assignment" model="ir.actions.server">
<field name="name">Assign with AI</field>
<field name="model_id" ref="esg.model_esg_carbon_emission_report"/>
<field name="binding_model_id" ref="esg.model_esg_carbon_emission_report"/>
<field name="binding_view_types">list,kanban</field>
<field name="state">code</field>
<field name="code">
action = records.action_ai_assign_emission_factors()
</field>
<field name="group_ids" eval="[(4, ref('esg.esg_group_manager'))]"/>
</record>
<record id="emission_factors_ai_auto_assignment" model="ir.actions.server">
<field name="name">Server Action: Assign with AI</field>
<field name="model_id" ref="esg.model_esg_carbon_emission_report"/>
<field name="state">ai</field>
<field name="ai_tool_ids" eval="[
(4, ref('ai_esg.ir_actions_server_ai_esg_get_emission_sources')),
(4, ref('ai_esg.ir_actions_server_ai_esg_get_emission_factor')),
(4, ref('ai_esg.ir_actions_server_ai_esg_assign_emission_factors_to_carbon_line')),
]"/>
<field name="ai_action_prompt">
<![CDATA[
Here is an emission line whose name is <span data-ai-field="name">Name</span>, its associated account is <span data-ai-field="account_id.name">Account Name</span>, its product category is <span data-ai-field="product_category_id.complete_name">Product Category Name</span> and its partner is <span data-ai-field="partner_id.name">Partner Name</span> from the country <span data-ai-field="partner_id.country_id.name">Partner Country Name</span>.
Moreover, its unit of measure is <span data-ai-field="uom_id.name">Unit of Measure Name</span>, its currency is <span data-ai-field="currency_id.name">Currency Name</span> and its company is <span data-ai-field="company_id.name">Company Name</span>.
Here are the instructions to following in the order:
First, determine the most relevant scope for this emission line between 'direct', 'indirect' or 'indirect_others' based on the given emission line data. key: 'direct' means Direct Emission (Scope 1), key: 'indirect' means Indirect Emission (Scope 2) and key: 'indirect_others' means Other Indirect Emission (Scope 3).
Secondly, determine the most relevant emission sources among the ones filtered by the scope (using the key) given in the previous step, and the emission line data. Select maximum 10 sources.
Thirdly, determine the most relevant emission factor among the ones filtered by the sources given in the previous step, and the emission line data. Try to match the most relevant fields such as name, uom_name, currency_name, region, company_name, etc.
Finally, assign the emission factor field of the emission line to the emission factor you found in the previous step.
]]>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="esg_esrs_efrag_list" model="ir.attachment">
<field name="name">EFRAG List of ESRS data points</field>
<field name="raw" type="bytes" file="esg/data/esg.esrs.csv"/>
<field name="mimetype">text/csv</field>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="ir_cron_ai_esg_assign_emission_factors_to_emission_line" model="ir.cron">
<field name="name">AI ESG: Cron to Assign Emission Factors to Emission Line</field>
<field name="model_id" ref="esg.model_esg_carbon_emission_report"/>
<field name="state">code</field>
<field name="code">model._cron_ai_assign_emission_factors()</field>
<field name="interval_number">9999</field>
<field name="interval_type">months</field>
</record>
</odoo>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="mail_template_data_ai_esg_assign_emission_factors_success" model="mail.template">
<field name="name">ESG: AI Assign of Emission Factors - Success</field>
<field name="model_id" ref="esg.model_esg_carbon_emission_report"/>
<field name="subject">ESG - AI Assign of Emission Factors</field>
<field name="description">Automatic email sent to the user after successfully assigning emission factors to all selected emissions using AI</field>
<field name="auto_delete" eval="True"/>
<field name="use_default_to" eval="False"/>
<field name="body_html" type="html">
<div>
<p>The request to assign emission factors to your emission lines using AI has been successfully completed.</p>
<p>You can review the emissions assigned in your ESG app.</p>
</div>
</field>
</record>
<record id="mail_template_data_ai_esg_assign_emission_factors_failure" model="mail.template">
<field name="name">ESG: AI Assign of Emission Factors - Failure</field>
<field name="model_id" ref="esg.model_esg_carbon_emission_report"/>
<field name="subject">ESG - AI Assign of Emission Factors</field>
<field name="description">Automatic email sent to the user after failing to assign emission factors to some selected emissions using AI</field>
<field name="auto_delete" eval="True"/>
<field name="use_default_to" eval="False"/>
<field name="body_html" type="html">
<div>
<p>The request to assign emission factors to your emission lines using AI has been completed. Note that some emissions could not get assigned due to unexpected errors.</p>
<p>You can review the emissions assigned in your ESG app.</p>
</div>
</field>
</record>
</data>
</odoo>