From 3a37225ca10105b75b8f0dcd1f83c3cf8267033a Mon Sep 17 00:00:00 2001 From: Olga Marco Date: Thu, 17 Jun 2021 17:33:14 +0200 Subject: [PATCH] [MIG] remote_report_to_printer: Migration to 13.0 --- remote_report_to_printer/README.rst | 10 +++++----- .../i18n/remote_report_to_printer.pot | 13 ++++++------- .../models/ir_actions_report.py | 4 +--- remote_report_to_printer/models/res_remote.py | 3 +-- .../models/res_remote_printer.py | 1 - .../static/description/index.html | 6 +++--- remote_report_to_printer/tests/test_printer.py | 2 +- .../tests/test_remote_printer.py | 16 ++++++++-------- 8 files changed, 25 insertions(+), 30 deletions(-) diff --git a/remote_report_to_printer/README.rst b/remote_report_to_printer/README.rst index 1bd946e..fc8b5d1 100644 --- a/remote_report_to_printer/README.rst +++ b/remote_report_to_printer/README.rst @@ -14,13 +14,13 @@ Report to printer on remotes :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freport--print--send-lightgray.png?logo=github - :target: https://github.com/OCA/report-print-send/tree/12.0/remote_report_to_printer + :target: https://github.com/OCA/report-print-send/tree/13.0/remote_report_to_printer :alt: OCA/report-print-send .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/report-print-send-12-0/report-print-send-12-0-remote_report_to_printer + :target: https://translation.odoo-community.org/projects/report-print-send-13-0/report-print-send-13-0-remote_report_to_printer :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/144/12.0 + :target: https://runbot.odoo-community.org/runbot/144/13.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -54,7 +54,7 @@ Bug Tracker 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. @@ -84,6 +84,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/report-print-send `_ project on GitHub. +This module is part of the `OCA/report-print-send `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/remote_report_to_printer/i18n/remote_report_to_printer.pot b/remote_report_to_printer/i18n/remote_report_to_printer.pot index 3a1b8f4..68c77f8 100644 --- a/remote_report_to_printer/i18n/remote_report_to_printer.pot +++ b/remote_report_to_printer/i18n/remote_report_to_printer.pot @@ -1,12 +1,12 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * remote_report_to_printer +# * remote_report_to_printer # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" +"Project-Id-Version: Odoo Server 13.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: <>\n" +"Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -14,7 +14,7 @@ msgstr "" "Plural-Forms: \n" #. module: remote_report_to_printer -#: sql_constraint:res.remote.printer:0 +#: model:ir.model.constraint,message:remote_report_to_printer.constraint_res_remote_printer_unique_printer_remote_usage msgid "A Remote cannot have the same printer for the same usage" msgstr "" @@ -59,7 +59,7 @@ msgid "Last Updated on" msgstr "" #. module: remote_report_to_printer -#: code:addons/remote_report_to_printer/models/res_remote_printer.py:49 +#: code:addons/remote_report_to_printer/models/res_remote_printer.py:0 #, python-format msgid "Only one default printer is allowed" msgstr "" @@ -117,7 +117,7 @@ msgid "Report Action" msgstr "" #. module: remote_report_to_printer -#: selection:res.remote.printer,printer_usage:0 +#: model:ir.model.fields.selection,name:remote_report_to_printer.selection__res_remote_printer__printer_usage__standard msgid "Standard" msgstr "" @@ -125,4 +125,3 @@ msgstr "" #: model:ir.model.fields,field_description:remote_report_to_printer.field_printing_action__action_type msgid "Type" msgstr "" - diff --git a/remote_report_to_printer/models/ir_actions_report.py b/remote_report_to_printer/models/ir_actions_report.py index 797eb18..4e26a29 100644 --- a/remote_report_to_printer/models/ir_actions_report.py +++ b/remote_report_to_printer/models/ir_actions_report.py @@ -1,20 +1,18 @@ # Copyright (c) 2018 Creu Blanca # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, models +from odoo import models class IrActionsReport(models.Model): _inherit = "ir.actions.report" - @api.multi def _get_user_default_print_behaviour(self): res = super()._get_user_default_print_behaviour() if res.get("action", "unknown") == "remote_default": res.update(self.remote.get_printer_behaviour()) return res - @api.multi def _get_report_default_print_behaviour(self): res = super()._get_report_default_print_behaviour() if res.get("action", "unknown") == "remote_default": diff --git a/remote_report_to_printer/models/res_remote.py b/remote_report_to_printer/models/res_remote.py index 69b9ce6..8fb8cc4 100644 --- a/remote_report_to_printer/models/res_remote.py +++ b/remote_report_to_printer/models/res_remote.py @@ -1,6 +1,6 @@ # Copyright (c) 2018 Creu Blanca # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, fields, models +from odoo import fields, models class ResRemote(models.Model): @@ -10,7 +10,6 @@ class ResRemote(models.Model): "res.remote.printer", inverse_name="remote_id", ) - @api.multi def get_printer_behaviour(self): self.ensure_one() printer_usage = self.env.context.get("printer_usage", "standard") diff --git a/remote_report_to_printer/models/res_remote_printer.py b/remote_report_to_printer/models/res_remote_printer.py index 197e632..0e3f02c 100644 --- a/remote_report_to_printer/models/res_remote_printer.py +++ b/remote_report_to_printer/models/res_remote_printer.py @@ -29,7 +29,6 @@ class ResRemotePrinter(models.Model): """ Reset the tray when the printer is changed """ self.printer_tray_id = False - @api.multi @api.constrains("remote_id", "printer_usage", "is_default") def _check_remote_usage(self): for rec in self.filtered(lambda r: r.is_default): diff --git a/remote_report_to_printer/static/description/index.html b/remote_report_to_printer/static/description/index.html index d7b56ea..ba291da 100644 --- a/remote_report_to_printer/static/description/index.html +++ b/remote_report_to_printer/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/report-print-send Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/report-print-send Translate me on Weblate Try me on Runbot

This module allows users to send reports to a printer using remote’s configuration.

A remote is an external entity that access odoo. For example, computers, mobiles, servers… We will identify remotes by its name or ip. On some environments, @@ -404,7 +404,7 @@ work place.

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.

@@ -428,7 +428,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

This module is part of the OCA/report-print-send project on GitHub.

+

This module is part of the OCA/report-print-send project on GitHub.

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

diff --git a/remote_report_to_printer/tests/test_printer.py b/remote_report_to_printer/tests/test_printer.py index 5aacda2..9d92d6d 100644 --- a/remote_report_to_printer/tests/test_printer.py +++ b/remote_report_to_printer/tests/test_printer.py @@ -12,7 +12,7 @@ class TestRemotePrinter(TransactionCase): self.remote = self.env["res.remote"].search([("name", "=", name)]) if not self.remote: self.remote = self.env["res.remote"].create( - {"name": name, "ip": "127.0.0.1"} + {"name": name, "ip": "127.0.0.1", "in_network": True} ) self.server = self.env["printing.server"].create( {"name": "Server", "address": "localhost", "port": 631} diff --git a/remote_report_to_printer/tests/test_remote_printer.py b/remote_report_to_printer/tests/test_remote_printer.py index 6d3431e..636bd9d 100644 --- a/remote_report_to_printer/tests/test_remote_printer.py +++ b/remote_report_to_printer/tests/test_remote_printer.py @@ -18,7 +18,7 @@ class TestRemotePrinter(TransactionCase): self.remote = self.env["res.remote"].search([("name", "=", name)]) if not self.remote: self.remote = self.env["res.remote"].create( - {"name": name, "ip": "127.0.0.1"} + {"name": name, "ip": "127.0.0.1", "in_network": True} ) self.server = self.env["printing.server"].create( {"name": "Server", "address": "localhost", "port": 631} @@ -49,7 +49,7 @@ class TestRemotePrinter(TransactionCase): ) def test_constrain(self): - self.env["res.remote.printer"].sudo(self.printer_manager).create( + self.env["res.remote.printer"].with_user(self.printer_manager).create( { "remote_id": self.remote.id, "printer_id": self.printer_1.id, @@ -68,7 +68,7 @@ class TestRemotePrinter(TransactionCase): def test_onchange_printer(self): remote_printer = ( self.env["res.remote.printer"] - .sudo(self.printer_manager) + .with_user(self.printer_manager) .create( { "remote_id": self.remote.id, @@ -85,7 +85,7 @@ class TestRemotePrinter(TransactionCase): def test_permissions_delete_manager(self): printer = ( self.env["res.remote.printer"] - .sudo(self.printer_manager) + .with_user(self.printer_manager) .create( { "remote_id": self.remote.id, @@ -94,7 +94,7 @@ class TestRemotePrinter(TransactionCase): } ) ) - printer.sudo(self.printer_manager).unlink() + printer.with_user(self.printer_manager).unlink() printer = self.env["res.remote.printer"].search( [ ("remote_id", "=", self.remote.id), @@ -107,7 +107,7 @@ class TestRemotePrinter(TransactionCase): def test_permissions_delete_user(self): printer = ( self.env["res.remote.printer"] - .sudo(self.printer_manager) + .with_user(self.printer_manager) .create( { "remote_id": self.remote.id, @@ -117,11 +117,11 @@ class TestRemotePrinter(TransactionCase): ) ) with self.assertRaises(AccessError): - printer.sudo(self.printer_user).unlink() + printer.with_user(self.printer_user).unlink() def test_permissions_create_user(self): with self.assertRaises(AccessError): - self.env["res.remote.printer"].sudo(self.printer_user).create( + self.env["res.remote.printer"].with_user(self.printer_user).create( { "remote_id": self.remote.id, "printer_id": self.printer_1.id,