Merge PR #177 into 12.0

Signed-off-by pedrobaeza
This commit is contained in:
OCA-git-bot
2021-02-08 10:51:12 +00:00
22 changed files with 788 additions and 0 deletions

1
oca_dependencies.txt Normal file
View File

@@ -0,0 +1 @@
server-tools

View File

@@ -0,0 +1,89 @@
============================
Report to printer on remotes
============================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
: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
: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
: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
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
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,
we want to configure the printers by remote, because users may change their
work place.
It adds an optional behaviour on reports to send it directly to a printer.
* `Use remote's configuration` use the remote's behaviour
Also, this option can be selected as a user default option for printer.
**Table of contents**
.. contents::
:local:
Usage
=====
* In *Settings > Remotes* configure the remotes printers by usage
Bug Tracker
===========
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.
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**>`_.
Do not contact contributors directly about support or help with technical issues.
Credits
=======
Authors
~~~~~~~
* Creu Blanca
Contributors
~~~~~~~~~~~~
* Enric Tobella <etobella@creublanca.es>
Maintainers
~~~~~~~~~~~
This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
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 <https://github.com/OCA/report-print-send/tree/12.0/remote_report_to_printer>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -0,0 +1 @@
from . import models

View File

@@ -0,0 +1,19 @@
# Copyright (c) 2018 Creu Blanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': "Report to printer on remotes",
'version': '12.0.2.1.1',
'category': 'Generic Modules/Base',
'author': "Creu Blanca, Odoo Community Association (OCA)",
'website': 'http://www.github.com/OCA/report-print-send',
'license': 'AGPL-3',
"depends": ['base_remote', 'base_report_to_printer'],
'data': [
'data/printing_data.xml',
'security/ir.model.access.csv',
'views/res_remote_views.xml',
'views/res_remote_printer_views.xml',
],
'installable': True,
}

View File

@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<odoo noupdate="1">
<record model="printing.action" id="printing_action_remote">
<field name="name">Use Remote Defaults</field>
<field name="action_type">remote_default</field>
</record>
<record model="printing.action" id="printing_action_3">
<field name="name">Use User Defaults</field>
<field name="action_type">user_default</field>
</record>
</odoo>

View File

@@ -0,0 +1,129 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * remote_report_to_printer
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2018-11-16 20:19+0000\n"
"Last-Translator: Enric Tobella <etobella@creublanca.es>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 3.2.2\n"
#. module: remote_report_to_printer
#: sql_constraint:res.remote.printer:0
msgid "A Remote cannot have the same printer for the same usage"
msgstr "El remoto no puede repetir la misma impresora para el mismo uso"
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer_create_uid
msgid "Created by"
msgstr "Creado por"
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer_create_date
msgid "Created on"
msgstr "Creado en"
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer_display_name
msgid "Display Name"
msgstr "Nombre mostrado"
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer_id
msgid "ID"
msgstr "ID"
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer_is_default
msgid "Is Default"
msgstr "Por defecto"
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer___last_update
msgid "Last Modified on"
msgstr "Última modificación el"
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer_write_uid
msgid "Last Updated by"
msgstr "Última actualización por"
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer_write_date
msgid "Last Updated on"
msgstr "Última actualización el"
#. module: remote_report_to_printer
#: code:addons/remote_report_to_printer/models/res_remote_printer.py:48
#, python-format
msgid "Only one default printer is allowed"
msgstr "Sólo se permite una impresora por defecto"
#. module: remote_report_to_printer
#: model:ir.model,name:remote_report_to_printer.model_printing_action
msgid "Print Job Action"
msgstr "Acción de imprimir un trabajo"
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer_printer_id
msgid "Printer"
msgstr "Impresora"
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer_printer_tray_id
msgid "Printer Tray"
msgstr "Bandeja de impresora"
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer_printer_usage
msgid "Printer Usage"
msgstr "Uso de impresora"
#. module: remote_report_to_printer
#: model:ir.ui.view,arch_db:remote_report_to_printer.res_remote_form
msgid "Printers"
msgstr "Impresoras"
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer_remote_id
msgid "Remote"
msgstr "Remoto"
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_remote_printer_ids
#: model:ir.ui.view,arch_db:remote_report_to_printer.res_remote_printer_form
msgid "Remote Printer"
msgstr "Impresora de remoto"
#. module: remote_report_to_printer
#: model:ir.ui.view,arch_db:remote_report_to_printer.res_remote_printer_tree
msgid "Remote Printers"
msgstr "Impresoras de remoto"
#. module: remote_report_to_printer
#: model:ir.model,name:remote_report_to_printer.model_res_remote
msgid "Remotes"
msgstr "Remotos"
#. module: remote_report_to_printer
#: selection:res.remote.printer,printer_usage:0
msgid "Standard"
msgstr "Estándar"
#. module: remote_report_to_printer
#: model:ir.model,name:remote_report_to_printer.model_ir_actions_report
msgid "ir.actions.report"
msgstr "ir.actions.report"
#. module: remote_report_to_printer
#: model:ir.model,name:remote_report_to_printer.model_res_remote_printer
msgid "res.remote.printer"
msgstr "res.remote.printer"

View File

@@ -0,0 +1,127 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * remote_report_to_printer
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: remote_report_to_printer
#: sql_constraint:res.remote.printer:0
msgid "A Remote cannot have the same printer for the same usage"
msgstr ""
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer_create_uid
msgid "Created by"
msgstr ""
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer_create_date
msgid "Created on"
msgstr ""
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer_display_name
msgid "Display Name"
msgstr ""
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer_id
msgid "ID"
msgstr ""
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer_is_default
msgid "Is Default"
msgstr ""
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer___last_update
msgid "Last Modified on"
msgstr ""
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer_write_uid
msgid "Last Updated by"
msgstr ""
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer_write_date
msgid "Last Updated on"
msgstr ""
#. module: remote_report_to_printer
#: code:addons/remote_report_to_printer/models/res_remote_printer.py:48
#, python-format
msgid "Only one default printer is allowed"
msgstr ""
#. module: remote_report_to_printer
#: model:ir.model,name:remote_report_to_printer.model_printing_action
msgid "Print Job Action"
msgstr ""
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer_printer_id
msgid "Printer"
msgstr ""
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer_printer_tray_id
msgid "Printer Tray"
msgstr ""
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer_printer_usage
msgid "Printer Usage"
msgstr ""
#. module: remote_report_to_printer
#: model:ir.ui.view,arch_db:remote_report_to_printer.res_remote_form
msgid "Printers"
msgstr ""
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_printer_remote_id
msgid "Remote"
msgstr ""
#. module: remote_report_to_printer
#: model:ir.model.fields,field_description:remote_report_to_printer.field_res_remote_remote_printer_ids
#: model:ir.ui.view,arch_db:remote_report_to_printer.res_remote_printer_form
msgid "Remote Printer"
msgstr ""
#. module: remote_report_to_printer
#: model:ir.ui.view,arch_db:remote_report_to_printer.res_remote_printer_tree
msgid "Remote Printers"
msgstr ""
#. module: remote_report_to_printer
#: model:ir.model,name:remote_report_to_printer.model_res_remote
msgid "Remotes"
msgstr ""
#. module: remote_report_to_printer
#: selection:res.remote.printer,printer_usage:0
msgid "Standard"
msgstr ""
#. module: remote_report_to_printer
#: model:ir.model,name:remote_report_to_printer.model_ir_actions_report
msgid "ir.actions.report"
msgstr ""
#. module: remote_report_to_printer
#: model:ir.model,name:remote_report_to_printer.model_res_remote_printer
msgid "res.remote.printer"
msgstr ""

View File

@@ -0,0 +1,4 @@
from . import ir_actions_report
from . import res_remote
from . import res_remote_printer
from . import printing_action

View File

@@ -0,0 +1,22 @@
# Copyright (c) 2018 Creu Blanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, 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':
res.update(self.remote.get_printer_behaviour())
return res

View File

@@ -0,0 +1,18 @@
# Copyright (c) 2018 Creu Blanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class PrintingAction(models.Model):
_inherit = 'printing.action'
@api.model
def _available_action_types(self):
res = super()._available_action_types()
res.append(('remote_default', "Use remote's default"))
return res
action_type = fields.Selection(
selection=_available_action_types,
)

View File

@@ -0,0 +1,28 @@
# Copyright (c) 2018 Creu Blanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class ResRemote(models.Model):
_inherit = 'res.remote'
remote_printer_ids = fields.One2many(
'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')
printers = self.remote.remote_printer_ids.filtered(
lambda r: r.printer_usage == printer_usage
).sorted(key='is_default', reverse=True)
if printers:
printer = printers[0]
return {
'action': 'server',
'printer': printer.printer_id,
'tray': printer.printer_tray_id.system_name
}
return {'action': 'client'}

View File

@@ -0,0 +1,49 @@
# 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.exceptions import ValidationError
class ResRemotePrinter(models.Model):
_name = 'res.remote.printer'
_description = 'Remote Printer'
remote_id = fields.Many2one(
'res.remote',
ondelete='cascade',
readonly=True,
)
printer_id = fields.Many2one(
'printing.printer',
ondelete='cascade',
)
printer_tray_id = fields.Many2one(
'printing.tray',
ondelete='cascade',
domain="[('printer_id', '=', printer_id)]",
)
is_default = fields.Boolean(default=False)
printer_usage = fields.Selection([
('standard', 'Standard')
], default='standard')
_sql_constraints = [
('unique_printer_remote_usage',
'unique(remote_id,printer_id,printer_usage)',
'A Remote cannot have the same printer for the same usage')
]
@api.onchange('printer_id')
def _onchange_printing_printer_id(self):
""" 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):
if rec.remote_id.remote_printer_ids.filtered(
lambda r: r != rec and r.is_default
and r.printer_usage == rec.printer_usage
):
raise ValidationError(_('Only one default printer is allowed'))

View File

@@ -0,0 +1 @@
* Enric Tobella <etobella@creublanca.es>

View File

@@ -0,0 +1,12 @@
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,
we want to configure the printers by remote, because users may change their
work place.
It adds an optional behaviour on reports to send it directly to a printer.
* `Use remote's configuration` use the remote's behaviour
Also, this option can be selected as a user default option for printer.

View File

@@ -0,0 +1 @@
* In *Settings > Remotes* configure the remotes printers by usage

View File

@@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_remote,access_remote_printer,model_res_remote_printer,base.group_user,1,0,0,0
manage_remote,manage_remote_printer,model_res_remote_printer,base.group_system,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_remote access_remote_printer model_res_remote_printer base.group_user 1 0 0 0
3 manage_remote manage_remote_printer model_res_remote_printer base.group_system 1 1 1 1

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@@ -0,0 +1,2 @@
from . import test_remote_printer
from . import test_printer

View File

@@ -0,0 +1,106 @@
# Copyright (c) 2018 Creu Blanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tests.common import TransactionCase
from mock import patch
class TestRemotePrinter(TransactionCase):
def setUp(self):
super().setUp()
name = 'testing_remote_server'
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',
})
self.server = self.env['printing.server'].create({
'name': 'Server',
'address': 'localhost',
'port': 631,
})
self.printer_1 = self.env['printing.printer'].create({
'name': 'Printer 1',
'system_name': 'P1',
'server_id': self.server.id,
})
self.remote_printer = self.env['res.remote.printer'].create({
'remote_id': self.remote.id,
'printer_id': self.printer_1.id,
'is_default': True,
})
self.Model = self.env['ir.actions.report']
self.report = self.env['ir.actions.report'].search([], limit=1)
def test_behaviour_user_remote_values(self):
report = self.Model.search([], limit=1)
self.env.user.printing_action = 'remote_default'
with patch(
'odoo.addons.base_remote.models.base.Base.remote', new=self.remote
):
behaviour = report.behaviour()
self.assertEqual(behaviour, {
'action': 'client',
'printer': self.printer_1,
'tray': False,
})
def test_behaviour_report_values(self):
report = self.Model.search([], limit=1)
self.env.user.printing_action = 'client'
report.property_printing_action_id = self.browse_ref(
'remote_report_to_printer.printing_action_remote'
)
with patch(
'odoo.addons.base_remote.models.base.Base.remote', new=self.remote
):
behaviour = report.behaviour()
self.assertDictEqual(behaviour, {
'action': 'server',
'printer': self.printer_1,
'tray': False,
})
def test_behaviour_user_action(self):
report = self.Model.search([], limit=1)
self.env.user.printing_action = 'remote_default'
report.property_printing_action_id = self.browse_ref(
'remote_report_to_printer.printing_action_3'
)
with patch(
'odoo.addons.base_remote.models.base.Base.remote', new=self.remote
):
behaviour = report.behaviour()
self.assertEqual(behaviour, {
'action': 'server',
'printer': self.printer_1,
'tray': False,
})
def test_behaviour_default_action(self):
report = self.Model.search([], limit=1)
self.env.user.printing_action = 'client'
with patch(
'odoo.addons.base_remote.models.base.Base.remote', new=self.remote
):
behaviour = report.behaviour()
self.assertEqual(behaviour, {
'action': 'client',
'printer': self.env['printing.printer'],
'tray': False,
})
def test_behaviour_no_printers(self):
self.remote_printer.unlink()
report = self.Model.search([], limit=1)
self.env.user.printing_action = 'remote_default'
report.property_printing_action_id = self.browse_ref(
'remote_report_to_printer.printing_action_3'
)
with patch(
'odoo.addons.base_remote.models.base.Base.remote',
new=self.remote
):
behaviour = report.behaviour()
self.assertEqual(behaviour['action'], 'client')

View File

@@ -0,0 +1,115 @@
# Copyright (c) 2018 Creu Blanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tests.common import TransactionCase
from odoo.exceptions import ValidationError
from odoo.exceptions import AccessError
class TestRemotePrinter(TransactionCase):
def setUp(self):
super().setUp()
self.system_user_group = self.env.ref('base.group_system')
self.user_group = self.env.ref('base.group_user')
self.printer_manager = self._create_user('printer_manager',
self.system_user_group.id)
self.printer_user = self._create_user('printer_user',
self.user_group.id)
name = 'testing_remote_server'
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',
})
self.server = self.env['printing.server'].create({
'name': 'Server',
'address': 'localhost',
'port': 631,
})
self.printer_1 = self.env['printing.printer'].create({
'name': 'Printer 1',
'system_name': 'P1',
'server_id': self.server.id,
})
self.printer_2 = self.env['printing.printer'].create({
'name': 'Printer 2',
'system_name': 'P2',
'server_id': self.server.id,
})
self.tray_1 = self.env['printing.tray'].create({
'name': 'Tray',
'system_name': 'P2',
'printer_id': self.printer_1.id,
})
def _create_user(self, name, group_ids):
return self.env['res.users'].with_context(
{'no_reset_password': True}).create(
{'name': name,
'password': 'demo',
'login': name,
'email': '@'.join([name, '@test.com']),
'groups_id': [(6, 0, [group_ids])]
})
def test_constrain(self):
self.env['res.remote.printer'].sudo(self.printer_manager).create({
'remote_id': self.remote.id,
'printer_id': self.printer_1.id,
'is_default': True,
})
with self.assertRaises(ValidationError):
self.env['res.remote.printer'].create({
'remote_id': self.remote.id,
'printer_id': self.printer_2.id,
'is_default': True,
})
def test_onchange_printer(self):
remote_printer = self.env['res.remote.printer'].sudo(
self.printer_manager).create({
'remote_id': self.remote.id,
'printer_id': self.printer_1.id,
'printer_tray_id': self.tray_1.id,
})
self.assertTrue(remote_printer.printer_tray_id)
remote_printer.printer_id = self.printer_2
remote_printer._onchange_printing_printer_id()
self.assertFalse(remote_printer.printer_tray_id)
def test_permissions_delete_manager(self):
printer = self.env['res.remote.printer'].sudo(
self.printer_manager).create({
'remote_id': self.remote.id,
'printer_id': self.printer_1.id,
'is_default': True,
}
)
printer.sudo(self.printer_manager).unlink()
printer = self.env['res.remote.printer'].search([
('remote_id', '=', self.remote.id),
('printer_id', '=', self.printer_1.id)], limit=1)
self.assertEquals(printer, self.env['res.remote.printer'])
def test_permissions_delete_user(self):
printer = self.env['res.remote.printer'].sudo(
self.printer_manager).create({
'remote_id': self.remote.id,
'printer_id': self.printer_1.id,
'is_default': True,
}
)
with self.assertRaises(AccessError):
printer.sudo(self.printer_user).unlink()
def test_permissions_create_user(self):
with self.assertRaises(AccessError):
self.env['res.remote.printer'].sudo(
self.printer_user).create({
'remote_id': self.remote.id,
'printer_id': self.printer_1.id,
'is_default': True,
}
)

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="res_remote_printer_form" model="ir.ui.view">
<field name="name">res.remote.printer.form</field>
<field name="model">res.remote.printer</field>
<field name="arch" type="xml">
<form string="Remote Printer">
<sheet>
<group>
<field name="printer_id"/>
<field name="printer_tray_id"/>
<field name="printer_usage"/>
<field name="is_default"/>
<field name="remote_id"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="res_remote_printer_tree" model="ir.ui.view">
<field name="name">res.remote.printer.tree</field>
<field name="model">res.remote.printer</field>
<field name="arch" type="xml">
<tree string="Remote Printers" editable="bottom">
<field name="printer_id"/>
<field name="printer_tray_id"/>
<field name="is_default"/>
<field name="printer_usage"/>
<field name="remote_id" invisible="1"/>
</tree>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="res_remote_form" model="ir.ui.view">
<field name="name">res.remote.form</field>
<field name="model">res.remote</field>
<field name="inherit_id" ref="base_remote.res_remote_form"/>
<field name="arch" type="xml">
<notebook position="inside">
<page name="printers" string="Printers">
<field name="remote_printer_ids"/>
</page>
</notebook>
</field>
</record>
</odoo>