[IMP] stock: auto-print reception report

Add in feature to auto-print reception report at validation of picking.
Note that only pickings that have an allocation will be printed
otherwise the form will only have the picking name/barcode and nothing
else in it (i.e. not very useful).

Part of task: 3046178 - general auto-print goal

Part-of: odoo/odoo#126791
This commit is contained in:
Tiffany Chang (tic)
2023-10-24 12:38:06 +00:00
parent d43416c65d
commit ab56ebe8e6
3 changed files with 14 additions and 1 deletions
+12
View File
@@ -113,6 +113,9 @@ class PickingType(models.Model):
('zpl_lots', 'ZPL Labels - One per lot/SN'),
('zpl_units', 'ZPL Labels - One per unit')],
string="Lot Label Format to auto-print", default='4x12_lots')
auto_print_reception_report = fields.Boolean(
"Auto Print Reception Report",
help="If this checkbox is ticked, Odoo will automatically print the reception report of a picking when it is validated and has assigned moves.")
auto_print_reception_report_labels = fields.Boolean(
"Auto Print Reception Report Labels",
help="If this checkbox is ticked, Odoo will automatically print the reception report labels of a picking when it is validated.")
@@ -1768,6 +1771,15 @@ class Picking(models.Model):
report_actions.append(action)
if self.user_has_groups('stock.group_reception_report'):
reception_reports_to_print = self.filtered(
lambda p: p.picking_type_id.auto_print_reception_report
and p.picking_type_id.code != 'outgoing'
and p.move_ids.move_dest_ids
)
if reception_reports_to_print:
action = self.env.ref('stock.stock_reception_report_action').report_action(reception_reports_to_print, config=False)
clean_action(action, self.env)
report_actions.append(action)
reception_labels_to_print = self.filtered(lambda p: p.picking_type_id.auto_print_reception_report_labels and p.picking_type_id.code != 'outgoing')
if reception_labels_to_print:
moves_to_print = reception_labels_to_print.move_ids.move_dest_ids
@@ -30,7 +30,7 @@
<record id="stock_reception_report_action" model="ir.actions.report">
<field name="name">Reception Report</field>
<field name="model">stock.picking</field>
<field name="report_type">qweb-html</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">stock.report_reception</field>
</record>
@@ -141,6 +141,7 @@
<label for="lot_label_format" string="Print label as:" invisible="not auto_print_lot_labels" class="fw-bold"/>
<field name="lot_label_format" invisible="not auto_print_lot_labels"/>
</div>
<field name="auto_print_reception_report" string="Reception Report" invisible="code == 'outgoing'" groups="stock.group_reception_report"/>
<field name="auto_print_reception_report_labels" string="Reception Report Labels" invisible="code == 'outgoing'" groups="stock.group_reception_report"/>
<field name="auto_print_packages" string="Package Content" groups="stock.group_tracking_lot"/>
</group>