Skip to content

Commit

Permalink
fixup! [ADD] stock_picking_auto_print
Browse files Browse the repository at this point in the history
Refactor in base & stock_picking modules
  • Loading branch information
jbaudoux committed Dec 16, 2022
1 parent bffb5a4 commit fdb2477
Show file tree
Hide file tree
Showing 33 changed files with 681 additions and 85 deletions.
75 changes: 75 additions & 0 deletions printing_auto_base/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
==================
printing_auto_base
==================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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/14.0/printing_auto_base
: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-14-0/report-print-send-14-0-printing_auto_base
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/report-print-send&target_branch=14.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Base module to support automatic priting of a report or attachements.

**Table of contents**

.. contents::
:local:

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:%20printing_auto_base%0Aversion:%2014.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
~~~~~~~

* BCIM

Contributors
~~~~~~~~~~~~

* Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
* Camptocamp
* Christopher Hansen <christopher.hansen@raumschmiede.de>

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/14.0/printing_auto_base>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
File renamed without changes.
19 changes: 19 additions & 0 deletions printing_auto_base/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2022 Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"application": False,
"author": "BCIM, Odoo Community Association (OCA)",
"category": "Warehouse Management",
"data": [
"views/printing_auto.xml",
],
"depends": [
"base_report_to_printer",
],
"installable": True,
"license": "AGPL-3",
"name": "printing_auto_base",
"version": "14.0.1.0.0",
"website": "https://github.com/OCA/report-print-send",
}
1 change: 1 addition & 0 deletions printing_auto_base/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import printing_auto
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from odoo.tools.safe_eval import safe_eval


class StockAutoPrinting(models.Model):
_name = "stock.auto.printing"
_description = "Stock Auto Printing"
class PrintingAuto(models.Model):
_name = "printing.auto"
_description = "Printing Auto"

name = fields.Char(string="Name", required=True)
file_type = fields.Selection(
Expand Down Expand Up @@ -45,7 +45,6 @@ class StockAutoPrinting(models.Model):
printer_tray_id = fields.Many2one("printing.tray")
nbr_of_copies = fields.Integer("Number of Copies", default=1)

picking_type_id = fields.Many2one("stock.picking.type", required=True)
label = fields.Boolean(string="Is Label")

@api.constrains("report_id", "file_type")
Expand All @@ -54,10 +53,8 @@ def check_report(self):
if rec.file_type == "report" and not rec.report_id:
raise UserError(_("Report was not set"))

def do_automated_printing(self, pickings):
def do_print(self, pickings):
self.ensure_one()
if not self.nbr_of_copies:
return

behaviour = self.get_behaviour()
printer = behaviour["printer"]
Expand All @@ -66,13 +63,19 @@ def do_automated_printing(self, pickings):
_("No printer configured to print this {}.").format(self.name)
)

if self.nbr_of_copies <= 0:
return (printer, 0)

count = 0
for picking in pickings:
if not self._check_condition(picking):
continue
record = self._get_record(picking)
for content in self.get_content(record):
for _n in range(self.nbr_of_copies):
printer.print_document(report=None, content=content, **behaviour)
count += 1
return (printer, count)

def get_behaviour(self):
if self.printer_id:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
* Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
* Camptocamp
* Christopher Hansen <christopher.hansen@raumschmiede.de>
1 change: 1 addition & 0 deletions printing_auto_base/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Base module to support automatic priting of a report or attachements.
Loading

0 comments on commit fdb2477

Please sign in to comment.