Skip to content

Commit

Permalink
[MIG] endpoint: Migration to V12
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiMForgeFlow committed Nov 27, 2024
1 parent 14a3371 commit ed87628
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion endpoint/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Endpoint",
"summary": """Provide custom endpoint machinery.""",
"version": "13.0.1.0.0",
"version": "12.0.1.0.0",
"license": "LGPL-3",
"development_status": "Beta",
"author": "Camptocamp,Odoo Community Association (OCA)",
Expand Down
14 changes: 9 additions & 5 deletions endpoint/models/endpoint_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@ def _code_snippet_log_func(self, message, level="info"):
with self.pool.cursor() as cr:
cr.execute(
"""
INSERT INTO ir_logging
(create_date, create_uid, type, dbname, name, level, message, path, line, func)
INSERT INTO ir_logging (
create_date, create_uid, type, dbname, name, level,
message, path, line, func
)
VALUES (NOW() at time zone 'UTC', %s, %s, %s, %s, %s, %s, %s, %s, %s)
""",
(
Expand Down Expand Up @@ -159,7 +161,9 @@ def _code_snippet_valued(self):

def _default_endpoint_options_handler(self):
return {
"klass_dotted_path": "odoo.addons.endpoint.controllers.main.EndpointController",
"klass_dotted_path": (
"odoo.addons.endpoint.controllers.main.EndpointController"
),
"method_name": "auto_endpoint",
"default_pargs": (self._name, self.route),
}
Expand Down Expand Up @@ -188,7 +192,7 @@ def _handle_request(self, request):
# Switch user for the whole process
self_with_user = self
if self.exec_as_user_id:
self_with_user = self.with_user(user=self.exec_as_user_id)
self_with_user = self.sudo(user=self.exec_as_user_id)
handler = self_with_user._get_handler()
try:
res = handler(request)
Expand All @@ -213,5 +217,5 @@ def copy_data(self, default=None):
# Yet, we want to be able to duplicate a record from the UI.
for rec, data in zip(self, result):
if not data.get("route"):
data["route"] = f"{rec.route}/COPY_FIXME"
data["route"] = "{}/COPY_FIXME".format(rec.route)
return result
2 changes: 1 addition & 1 deletion endpoint/security/ir_rule.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<field name="global" eval="True" />
<field
name="domain_force"
>['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>
>['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
</record>
</odoo>
14 changes: 7 additions & 7 deletions endpoint/views/endpoint_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
<field name="arch" type="xml">
<form>
<header />
<field name="active" invisible="1" />
<field name="registry_sync" invisible="1" />
<widget
name="web_ribbon"
title="Archived"
bg_color="bg-warning"
attrs="{'invisible': [('active', '=', True)]}"
/>
<sheet>
<div class="oe_button_box" name="button_box">
<button name="toggle_active" type="object"
class="oe_stat_button" icon="fa-archive">
<field name="active" widget="boolean_button"
options='{"terminology": "archive"}'/>
</button>
</div>
<div
class="alert alert-warning"
role="alert"
Expand Down

0 comments on commit ed87628

Please sign in to comment.