[MIG] remote_report_to_printer: Migration to 13.0

This commit is contained in:
Olga Marco
2021-06-17 17:33:14 +02:00
parent 70d06c60c4
commit 3a37225ca1
8 changed files with 25 additions and 30 deletions

View File

@@ -14,13 +14,13 @@ Report to printer on remotes
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freport--print--send-lightgray.png?logo=github .. |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 :alt: OCA/report-print-send
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |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 :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |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 :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@@ -54,7 +54,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/report-print-send/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/OCA/report-print-send/issues>`_.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/report-print-send/issues/new?body=module:%20remote_report_to_printer%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/report-print-send/issues/new?body=module:%20remote_report_to_printer%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues. 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 mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/report-print-send <https://github.com/OCA/report-print-send/tree/12.0/remote_report_to_printer>`_ project on GitHub. This module is part of the `OCA/report-print-send <https://github.com/OCA/report-print-send/tree/13.0/remote_report_to_printer>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -4,9 +4,9 @@
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 12.0\n" "Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
@@ -14,7 +14,7 @@ msgstr ""
"Plural-Forms: \n" "Plural-Forms: \n"
#. module: remote_report_to_printer #. 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" msgid "A Remote cannot have the same printer for the same usage"
msgstr "" msgstr ""
@@ -59,7 +59,7 @@ msgid "Last Updated on"
msgstr "" msgstr ""
#. module: remote_report_to_printer #. 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 #, python-format
msgid "Only one default printer is allowed" msgid "Only one default printer is allowed"
msgstr "" msgstr ""
@@ -117,7 +117,7 @@ msgid "Report Action"
msgstr "" msgstr ""
#. module: remote_report_to_printer #. 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" msgid "Standard"
msgstr "" msgstr ""
@@ -125,4 +125,3 @@ msgstr ""
#: model:ir.model.fields,field_description:remote_report_to_printer.field_printing_action__action_type #: model:ir.model.fields,field_description:remote_report_to_printer.field_printing_action__action_type
msgid "Type" msgid "Type"
msgstr "" msgstr ""

View File

@@ -1,20 +1,18 @@
# Copyright (c) 2018 Creu Blanca # Copyright (c) 2018 Creu Blanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # 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): class IrActionsReport(models.Model):
_inherit = "ir.actions.report" _inherit = "ir.actions.report"
@api.multi
def _get_user_default_print_behaviour(self): def _get_user_default_print_behaviour(self):
res = super()._get_user_default_print_behaviour() res = super()._get_user_default_print_behaviour()
if res.get("action", "unknown") == "remote_default": if res.get("action", "unknown") == "remote_default":
res.update(self.remote.get_printer_behaviour()) res.update(self.remote.get_printer_behaviour())
return res return res
@api.multi
def _get_report_default_print_behaviour(self): def _get_report_default_print_behaviour(self):
res = super()._get_report_default_print_behaviour() res = super()._get_report_default_print_behaviour()
if res.get("action", "unknown") == "remote_default": if res.get("action", "unknown") == "remote_default":

View File

@@ -1,6 +1,6 @@
# Copyright (c) 2018 Creu Blanca # Copyright (c) 2018 Creu Blanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # 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): class ResRemote(models.Model):
@@ -10,7 +10,6 @@ class ResRemote(models.Model):
"res.remote.printer", inverse_name="remote_id", "res.remote.printer", inverse_name="remote_id",
) )
@api.multi
def get_printer_behaviour(self): def get_printer_behaviour(self):
self.ensure_one() self.ensure_one()
printer_usage = self.env.context.get("printer_usage", "standard") printer_usage = self.env.context.get("printer_usage", "standard")

View File

@@ -29,7 +29,6 @@ class ResRemotePrinter(models.Model):
""" Reset the tray when the printer is changed """ """ Reset the tray when the printer is changed """
self.printer_tray_id = False self.printer_tray_id = False
@api.multi
@api.constrains("remote_id", "printer_usage", "is_default") @api.constrains("remote_id", "printer_usage", "is_default")
def _check_remote_usage(self): def _check_remote_usage(self):
for rec in self.filtered(lambda r: r.is_default): for rec in self.filtered(lambda r: r.is_default):

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/report-print-send/tree/12.0/remote_report_to_printer"><img alt="OCA/report-print-send" src="https://img.shields.io/badge/github-OCA%2Freport--print--send-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/report-print-send-12-0/report-print-send-12-0-remote_report_to_printer"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/144/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/report-print-send/tree/13.0/remote_report_to_printer"><img alt="OCA/report-print-send" src="https://img.shields.io/badge/github-OCA%2Freport--print--send-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/report-print-send-13-0/report-print-send-13-0-remote_report_to_printer"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/144/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module allows users to send reports to a printer using remotes configuration.</p> <p>This module allows users to send reports to a printer using remotes configuration.</p>
<p>A <em>remote</em> is an external entity that access odoo. For example, computers, mobiles, <p>A <em>remote</em> is an external entity that access odoo. For example, computers, mobiles,
servers… We will identify <em>remotes</em> by its name or ip. On some environments, servers… We will identify <em>remotes</em> by its name or ip. On some environments,
@@ -404,7 +404,7 @@ work place.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/report-print-send/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/report-print-send/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/report-print-send/issues/new?body=module:%20remote_report_to_printer%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <a class="reference external" href="https://github.com/OCA/report-print-send/issues/new?body=module:%20remote_report_to_printer%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@@ -428,7 +428,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/report-print-send/tree/12.0/remote_report_to_printer">OCA/report-print-send</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/report-print-send/tree/13.0/remote_report_to_printer">OCA/report-print-send</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>

View File

@@ -12,7 +12,7 @@ class TestRemotePrinter(TransactionCase):
self.remote = self.env["res.remote"].search([("name", "=", name)]) self.remote = self.env["res.remote"].search([("name", "=", name)])
if not self.remote: if not self.remote:
self.remote = self.env["res.remote"].create( 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( self.server = self.env["printing.server"].create(
{"name": "Server", "address": "localhost", "port": 631} {"name": "Server", "address": "localhost", "port": 631}

View File

@@ -18,7 +18,7 @@ class TestRemotePrinter(TransactionCase):
self.remote = self.env["res.remote"].search([("name", "=", name)]) self.remote = self.env["res.remote"].search([("name", "=", name)])
if not self.remote: if not self.remote:
self.remote = self.env["res.remote"].create( 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( self.server = self.env["printing.server"].create(
{"name": "Server", "address": "localhost", "port": 631} {"name": "Server", "address": "localhost", "port": 631}
@@ -49,7 +49,7 @@ class TestRemotePrinter(TransactionCase):
) )
def test_constrain(self): 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, "remote_id": self.remote.id,
"printer_id": self.printer_1.id, "printer_id": self.printer_1.id,
@@ -68,7 +68,7 @@ class TestRemotePrinter(TransactionCase):
def test_onchange_printer(self): def test_onchange_printer(self):
remote_printer = ( remote_printer = (
self.env["res.remote.printer"] self.env["res.remote.printer"]
.sudo(self.printer_manager) .with_user(self.printer_manager)
.create( .create(
{ {
"remote_id": self.remote.id, "remote_id": self.remote.id,
@@ -85,7 +85,7 @@ class TestRemotePrinter(TransactionCase):
def test_permissions_delete_manager(self): def test_permissions_delete_manager(self):
printer = ( printer = (
self.env["res.remote.printer"] self.env["res.remote.printer"]
.sudo(self.printer_manager) .with_user(self.printer_manager)
.create( .create(
{ {
"remote_id": self.remote.id, "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( printer = self.env["res.remote.printer"].search(
[ [
("remote_id", "=", self.remote.id), ("remote_id", "=", self.remote.id),
@@ -107,7 +107,7 @@ class TestRemotePrinter(TransactionCase):
def test_permissions_delete_user(self): def test_permissions_delete_user(self):
printer = ( printer = (
self.env["res.remote.printer"] self.env["res.remote.printer"]
.sudo(self.printer_manager) .with_user(self.printer_manager)
.create( .create(
{ {
"remote_id": self.remote.id, "remote_id": self.remote.id,
@@ -117,11 +117,11 @@ class TestRemotePrinter(TransactionCase):
) )
) )
with self.assertRaises(AccessError): with self.assertRaises(AccessError):
printer.sudo(self.printer_user).unlink() printer.with_user(self.printer_user).unlink()
def test_permissions_create_user(self): def test_permissions_create_user(self):
with self.assertRaises(AccessError): 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, "remote_id": self.remote.id,
"printer_id": self.printer_1.id, "printer_id": self.printer_1.id,