Skip to content

Commit

Permalink
[IMP] delivery_automatic_print: Allow to filter picking types for eac…
Browse files Browse the repository at this point in the history
…h automatically printed report
  • Loading branch information
fkantelberg authored and jans23 committed Jul 17, 2024
1 parent abf677f commit c38913a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
4 changes: 3 additions & 1 deletion delivery_automatic_print/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"carrier_shipping_label_template",
"stock",
],
"data": [],
"data": [
"views/ir_actions_report_views.xml",
],
"auto_install": False,
"installable": True,
"author": "Nitrokey GmbH",
Expand Down
4 changes: 3 additions & 1 deletion delivery_automatic_print/models/ir_actions_report.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# © 2024 initOS GmbH
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models
from odoo import fields, models


class IrActionsReport(models.Model):
_inherit = "ir.actions.report"

auto_picking_type_ids = fields.Many2many("stock.picking.type")

def _render_qweb_pdf(self, res_ids=None, data=None):
document, fmt = super()._render_qweb_pdf(res_ids, data)

Expand Down
9 changes: 8 additions & 1 deletion delivery_automatic_print/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ def button_validate(self):

ctx = {"raise_on_missing_labels": False}
for report in self.reports_to_print().with_context(**ctx):
report.sudo()._render_qweb_pdf(self.ids)
if report.auto_picking_type_ids:
pickings = self.filtered_domain(
[("picking_type_id", "in", report.auto_picking_type_ids.ids)]
)
else:
pickings = self

report.sudo()._render_qweb_pdf(pickings.ids)

return res
12 changes: 12 additions & 0 deletions delivery_automatic_print/views/ir_actions_report_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="act_report_xml_view" model="ir.ui.view">
<field name="model">ir.actions.report</field>
<field name="inherit_id" ref="base_report_to_printer.act_report_xml_view" />
<field name="arch" type="xml">
<field name="printer_tray_id" position="after">
<field name="auto_picking_type_ids" />
</field>
</field>
</record>
</odoo>

0 comments on commit c38913a

Please sign in to comment.