From 297e492d550af0b79f9d10a611cfa1ca1234ebd0 Mon Sep 17 00:00:00 2001 From: Ashish Hirpara Date: Thu, 17 Mar 2022 18:00:53 +0530 Subject: [PATCH] [MIG] server_action_navigate: Migration to 14.0 --- server_action_navigate/__init__.py | 1 + server_action_navigate/__manifest__.py | 7 ++++--- server_action_navigate/hooks.py | 7 +++++++ server_action_navigate/i18n/it.po | 0 .../models/ir_actions_server.py | 4 +++- .../models/ir_actions_server_navigate_line.py | 16 +++++++++------- server_action_navigate/readme/CONTRIBUTORS.rst | 1 + .../static/description/index.html | 18 +++++++++++------- 8 files changed, 36 insertions(+), 18 deletions(-) create mode 100644 server_action_navigate/hooks.py create mode 100644 server_action_navigate/i18n/it.po diff --git a/server_action_navigate/__init__.py b/server_action_navigate/__init__.py index 0650744f..071962a3 100644 --- a/server_action_navigate/__init__.py +++ b/server_action_navigate/__init__.py @@ -1 +1,2 @@ from . import models +from .hooks import uninstall_hook diff --git a/server_action_navigate/__manifest__.py b/server_action_navigate/__manifest__.py index ea965ea7..45d29419 100644 --- a/server_action_navigate/__manifest__.py +++ b/server_action_navigate/__manifest__.py @@ -4,14 +4,15 @@ { "name": "Server Actions - Navigate", - "version": "13.0.1.0.0", - "author": "GRAP, " "Odoo Community Association (OCA)", + "version": "14.0.1.0.0", + "author": "GRAP, Odoo Community Association (OCA)", "summary": "Navigate between any items of any Odoo Models", "category": "Tools", "website": "https://github.com/OCA/server-backend", "license": "AGPL-3", "depends": ["base"], - "maintainers": ["legalsylvain"], + "maintainers": ["legalsylvain", "ashishhirpara"], "data": ["security/ir.model.access.csv", "views/view_ir_actions_server.xml"], "demo": ["demo/ir_actions_server.xml"], + "uninstall_hook": "uninstall_hook", } diff --git a/server_action_navigate/hooks.py b/server_action_navigate/hooks.py new file mode 100644 index 00000000..6346e2ba --- /dev/null +++ b/server_action_navigate/hooks.py @@ -0,0 +1,7 @@ +from odoo import SUPERUSER_ID, api + + +def uninstall_hook(cr, registry): + env = api.Environment(cr, SUPERUSER_ID, {}) + env["ir.actions.server.navigate.line"].search([]).unlink() + env["ir.actions.server"].search([("state", "=", "navigate")]).unlink() diff --git a/server_action_navigate/i18n/it.po b/server_action_navigate/i18n/it.po new file mode 100644 index 00000000..e69de29b diff --git a/server_action_navigate/models/ir_actions_server.py b/server_action_navigate/models/ir_actions_server.py index 5395cbba..f5984280 100644 --- a/server_action_navigate/models/ir_actions_server.py +++ b/server_action_navigate/models/ir_actions_server.py @@ -9,7 +9,9 @@ from odoo.exceptions import UserError class IrActionsServer(models.Model): _inherit = "ir.actions.server" - state = fields.Selection(selection_add=[("navigate", "Navigate")]) + state = fields.Selection( + selection_add=[("navigate", "Navigate")], ondelete={"navigate": "set default"} + ) navigate_action_id = fields.Many2one( string="Navigation Action", diff --git a/server_action_navigate/models/ir_actions_server_navigate_line.py b/server_action_navigate/models/ir_actions_server_navigate_line.py index 4daa8ff1..07343d41 100644 --- a/server_action_navigate/models/ir_actions_server_navigate_line.py +++ b/server_action_navigate/models/ir_actions_server_navigate_line.py @@ -22,19 +22,21 @@ class IrActionsServerNavigateLine(models.Model): ) field_id = fields.Many2one( - comodel_name="ir.model.fields", string="Field", required=True + comodel_name="ir.model.fields", + string="Field", + required=True, + ondelete="cascade", ) # when adding a record, onchange is called for every field on the # form, also in editable list views @api.onchange("field_id") def _onchange_field_id(self): - # check out the docstring of this in odoo/models.py - lines = self.action_id.resolve_2many_commands( - "navigate_line_ids", - self.env.context.get("navigate_line_ids", []), - ) - lines = sum(map(self.new, lines), self.browse([])) + + lines = self.action_id.new( + {"navigate_line_ids": self.env.context.get("navigate_line_ids", [])} + ).navigate_line_ids + model = lines[-1:].field_id.relation or self.action_id.model_id.model return { "domain": { diff --git a/server_action_navigate/readme/CONTRIBUTORS.rst b/server_action_navigate/readme/CONTRIBUTORS.rst index e1525ce0..6da16266 100644 --- a/server_action_navigate/readme/CONTRIBUTORS.rst +++ b/server_action_navigate/readme/CONTRIBUTORS.rst @@ -1 +1,2 @@ * Sylvain LE GAL (https://www.twitter.com/legalsylvain) +* Ashish Hirpara (https://ashish-hirpara.com) diff --git a/server_action_navigate/static/description/index.html b/server_action_navigate/static/description/index.html index eeac420e..70c5af21 100644 --- a/server_action_navigate/static/description/index.html +++ b/server_action_navigate/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/server-backend Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/server-backend Translate me on Weblate Try me on Runbot

This module provides a generic tool to have the possibility to see a list of records associated to a given selection of records. This is basically the UI version of recordset.mapped('field1.field2').

For example, if you use the sale module, you can configure an action to see @@ -393,7 +393,7 @@ all the products that have been sold for a given selection of sale orders.

  • Create a new item
  • -https://raw.githubusercontent.com/OCA/server-backend/13.0/server_action_navigate/static/description/ir_actions_server_form.png +https://raw.githubusercontent.com/OCA/server-backend/14.0/server_action_navigate/static/description/ir_actions_server_form.png
    -https://raw.githubusercontent.com/OCA/server-backend/13.0/server_action_navigate/static/description/sale_order_tree.png +https://raw.githubusercontent.com/OCA/server-backend/14.0/server_action_navigate/static/description/sale_order_tree.png
    -https://raw.githubusercontent.com/OCA/server-backend/13.0/server_action_navigate/static/description/product_product_tree.png +https://raw.githubusercontent.com/OCA/server-backend/14.0/server_action_navigate/static/description/product_product_tree.png
    @@ -433,7 +433,7 @@ button.

    Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -feedback.

    +feedback.

    Do not contact contributors directly about support or help with technical issues.

    @@ -442,12 +442,16 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

    Authors

    Contributors

    @@ -458,8 +462,8 @@ If you spotted it first, help us smashing it by providing a detailed and welcome mission is to support the collaborative development of Odoo features and promote its widespread use.

    Current maintainer:

    -

    legalsylvain

    -

    This module is part of the OCA/server-backend project on GitHub.

    +

    legalsylvain

    +

    This module is part of the OCA/server-backend project on GitHub.

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.