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 @@
from . import ir_actions_server

View File

@@ -0,0 +1,34 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
from odoo.exceptions import ValidationError
from odoo.tools import _
class IrActionsServer(models.Model):
_inherit = "ir.actions.server"
_explanation = "AI extensions for server actions, adding the capability to update record fields using AI-generated content based on a specified prompt."
evaluation_type = fields.Selection(
selection_add=[("ai_computed", "Update with AI")],
)
ai_update_prompt = fields.Html("AI Update Prompt", sanitize=True, sanitize_output_method="xml")
update_field_name = fields.Char(related='update_field_id.name')
update_field_relation = fields.Char(related="update_field_id.relation")
update_field_type = fields.Selection(related='update_field_id.ttype')
@api.constrains('evaluation_type', 'update_field_id', 'state')
def _check_ai_evaluation_type(self):
for action in self:
if action.state == 'object_write' and action.evaluation_type == 'ai_computed' and not action.update_field_id.store:
raise ValidationError(_("This field can not be computed with AI (not stored)."))
def _run_action_object_write(self, eval_context=None):
ai_actions = self.filtered(lambda a: a.evaluation_type == "ai_computed")
if self - ai_actions:
super(IrActionsServer, self - ai_actions)._run_action_object_write(eval_context)
records = self._ai_get_records(eval_context)
for action in ai_actions:
field = action.update_field_id
records._fill_ai_field(self.env[field.model]._fields.get(field.name), action.ai_update_prompt)