mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[MIG] remote_report_to_printer: Migration to 13.0
This commit is contained in:
1
oca_dependencies.txt
Normal file
1
oca_dependencies.txt
Normal file
@@ -0,0 +1 @@
|
||||
server-tools
|
||||
@@ -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":
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user