[IMP] update dotfiles [ci skip]

This commit is contained in:
oca-git-bot
2022-03-31 17:22:14 +02:00
parent 383c767697
commit 29c21d455c
24 changed files with 127 additions and 109 deletions

View File

@@ -1,14 +1,17 @@
# Do NOT update manually; changes here will be overwritten by Copier # Do NOT update manually; changes here will be overwritten by Copier
_commit: v1.3.6 _commit: v1.5.2
_src_path: gh:oca/oca-addons-repo-template _src_path: gh:oca/oca-addons-repo-template
ci: Travis ci: Travis
dependency_installation_mode: PIP dependency_installation_mode: PIP
generate_requirements_txt: true generate_requirements_txt: true
include_wkhtmltopdf: false include_wkhtmltopdf: false
odoo_version: 14.0 odoo_version: 14.0
org_name: Odoo Community Association (OCA)
org_slug: OCA
rebel_module_groups: [] rebel_module_groups: []
repo_description: 'TODO: add repo description.' repo_description: 'TODO: add repo description.'
repo_name: report-print-send repo_name: report-print-send
repo_slug: report-print-send repo_slug: report-print-send
repo_website: https://github.com/OCA/report-print-send
travis_apt_packages: [] travis_apt_packages: []
travis_apt_sources: [] travis_apt_sources: []

View File

@@ -4,7 +4,7 @@ env:
# See https://github.com/OCA/odoo-community.org/issues/37#issuecomment-470686449 # See https://github.com/OCA/odoo-community.org/issues/37#issuecomment-470686449
parserOptions: parserOptions:
ecmaVersion: 2017 ecmaVersion: 2019
overrides: overrides:
- files: - files:

View File

@@ -2,7 +2,12 @@ name: pre-commit
on: on:
pull_request: pull_request:
branches:
- "14.0*"
push: push:
branches:
- "14.0"
- "14.0-ocabot-*"
jobs: jobs:
pre-commit: pre-commit:
@@ -10,11 +15,21 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-python@v2 - uses: actions/setup-python@v2
- name: Get python version
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v1
with: with:
# The pylint-odoo version we use here does not support python 3.10 path: ~/.cache/pre-commit
# https://github.com/OCA/oca-addons-repo-template/issues/80 key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
# We also need to pin to an older version of python for older odoo versions - name: Install pre-commit
# where we are not using black > 21. Older black versions won't work with run: pip install pre-commit
# Python 3.9.8+, and we can't bump black without reformatting. - name: Run pre-commit
python-version: "3.9.7" run: pre-commit run --all-files --show-diff-on-failure --color=always
- uses: pre-commit/action@v2.0.0 - name: Check that all files generated by pre-commit are in git
run: |
newfiles="$(git ls-files --others --exclude-from=.gitignore)"
if [ "$newfiles" != "" ] ; then
echo "Please check-in the following files:"
echo "$newfiles"
exit 1
fi

View File

@@ -46,7 +46,7 @@ repos:
- --remove-duplicate-keys - --remove-duplicate-keys
- --remove-unused-variables - --remove-unused-variables
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 20.8b1 rev: 22.3.0
hooks: hooks:
- id: black - id: black
- repo: https://github.com/pre-commit/mirrors-prettier - repo: https://github.com/pre-commit/mirrors-prettier
@@ -120,7 +120,7 @@ repos:
name: flake8 name: flake8
additional_dependencies: ["flake8-bugbear==20.1.4"] additional_dependencies: ["flake8-bugbear==20.1.4"]
- repo: https://github.com/PyCQA/pylint - repo: https://github.com/PyCQA/pylint
rev: pylint-2.5.3 rev: v2.11.1
hooks: hooks:
- id: pylint - id: pylint
name: pylint with optional checks name: pylint with optional checks
@@ -129,7 +129,7 @@ repos:
- --exit-zero - --exit-zero
verbose: true verbose: true
additional_dependencies: &pylint_deps additional_dependencies: &pylint_deps
- pylint-odoo==3.5.0 - pylint-odoo==5.0.5
- id: pylint - id: pylint
name: pylint with mandatory checks name: pylint with mandatory checks
args: args:

View File

@@ -1,4 +1,5 @@
[![Runbot Status](https://runbot.odoo-community.org/runbot/badge/flat/144/14.0.svg)](https://runbot.odoo-community.org/runbot/repo/github-com-oca-report-print-send-144)
[![Runboat](https://img.shields.io/badge/runboat-Try%20me-875A7B.png)](https://runboat.odoo-community.org/builds?repo=OCA/report-print-send&target_branch=14.0)
[![Build Status](https://travis-ci.com/OCA/report-print-send.svg?branch=14.0)](https://travis-ci.com/OCA/report-print-send) [![Build Status](https://travis-ci.com/OCA/report-print-send.svg?branch=14.0)](https://travis-ci.com/OCA/report-print-send)
[![codecov](https://codecov.io/gh/OCA/report-print-send/branch/14.0/graph/badge.svg)](https://codecov.io/gh/OCA/report-print-send) [![codecov](https://codecov.io/gh/OCA/report-print-send/branch/14.0/graph/badge.svg)](https://codecov.io/gh/OCA/report-print-send)
[![Translation Status](https://translation.odoo-community.org/widgets/report-print-send-14-0/-/svg-badge.svg)](https://translation.odoo-community.org/engage/report-print-send-14-0/?utm_source=widget) [![Translation Status](https://translation.odoo-community.org/widgets/report-print-send-14-0/-/svg-badge.svg)](https://translation.odoo-community.org/engage/report-print-send-14-0/?utm_source=widget)
@@ -33,12 +34,11 @@ addon | version | maintainers | summary
This repository is licensed under [AGPL-3.0](LICENSE). This repository is licensed under [AGPL-3.0](LICENSE).
However, each module can have a totally different license, as long as they adhere to OCA However, each module can have a totally different license, as long as they adhere to Odoo Community Association (OCA)
policy. Consult each module's `__manifest__.py` file, which contains a `license` key policy. Consult each module's `__manifest__.py` file, which contains a `license` key
that explains its license. that explains its license.
---- ----
OCA, or the [Odoo Community Association](http://odoo-community.org/), is a nonprofit OCA, or the [Odoo Community Association](http://odoo-community.org/), is a nonprofit
organization whose mission is to support the collaborative development of Odoo features organization whose mission is to support the collaborative development of Odoo features
and promote its widespread use. and promote its widespread use.

View File

@@ -35,7 +35,7 @@ class IrActionsReport(models.Model):
@api.onchange("printing_printer_id") @api.onchange("printing_printer_id")
def onchange_printing_printer_id(self): def onchange_printing_printer_id(self):
""" 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.model @api.model
@@ -99,7 +99,7 @@ class IrActionsReport(models.Model):
return result return result
def print_document(self, record_ids, data=None): def print_document(self, record_ids, data=None):
""" Print a document, do not return the document file """ """Print a document, do not return the document file"""
document, doc_format = self.with_context( document, doc_format = self.with_context(
must_skip_send_to_printer=True must_skip_send_to_printer=True
)._render_qweb_pdf(record_ids, data=data) )._render_qweb_pdf(record_ids, data=data)

View File

@@ -173,7 +173,7 @@ class PrintingPrinter(models.Model):
return options return options
def print_file(self, file_name, report=None, **print_opts): def print_file(self, file_name, report=None, **print_opts):
""" Print a file """ """Print a file"""
self.ensure_one() self.ensure_one()
title = print_opts.pop("title", file_name) title = print_opts.pop("title", file_name)
connection = self.server_id._open_connection(raise_on_error=True) connection = self.server_id._open_connection(raise_on_error=True)

View File

@@ -35,7 +35,7 @@ class PrintingReportXmlAction(models.Model):
@api.onchange("printer_id") @api.onchange("printer_id")
def onchange_printer_id(self): def onchange_printer_id(self):
""" 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
def behaviour(self): def behaviour(self):

View File

@@ -38,5 +38,5 @@ class ResUsers(models.Model):
@api.onchange("printing_printer_id") @api.onchange("printing_printer_id")
def onchange_printing_printer_id(self): def onchange_printing_printer_id(self):
""" 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

View File

@@ -54,14 +54,14 @@ class TestIrActionsReportXml(TransactionCase):
return self.env["printing.tray"].create(values) return self.env["printing.tray"].create(values)
def test_print_action_for_report_name_gets_report(self): def test_print_action_for_report_name_gets_report(self):
""" It should get report by name """ """It should get report by name"""
with mock.patch("%s._get_report_from_name" % model) as mk: with mock.patch("%s._get_report_from_name" % model) as mk:
expect = "test" expect = "test"
self.Model.print_action_for_report_name(expect) self.Model.print_action_for_report_name(expect)
mk.assert_called_once_with(expect) mk.assert_called_once_with(expect)
def test_print_action_for_report_name_returns_if_no_report(self): def test_print_action_for_report_name_returns_if_no_report(self):
""" It should return empty dict when no matching report """ """It should return empty dict when no matching report"""
with mock.patch("%s._get_report_from_name" % model) as mk: with mock.patch("%s._get_report_from_name" % model) as mk:
expect = "test" expect = "test"
mk.return_value = False mk.return_value = False
@@ -69,7 +69,7 @@ class TestIrActionsReportXml(TransactionCase):
self.assertDictEqual({}, res) self.assertDictEqual({}, res)
def test_print_action_for_report_name_returns_if_report(self): def test_print_action_for_report_name_returns_if_report(self):
""" It should return correct serializable result for behaviour """ """It should return correct serializable result for behaviour"""
with mock.patch("%s._get_report_from_name" % model) as mk: with mock.patch("%s._get_report_from_name" % model) as mk:
res = self.Model.print_action_for_report_name("test") res = self.Model.print_action_for_report_name("test")
behaviour = mk().behaviour() behaviour = mk().behaviour()
@@ -80,7 +80,7 @@ class TestIrActionsReportXml(TransactionCase):
self.assertDictEqual(expect, res, "Expect {}, Got {}".format(expect, res)) self.assertDictEqual(expect, res, "Expect {}, Got {}".format(expect, res))
def test_behaviour_default_values(self): def test_behaviour_default_values(self):
""" It should return the default action and printer """ """It should return the default action and printer"""
report = self.Model.search([], limit=1) report = self.Model.search([], limit=1)
self.env.user.printing_action = False self.env.user.printing_action = False
self.env.user.printing_printer_id = False self.env.user.printing_printer_id = False
@@ -96,7 +96,7 @@ class TestIrActionsReportXml(TransactionCase):
) )
def test_behaviour_user_values(self): def test_behaviour_user_values(self):
""" It should return the action and printer from user """ """It should return the action and printer from user"""
report = self.Model.search([], limit=1) report = self.Model.search([], limit=1)
self.env.user.printing_action = "client" self.env.user.printing_action = "client"
self.env.user.printing_printer_id = self.new_printer() self.env.user.printing_printer_id = self.new_printer()
@@ -110,7 +110,7 @@ class TestIrActionsReportXml(TransactionCase):
) )
def test_behaviour_report_values(self): def test_behaviour_report_values(self):
""" It should return the action and printer from report """ """It should return the action and printer from report"""
report = self.Model.search([], limit=1) report = self.Model.search([], limit=1)
self.env.user.printing_action = "client" self.env.user.printing_action = "client"
report.property_printing_action_id = self.new_action() report.property_printing_action_id = self.new_action()
@@ -125,7 +125,7 @@ class TestIrActionsReportXml(TransactionCase):
) )
def test_behaviour_user_action(self): def test_behaviour_user_action(self):
""" It should return the action and printer from user action""" """It should return the action and printer from user action"""
report = self.Model.search([], limit=1) report = self.Model.search([], limit=1)
self.env.user.printing_action = "client" self.env.user.printing_action = "client"
report.property_printing_action_id.action_type = "user_default" report.property_printing_action_id.action_type = "user_default"
@@ -180,7 +180,7 @@ class TestIrActionsReportXml(TransactionCase):
) )
def test_behaviour_printing_action_with_printer(self): def test_behaviour_printing_action_with_printer(self):
""" It should return the action and printer from printing action """ """It should return the action and printer from printing action"""
report = self.Model.search([], limit=1) report = self.Model.search([], limit=1)
self.env.user.printing_action = "client" self.env.user.printing_action = "client"
printing_action = self.new_printing_action() printing_action = self.new_printing_action()

View File

@@ -44,7 +44,7 @@ class TestPrintingJob(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_cancel_job_error(self, cups): def test_cancel_job_error(self, cups):
""" It should catch any exception from CUPS and update status """ """It should catch any exception from CUPS and update status"""
cups.Connection.side_effect = Exception cups.Connection.side_effect = Exception
printer = self.new_printer() printer = self.new_printer()
job = self.new_job(printer, {"job_id_cups": 2}) job = self.new_job(printer, {"job_id_cups": 2})
@@ -54,7 +54,7 @@ class TestPrintingJob(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_cancel_job(self, cups): def test_cancel_job(self, cups):
""" It should catch any exception from CUPS and update status """ """It should catch any exception from CUPS and update status"""
printer = self.new_printer() printer = self.new_printer()
job = self.new_job(printer) job = self.new_job(printer)
job.cancel() job.cancel()

View File

@@ -64,7 +64,7 @@ class TestPrintingPrinter(TransactionCase):
self.assertEqual(self.Model._set_option_format(None, "pdf"), {}) self.assertEqual(self.Model._set_option_format(None, "pdf"), {})
def test_print_options(self): def test_print_options(self):
""" It should generate the right options dictionnary """ """It should generate the right options dictionnary"""
# TODO: None here used as report - tests here should be merged # TODO: None here used as report - tests here should be merged
# with tests in test_printing_printer_tray from when modules merged # with tests in test_printing_printer_tray from when modules merged
report = self.env["ir.actions.report"].search([], limit=1) report = self.env["ir.actions.report"].search([], limit=1)
@@ -81,7 +81,7 @@ class TestPrintingPrinter(TransactionCase):
@mock.patch("%s.cups" % server_model) @mock.patch("%s.cups" % server_model)
def test_print_report(self, cups): def test_print_report(self, cups):
""" It should print a report through CUPS """ """It should print a report through CUPS"""
fd, file_name = tempfile.mkstemp() fd, file_name = tempfile.mkstemp()
with mock.patch("%s.mkstemp" % model) as mkstemp: with mock.patch("%s.mkstemp" % model) as mkstemp:
mkstemp.return_value = fd, file_name mkstemp.return_value = fd, file_name
@@ -93,7 +93,7 @@ class TestPrintingPrinter(TransactionCase):
@mock.patch("%s.cups" % server_model) @mock.patch("%s.cups" % server_model)
def test_print_report_error(self, cups): def test_print_report_error(self, cups):
""" It should print a report through CUPS """ """It should print a report through CUPS"""
cups.Connection.side_effect = Exception cups.Connection.side_effect = Exception
fd, file_name = tempfile.mkstemp() fd, file_name = tempfile.mkstemp()
with mock.patch("%s.mkstemp" % model) as mkstemp: with mock.patch("%s.mkstemp" % model) as mkstemp:
@@ -106,7 +106,7 @@ class TestPrintingPrinter(TransactionCase):
@mock.patch("%s.cups" % server_model) @mock.patch("%s.cups" % server_model)
def test_print_file(self, cups): def test_print_file(self, cups):
""" It should print a file through CUPS """ """It should print a file through CUPS"""
file_name = "file_name" file_name = "file_name"
printer = self.new_record() printer = self.new_record()
printer.print_file(file_name, "pdf") printer.print_file(file_name, "pdf")
@@ -116,7 +116,7 @@ class TestPrintingPrinter(TransactionCase):
@mock.patch("%s.cups" % server_model) @mock.patch("%s.cups" % server_model)
def test_print_file_error(self, cups): def test_print_file_error(self, cups):
""" It should print a file through CUPS """ """It should print a file through CUPS"""
cups.Connection.side_effect = Exception cups.Connection.side_effect = Exception
file_name = "file_name" file_name = "file_name"
printer = self.new_record() printer = self.new_record()
@@ -124,7 +124,7 @@ class TestPrintingPrinter(TransactionCase):
printer.print_file(file_name) printer.print_file(file_name)
def test_set_default(self): def test_set_default(self):
""" It should set a single record as default """ """It should set a single record as default"""
printer = self.new_record() printer = self.new_record()
self.assertTrue(printer.default) self.assertTrue(printer.default)
other_printer = self.new_record() other_printer = self.new_record()
@@ -136,7 +136,7 @@ class TestPrintingPrinter(TransactionCase):
self.assertEqual(other_printer, self.Model.get_default()) self.assertEqual(other_printer, self.Model.get_default())
def test_unset_default(self): def test_unset_default(self):
""" It should unset the default state of the printer """ """It should unset the default state of the printer"""
printer = self.new_record() printer = self.new_record()
self.assertTrue(printer.default) self.assertTrue(printer.default)
printer.unset_default() printer.unset_default()
@@ -144,7 +144,7 @@ class TestPrintingPrinter(TransactionCase):
@mock.patch("%s.cups" % server_model) @mock.patch("%s.cups" % server_model)
def test_cancel_all_jobs(self, cups): def test_cancel_all_jobs(self, cups):
""" It should cancel all jobs """ """It should cancel all jobs"""
printer = self.new_record() printer = self.new_record()
printer.action_cancel_all_jobs() printer.action_cancel_all_jobs()
cups.Connection().cancelAllJobs.assert_called_once_with( cups.Connection().cancelAllJobs.assert_called_once_with(
@@ -153,7 +153,7 @@ class TestPrintingPrinter(TransactionCase):
@mock.patch("%s.cups" % server_model) @mock.patch("%s.cups" % server_model)
def test_cancel_and_purge_all_jobs(self, cups): def test_cancel_and_purge_all_jobs(self, cups):
""" It should cancel all jobs """ """It should cancel all jobs"""
printer = self.new_record() printer = self.new_record()
printer.cancel_all_jobs(purge_jobs=True) printer.cancel_all_jobs(purge_jobs=True)
cups.Connection().cancelAllJobs.assert_called_once_with( cups.Connection().cancelAllJobs.assert_called_once_with(
@@ -162,21 +162,21 @@ class TestPrintingPrinter(TransactionCase):
@mock.patch("%s.cups" % server_model) @mock.patch("%s.cups" % server_model)
def test_enable_printer(self, cups): def test_enable_printer(self, cups):
""" It should enable the printer """ """It should enable the printer"""
printer = self.new_record() printer = self.new_record()
printer.enable() printer.enable()
cups.Connection().enablePrinter.assert_called_once_with(printer.system_name) cups.Connection().enablePrinter.assert_called_once_with(printer.system_name)
@mock.patch("%s.cups" % server_model) @mock.patch("%s.cups" % server_model)
def test_disable_printer(self, cups): def test_disable_printer(self, cups):
""" It should disable the printer """ """It should disable the printer"""
printer = self.new_record() printer = self.new_record()
printer.disable() printer.disable()
cups.Connection().disablePrinter.assert_called_once_with(printer.system_name) cups.Connection().disablePrinter.assert_called_once_with(printer.system_name)
@mock.patch("%s.cups" % server_model) @mock.patch("%s.cups" % server_model)
def test_print_test_page(self, cups): def test_print_test_page(self, cups):
""" It should print a test page """ """It should print a test page"""
printer = self.new_record() printer = self.new_record()
printer.print_test_page() printer.print_test_page()
cups.Connection().printTestPage.assert_called_once_with(printer.system_name) cups.Connection().printTestPage.assert_called_once_with(printer.system_name)

View File

@@ -38,7 +38,7 @@ class TestPrintingPrinterWizard(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_action_ok_inits_connection(self, cups): def test_action_ok_inits_connection(self, cups):
""" It should initialize CUPS connection """ """It should initialize CUPS connection"""
self.Model.action_ok() self.Model.action_ok()
cups.Connection.assert_called_once_with( cups.Connection.assert_called_once_with(
host=self.server.address, port=self.server.port host=self.server.address, port=self.server.port
@@ -46,7 +46,7 @@ class TestPrintingPrinterWizard(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_action_ok_gets_printers(self, cups): def test_action_ok_gets_printers(self, cups):
""" It should get printers from CUPS """ """It should get printers from CUPS"""
cups.Connection().getPrinters.return_value = {"sys_name": self.printer_vals} cups.Connection().getPrinters.return_value = {"sys_name": self.printer_vals}
cups.Connection().getPPD3.return_value = (200, 0, "") cups.Connection().getPPD3.return_value = (200, 0, "")
self.Model.action_ok() self.Model.action_ok()
@@ -54,14 +54,14 @@ class TestPrintingPrinterWizard(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_action_ok_raises_warning_on_error(self, cups): def test_action_ok_raises_warning_on_error(self, cups):
""" It should raise Warning on any error """ """It should raise Warning on any error"""
cups.Connection.side_effect = StopTest cups.Connection.side_effect = StopTest
with self.assertRaises(UserError): with self.assertRaises(UserError):
self.Model.action_ok() self.Model.action_ok()
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_action_ok_creates_new_printer(self, cups): def test_action_ok_creates_new_printer(self, cups):
""" It should create new printer w/ proper vals """ """It should create new printer w/ proper vals"""
cups.Connection().getPrinters.return_value = {"sys_name": self.printer_vals} cups.Connection().getPrinters.return_value = {"sys_name": self.printer_vals}
cups.Connection().getPPD3.return_value = (200, 0, "") cups.Connection().getPPD3.return_value = (200, 0, "")
self.Model.action_ok() self.Model.action_ok()
@@ -77,7 +77,7 @@ class TestPrintingPrinterWizard(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_action_ok_skips_existing_printer(self, cups): def test_action_ok_skips_existing_printer(self, cups):
""" It should not recreate existing printers """ """It should not recreate existing printers"""
cups.Connection().getPrinters.return_value = {"sys_name": self.printer_vals} cups.Connection().getPrinters.return_value = {"sys_name": self.printer_vals}
cups.Connection().getPPD3.return_value = (200, 0, "") cups.Connection().getPPD3.return_value = (200, 0, "")
self.env["printing.printer"].create(self._record_vals()) self.env["printing.printer"].create(self._record_vals())

View File

@@ -45,7 +45,7 @@ class TestPrintingServer(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_update_printers_error(self, cups): def test_update_printers_error(self, cups):
""" It should catch any exception from CUPS and update status """ """It should catch any exception from CUPS and update status"""
cups.Connection.side_effect = Exception cups.Connection.side_effect = Exception
rec_id = self.new_printer() rec_id = self.new_printer()
self.Model.update_printers() self.Model.update_printers()
@@ -53,7 +53,7 @@ class TestPrintingServer(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_update_printers_inits_cups(self, cups): def test_update_printers_inits_cups(self, cups):
""" It should init CUPS connection """ """It should init CUPS connection"""
self.new_printer() self.new_printer()
self.Model.update_printers() self.Model.update_printers()
cups.Connection.assert_called_once_with( cups.Connection.assert_called_once_with(
@@ -62,21 +62,21 @@ class TestPrintingServer(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_update_printers_gets_all_printers(self, cups): def test_update_printers_gets_all_printers(self, cups):
""" It should get all printers from CUPS server """ """It should get all printers from CUPS server"""
self.new_printer() self.new_printer()
self.Model.update_printers() self.Model.update_printers()
cups.Connection().getPrinters.assert_called_once_with() cups.Connection().getPrinters.assert_called_once_with()
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_update_printers_search(self, cups): def test_update_printers_search(self, cups):
""" It should search all when no domain """ """It should search all when no domain"""
with mock.patch("%s.search" % model_base) as search: with mock.patch("%s.search" % model_base) as search:
self.Model.update_printers() self.Model.update_printers()
search.assert_called_once_with([]) search.assert_called_once_with([])
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_update_printers_search_domain(self, cups): def test_update_printers_search_domain(self, cups):
""" It should use specific domain for search """ """It should use specific domain for search"""
with mock.patch("%s.search" % model_base) as search: with mock.patch("%s.search" % model_base) as search:
expect = [("id", ">", 0)] expect = [("id", ">", 0)]
self.Model.update_printers(expect) self.Model.update_printers(expect)
@@ -84,7 +84,7 @@ class TestPrintingServer(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_update_printers_update_unavailable(self, cups): def test_update_printers_update_unavailable(self, cups):
""" It should update status when printer is unavailable """ """It should update status when printer is unavailable"""
rec_id = self.new_printer() rec_id = self.new_printer()
cups.Connection().getPrinters().get.return_value = False cups.Connection().getPrinters().get.return_value = False
self.Model.action_update_printers() self.Model.action_update_printers()
@@ -92,7 +92,7 @@ class TestPrintingServer(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_update_archived_printers(self, cups): def test_update_archived_printers(self, cups):
""" It should update status even if printer is archived """ """It should update status even if printer is archived"""
rec_id = self.new_printer() rec_id = self.new_printer()
rec_id.toggle_active() rec_id.toggle_active()
self.server.refresh() self.server.refresh()
@@ -105,7 +105,7 @@ class TestPrintingServer(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_update_jobs_cron(self, cups): def test_update_jobs_cron(self, cups):
""" It should get all jobs from CUPS server """ """It should get all jobs from CUPS server"""
self.new_printer() self.new_printer()
self.Model.action_update_jobs() self.Model.action_update_jobs()
cups.Connection().getPrinters.assert_called_once_with() cups.Connection().getPrinters.assert_called_once_with()
@@ -127,7 +127,7 @@ class TestPrintingServer(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_update_jobs_button(self, cups): def test_update_jobs_button(self, cups):
""" It should get all jobs from CUPS server """ """It should get all jobs from CUPS server"""
self.new_printer() self.new_printer()
self.server.action_update_jobs() self.server.action_update_jobs()
cups.Connection().getPrinters.assert_called_once_with() cups.Connection().getPrinters.assert_called_once_with()
@@ -149,7 +149,7 @@ class TestPrintingServer(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_update_jobs_error(self, cups): def test_update_jobs_error(self, cups):
""" It should catch any exception from CUPS and update status """ """It should catch any exception from CUPS and update status"""
cups.Connection.side_effect = Exception cups.Connection.side_effect = Exception
self.new_printer() self.new_printer()
self.server.update_jobs() self.server.update_jobs()

View File

@@ -34,7 +34,7 @@ class TestPrintingTray(TransactionCase):
return self.env["printing.tray"].create(self.tray_vals) return self.env["printing.tray"].create(self.tray_vals)
def test_report_behaviour(self): def test_report_behaviour(self):
""" It should add the selected tray in the report data """ """It should add the selected tray in the report data"""
ir_report = self.env["ir.actions.report"].search([], limit=1) ir_report = self.env["ir.actions.report"].search([], limit=1)
report = self.env["printing.report.xml.action"].create( report = self.env["printing.report.xml.action"].create(
{"user_id": self.env.user.id, "report_id": ir_report.id, "action": "server"} {"user_id": self.env.user.id, "report_id": ir_report.id, "action": "server"}

View File

@@ -66,18 +66,18 @@ class TestReport(common.HttpCase):
) )
def test_can_print_report_context_skip(self): def test_can_print_report_context_skip(self):
""" It should return False based on context """ """It should return False based on context"""
rec_id = self.new_record().with_context(must_skip_send_to_printer=True) rec_id = self.new_record().with_context(must_skip_send_to_printer=True)
res = rec_id._can_print_report({"action": "server"}, True, True) res = rec_id._can_print_report({"action": "server"}, True, True)
self.assertFalse(res) self.assertFalse(res)
def test_can_print_report_true(self): def test_can_print_report_true(self):
""" It should return True when server print allowed """ """It should return True when server print allowed"""
res = self.new_record()._can_print_report({"action": "server"}, True, True) res = self.new_record()._can_print_report({"action": "server"}, True, True)
self.assertTrue(res) self.assertTrue(res)
def test_can_print_report_false(self): def test_can_print_report_false(self):
""" It should return False when server print not allowed """ """It should return False when server print not allowed"""
res = self.new_record()._can_print_report({"action": "server"}, True, False) res = self.new_record()._can_print_report({"action": "server"}, True, False)
self.assertFalse(res) self.assertFalse(res)
@@ -110,7 +110,7 @@ class TestReport(common.HttpCase):
) )
def test_print_document_not_printable(self): def test_print_document_not_printable(self):
""" It should print the report, regardless of the defined behaviour """ """It should print the report, regardless of the defined behaviour"""
self.report.printing_printer_id = self.new_printer() self.report.printing_printer_id = self.new_printer()
with mock.patch( with mock.patch(
"odoo.addons.base_report_to_printer.models." "odoo.addons.base_report_to_printer.models."
@@ -121,7 +121,7 @@ class TestReport(common.HttpCase):
print_document.assert_called_once() print_document.assert_called_once()
def test_print_document_printable(self): def test_print_document_printable(self):
""" It should print the report, regardless of the defined behaviour """ """It should print the report, regardless of the defined behaviour"""
self.report.property_printing_action_id.action_type = "server" self.report.property_printing_action_id.action_type = "server"
self.report.printing_printer_id = self.new_printer() self.report.printing_printer_id = self.new_printer()
with mock.patch( with mock.patch(
@@ -133,6 +133,6 @@ class TestReport(common.HttpCase):
print_document.assert_called_once() print_document.assert_called_once()
def test_print_document_no_printer(self): def test_print_document_no_printer(self):
""" It should raise an error """ """It should raise an error"""
with self.assertRaises(exceptions.UserError): with self.assertRaises(exceptions.UserError):
self.report.print_document(self.partners.ids) self.report.print_document(self.partners.ids)

View File

@@ -13,13 +13,13 @@ class TestResUsers(common.TransactionCase):
return self.env["res.users"].create(self.user_vals) return self.env["res.users"].create(self.user_vals)
def test_available_action_types_excludes_user_default(self): def test_available_action_types_excludes_user_default(self):
""" It should not contain `user_default` in avail actions """ """It should not contain `user_default` in avail actions"""
self.user_vals["printing_action"] = "user_default" self.user_vals["printing_action"] = "user_default"
with self.assertRaises(ValueError): with self.assertRaises(ValueError):
self.new_record() self.new_record()
def test_available_action_types_includes_something_else(self): def test_available_action_types_includes_something_else(self):
""" It should still contain other valid keys """ """It should still contain other valid keys"""
self.user_vals["printing_action"] = "server" self.user_vals["printing_action"] = "server"
self.assertTrue(self.new_record()) self.assertTrue(self.new_record())

View File

@@ -34,11 +34,11 @@ class TestWizardPrintRecordLabel(TransactionCase):
) )
def test_create_action(self): def test_create_action(self):
""" Check the creation of action """ """Check the creation of action"""
self.label.create_action() self.label.create_action()
self.assertTrue(self.label.action_window_id) self.assertTrue(self.label.action_window_id)
def test_unlink_action(self): def test_unlink_action(self):
""" Check the unlink of action """ """Check the unlink of action"""
self.label.unlink_action() self.label.unlink_action()
self.assertFalse(self.label.action_window_id) self.assertFalse(self.label.action_window_id)

View File

@@ -58,20 +58,20 @@ class TestPrintingLabelZpl2(TransactionCase):
return self.ComponentModel.create(values) return self.ComponentModel.create(values)
def test_print_on_bad_model(self): def test_print_on_bad_model(self):
""" Check that printing on the bad model raises an exception """ """Check that printing on the bad model raises an exception"""
label = self.new_label() label = self.new_label()
with self.assertRaises(exceptions.UserError): with self.assertRaises(exceptions.UserError):
label.print_label(self.printer, label) label.print_label(self.printer, label)
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_print_empty_label(self, cups): def test_print_empty_label(self, cups):
""" Check that printing an empty label works """ """Check that printing an empty label works"""
label = self.new_label() label = self.new_label()
label.print_label(self.printer, self.printer) label.print_label(self.printer, self.printer)
cups.Connection().printFile.assert_called_once() cups.Connection().printFile.assert_called_once()
def test_empty_label_contents(self): def test_empty_label_contents(self):
""" Check contents of an empty label """ """Check contents of an empty label"""
label = self.new_label() label = self.new_label()
contents = label._generate_zpl2_data(self.printer).decode("utf-8") contents = label._generate_zpl2_data(self.printer).decode("utf-8")
self.assertEqual( self.assertEqual(
@@ -91,7 +91,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_sublabel_label_contents(self): def test_sublabel_label_contents(self):
""" Check contents of a sublabel label component """ """Check contents of a sublabel label component"""
sublabel = self.new_label({"name": "Sublabel"}) sublabel = self.new_label({"name": "Sublabel"})
data = "Some text" data = "Some text"
self.new_component({"label_id": sublabel.id, "data": '"' + data + '"'}) self.new_component({"label_id": sublabel.id, "data": '"' + data + '"'})
@@ -309,7 +309,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_repeatable_sublabel_contents(self): def test_repeatable_sublabel_contents(self):
""" Check contents of a repeatable sublabel label component """ """Check contents of a repeatable sublabel label component"""
sublabel = self.new_label( sublabel = self.new_label(
{ {
"name": "Sublabel", "name": "Sublabel",
@@ -407,7 +407,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_text_label_contents(self): def test_text_label_contents(self):
""" Check contents of a text label """ """Check contents of a text label"""
label = self.new_label() label = self.new_label()
data = "Some text" data = "Some text"
self.new_component({"label_id": label.id, "data": '"%s"' % data}) self.new_component({"label_id": label.id, "data": '"%s"' % data})
@@ -437,7 +437,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_reversed_text_label_contents(self): def test_reversed_text_label_contents(self):
""" Check contents of a text label """ """Check contents of a text label"""
label = self.new_label() label = self.new_label()
data = "Some text" data = "Some text"
self.new_component( self.new_component(
@@ -471,7 +471,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_block_text_label_contents(self): def test_block_text_label_contents(self):
""" Check contents of a text label """ """Check contents of a text label"""
label = self.new_label() label = self.new_label()
data = "Some text" data = "Some text"
self.new_component( self.new_component(
@@ -505,7 +505,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_rectangle_label_contents(self): def test_rectangle_label_contents(self):
""" Check contents of a rectangle label """ """Check contents of a rectangle label"""
label = self.new_label() label = self.new_label()
self.new_component({"label_id": label.id, "component_type": "rectangle"}) self.new_component({"label_id": label.id, "component_type": "rectangle"})
contents = label._generate_zpl2_data(self.printer).decode("utf-8") contents = label._generate_zpl2_data(self.printer).decode("utf-8")
@@ -532,7 +532,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_diagonal_line_label_contents(self): def test_diagonal_line_label_contents(self):
""" Check contents of a diagonal line label """ """Check contents of a diagonal line label"""
label = self.new_label() label = self.new_label()
self.new_component({"label_id": label.id, "component_type": "diagonal"}) self.new_component({"label_id": label.id, "component_type": "diagonal"})
contents = label._generate_zpl2_data(self.printer).decode("utf-8") contents = label._generate_zpl2_data(self.printer).decode("utf-8")
@@ -559,7 +559,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_circle_label_contents(self): def test_circle_label_contents(self):
""" Check contents of a circle label """ """Check contents of a circle label"""
label = self.new_label() label = self.new_label()
self.new_component({"label_id": label.id, "component_type": "circle"}) self.new_component({"label_id": label.id, "component_type": "circle"})
contents = label._generate_zpl2_data(self.printer).decode("utf-8") contents = label._generate_zpl2_data(self.printer).decode("utf-8")
@@ -586,7 +586,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_code11_barcode_label_contents(self): def test_code11_barcode_label_contents(self):
""" Check contents of a code 11 barcode label """ """Check contents of a code 11 barcode label"""
label = self.new_label() label = self.new_label()
data = "Some text" data = "Some text"
self.new_component( self.new_component(
@@ -624,7 +624,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_2of5_barcode_label_contents(self): def test_2of5_barcode_label_contents(self):
""" Check contents of a interleaved 2 of 5 barcode label """ """Check contents of a interleaved 2 of 5 barcode label"""
label = self.new_label() label = self.new_label()
data = "Some text" data = "Some text"
self.new_component( self.new_component(
@@ -662,7 +662,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_code39_barcode_label_contents(self): def test_code39_barcode_label_contents(self):
""" Check contents of a code 39 barcode label """ """Check contents of a code 39 barcode label"""
label = self.new_label() label = self.new_label()
data = "Some text" data = "Some text"
self.new_component( self.new_component(
@@ -700,7 +700,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_code49_barcode_label_contents(self): def test_code49_barcode_label_contents(self):
""" Check contents of a code 49 barcode label """ """Check contents of a code 49 barcode label"""
label = self.new_label() label = self.new_label()
data = "Some text" data = "Some text"
self.new_component( self.new_component(
@@ -738,7 +738,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_code49_barcode_label_contents_line(self): def test_code49_barcode_label_contents_line(self):
""" Check contents of a code 49 barcode label """ """Check contents of a code 49 barcode label"""
label = self.new_label() label = self.new_label()
data = "Some text" data = "Some text"
self.new_component( self.new_component(
@@ -819,7 +819,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_pdf417_barcode_label_contents(self): def test_pdf417_barcode_label_contents(self):
""" Check contents of a pdf417 barcode label """ """Check contents of a pdf417 barcode label"""
label = self.new_label() label = self.new_label()
data = "Some text" data = "Some text"
self.new_component( self.new_component(
@@ -853,7 +853,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_ean8_barcode_label_contents(self): def test_ean8_barcode_label_contents(self):
""" Check contents of a ean-8 barcode label """ """Check contents of a ean-8 barcode label"""
label = self.new_label() label = self.new_label()
data = "Some text" data = "Some text"
self.new_component( self.new_component(
@@ -887,7 +887,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_upce_barcode_label_contents(self): def test_upce_barcode_label_contents(self):
""" Check contents of a upc-e barcode label """ """Check contents of a upc-e barcode label"""
label = self.new_label() label = self.new_label()
data = "Some text" data = "Some text"
self.new_component( self.new_component(
@@ -921,7 +921,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_code128_barcode_label_contents(self): def test_code128_barcode_label_contents(self):
""" Check contents of a code 128 barcode label """ """Check contents of a code 128 barcode label"""
label = self.new_label() label = self.new_label()
data = "Some text" data = "Some text"
self.new_component( self.new_component(
@@ -959,7 +959,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_ean13_barcode_label_contents(self): def test_ean13_barcode_label_contents(self):
""" Check contents of a ean-13 barcode label """ """Check contents of a ean-13 barcode label"""
label = self.new_label() label = self.new_label()
data = "Some text" data = "Some text"
self.new_component( self.new_component(
@@ -993,7 +993,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_qrcode_barcode_label_contents(self): def test_qrcode_barcode_label_contents(self):
""" Check contents of a qr code barcode label """ """Check contents of a qr code barcode label"""
label = self.new_label() label = self.new_label()
data = "Some text" data = "Some text"
self.new_component( self.new_component(
@@ -1031,7 +1031,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_graphic_label_contents_blank(self): def test_graphic_label_contents_blank(self):
""" Check contents of a image label """ """Check contents of a image label"""
label = self.new_label() label = self.new_label()
data = "R0lGODlhAQABAIAAAP7//wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" data = "R0lGODlhAQABAIAAAP7//wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=="
self.new_component( self.new_component(
@@ -1054,7 +1054,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_graphic_label_contents_blank_rotated(self): def test_graphic_label_contents_blank_rotated(self):
""" Check contents of image rotated label """ """Check contents of image rotated label"""
label = self.new_label() label = self.new_label()
data = "R0lGODlhAQABAIAAAP7//wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" data = "R0lGODlhAQABAIAAAP7//wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=="
self.new_component( self.new_component(
@@ -1082,7 +1082,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_graphic_label_contents_blank_inverted(self): def test_graphic_label_contents_blank_inverted(self):
""" Check contents of a image inverted label """ """Check contents of a image inverted label"""
label = self.new_label() label = self.new_label()
data = "R0lGODlhAQABAIAAAP7//wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" data = "R0lGODlhAQABAIAAAP7//wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=="
self.new_component( self.new_component(
@@ -1106,7 +1106,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_graphic_label_contents_blank_bottom(self): def test_graphic_label_contents_blank_bottom(self):
""" Check contents of a image bottom label """ """Check contents of a image bottom label"""
label = self.new_label() label = self.new_label()
data = "R0lGODlhAQABAIAAAP7//wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" data = "R0lGODlhAQABAIAAAP7//wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=="
self.new_component( self.new_component(
@@ -1130,7 +1130,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_zpl2_raw_contents_blank(self): def test_zpl2_raw_contents_blank(self):
""" Check contents of a image label """ """Check contents of a image label"""
label = self.new_label() label = self.new_label()
data = "^FO50,50^GB100,100,100^FS" data = "^FO50,50^GB100,100,100^FS"
self.new_component( self.new_component(
@@ -1153,7 +1153,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_zpl2_component_not_show(self): def test_zpl2_component_not_show(self):
""" Check to don't show no things """ """Check to don't show no things"""
label = self.new_label() label = self.new_label()
data = "component_not_show" data = "component_not_show"
self.new_component( self.new_component(
@@ -1169,7 +1169,7 @@ class TestPrintingLabelZpl2(TransactionCase):
) )
def test_zpl2_component_quick_move(self): def test_zpl2_component_quick_move(self):
""" Check component quick move """ """Check component quick move"""
label = self.new_label() label = self.new_label()
component = self.new_component( component = self.new_component(
{ {

View File

@@ -35,7 +35,7 @@ class TestWizardPrintRecordLabel(TransactionCase):
) )
def test_get_record(self): def test_get_record(self):
""" Check if return a record """ """Check if return a record"""
self.label.record_id = 10 self.label.record_id = 10
res = self.label._get_record() res = self.label._get_record()
@@ -47,7 +47,7 @@ class TestWizardPrintRecordLabel(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_print_label_test(self, cups): def test_print_label_test(self, cups):
""" Check if print test """ """Check if print test"""
self.label.test_print_mode = True self.label.test_print_mode = True
self.label.printer_id = self.printer self.label.printer_id = self.printer
self.label.record_id = 10 self.label.record_id = 10
@@ -55,12 +55,12 @@ class TestWizardPrintRecordLabel(TransactionCase):
cups.Connection().printFile.assert_called_once() cups.Connection().printFile.assert_called_once()
def test_emulation_without_params(self): def test_emulation_without_params(self):
""" Check if not execute next if not in this mode """ """Check if not execute next if not in this mode"""
self.label.test_labelary_mode = False self.label.test_labelary_mode = False
self.assertIs(self.label.labelary_image, False) self.assertIs(self.label.labelary_image, False)
def test_emulation_with_bad_header(self): def test_emulation_with_bad_header(self):
""" Check if bad header """ """Check if bad header"""
self.label.test_labelary_mode = True self.label.test_labelary_mode = True
self.label.labelary_width = 80 self.label.labelary_width = 80
self.label.labelary_dpmm = "8dpmm" self.label.labelary_dpmm = "8dpmm"
@@ -71,7 +71,7 @@ class TestWizardPrintRecordLabel(TransactionCase):
self.assertFalse(self.label.labelary_image) self.assertFalse(self.label.labelary_image)
def test_emulation_with_bad_data_compute(self): def test_emulation_with_bad_data_compute(self):
""" Check if bad data compute """ """Check if bad data compute"""
self.label.test_labelary_mode = True self.label.test_labelary_mode = True
self.label.labelary_width = 80 self.label.labelary_width = 80
self.label.labelary_height = 30 self.label.labelary_height = 30
@@ -83,7 +83,7 @@ class TestWizardPrintRecordLabel(TransactionCase):
self.assertIs(self.label.labelary_image, False) self.assertIs(self.label.labelary_image, False)
def test_emulation_with_good_data(self): def test_emulation_with_good_data(self):
""" Check if ok """ """Check if ok"""
self.label.test_labelary_mode = True self.label.test_labelary_mode = True
self.label.labelary_width = 80 self.label.labelary_width = 80
self.label.labelary_height = 30 self.label.labelary_height = 30

View File

@@ -32,12 +32,12 @@ class TestWizardImportZpl2(TransactionCase):
) )
def test_open_wizard(self): def test_open_wizard(self):
""" open wizard from label""" """open wizard from label"""
res = self.label.import_zpl2() res = self.label.import_zpl2()
self.assertEqual(res.get("context").get("default_label_id"), self.label.id) self.assertEqual(res.get("context").get("default_label_id"), self.label.id)
def test_wizard_import_zpl2(self): def test_wizard_import_zpl2(self):
""" Import ZPL2 from wizard """ """Import ZPL2 from wizard"""
zpl_data = ( zpl_data = (
"^XA\n" "^XA\n"
"^CI28\n" "^CI28\n"
@@ -76,7 +76,7 @@ class TestWizardImportZpl2(TransactionCase):
self.assertEqual(18, len(self.label.component_ids)) self.assertEqual(18, len(self.label.component_ids))
def test_wizard_import_zpl2_add(self): def test_wizard_import_zpl2_add(self):
""" Import ZPL2 from wizard ADD""" """Import ZPL2 from wizard ADD"""
self.env["printing.label.zpl2.component"].create( self.env["printing.label.zpl2.component"].create(
{ {
"name": "ZPL II Label", "name": "ZPL II Label",

View File

@@ -37,7 +37,7 @@ class TestWizardPrintRecordLabel(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_print_record_label(self, cups): def test_print_record_label(self, cups):
""" Check that printing a label using the generic wizard works """ """Check that printing a label using the generic wizard works"""
wizard_obj = self.Model.with_context( wizard_obj = self.Model.with_context(
active_model="printing.printer", active_model="printing.printer",
active_id=self.printer.id, active_id=self.printer.id,

View File

@@ -51,7 +51,7 @@ class PrintRecordLabel(models.TransientModel):
return values return values
def print_label(self): def print_label(self):
""" Prints a label per selected record """ """Prints a label per selected record"""
record_model = self.env.context["active_model"] record_model = self.env.context["active_model"]
for record_id in self.env.context["active_ids"]: for record_id in self.env.context["active_ids"]:
record = self.env[record_model].browse(record_id) record = self.env[record_model].browse(record_id)

View File

@@ -35,7 +35,7 @@ class ResRemotePrinter(models.Model):
@api.onchange("printer_id") @api.onchange("printer_id")
def _onchange_printing_printer_id(self): def _onchange_printing_printer_id(self):
""" 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.constrains("remote_id", "printer_usage", "is_default") @api.constrains("remote_id", "printer_usage", "is_default")