diff --git a/fusion_plating/fusion_plating_jobs/models/fp_receiving.py b/fusion_plating/fusion_plating_jobs/models/fp_receiving.py index f240df8b..3457b95c 100644 --- a/fusion_plating/fusion_plating_jobs/models/fp_receiving.py +++ b/fusion_plating/fusion_plating_jobs/models/fp_receiving.py @@ -8,6 +8,7 @@ # reaches state='done'. from odoo import _, fields, models +from odoo.exceptions import UserError class FpReceiving(models.Model): @@ -65,3 +66,34 @@ class FpReceiving(models.Model): if len(jobs) == 1: action.update({'view_mode': 'form', 'res_id': jobs.id}) return action + + # ---- Sticker printing from the Receiving screen (2026-06-04) ---------- + # Both stickers loop the SO's boxes (one label per box). Pass a SINGLE + # work order: the box loop is sale-order-scoped, so feeding every job + # would reprint each box label once per job. One job → exactly one label + # per box. Falls back to a single 1/1 label when no boxes exist yet. + def _fp_sticker_jobs(self): + self.ensure_one() + if not self.sale_order_id: + return self.env['fp.job'] + return self.env['fp.job'].sudo().search( + [('sale_order_id', '=', self.sale_order_id.id)], order='id', limit=1) + + def _fp_print_sticker(self, xmlid): + self.ensure_one() + jobs = self._fp_sticker_jobs() + if not jobs: + raise UserError(_( + 'No work order exists for this receiving yet — create the ' + 'Work Order before printing stickers.')) + return self.env.ref(xmlid).report_action(jobs) + + def action_print_external_sticker(self): + """Customer (external) box sticker(s) for this receiving's WO.""" + return self._fp_print_sticker( + 'fusion_plating_jobs.action_report_fp_job_sticker') + + def action_print_internal_sticker(self): + """Shop (internal) box sticker(s) — same layout, internal notes.""" + return self._fp_print_sticker( + 'fusion_plating_jobs.action_report_fp_job_sticker_internal') diff --git a/fusion_plating/fusion_plating_jobs/report/report_fp_job_sticker.xml b/fusion_plating/fusion_plating_jobs/report/report_fp_job_sticker.xml index 8fc03e49..029d82bd 100644 --- a/fusion_plating/fusion_plating_jobs/report/report_fp_job_sticker.xml +++ b/fusion_plating/fusion_plating_jobs/report/report_fp_job_sticker.xml @@ -57,8 +57,11 @@ fusion_plating_jobs.report_fp_job_sticker_internal_template fusion_plating_jobs.report_fp_job_sticker_internal_template 'Internal Job Sticker - %s' % (object.name or '').replace('/', '-') - - report + + @@ -121,74 +124,6 @@ - - - + @@ -281,6 +234,7 @@ + diff --git a/fusion_plating/fusion_plating_jobs/views/fp_receiving_views.xml b/fusion_plating/fusion_plating_jobs/views/fp_receiving_views.xml index 18211f23..329d3949 100644 --- a/fusion_plating/fusion_plating_jobs/views/fp_receiving_views.xml +++ b/fusion_plating/fusion_plating_jobs/views/fp_receiving_views.xml @@ -25,6 +25,17 @@ class="btn-primary" icon="fa-cogs" invisible="not x_fc_show_work_order_btn" help="Open the Work Order(s) for this receiving. Hidden automatically once every linked WO is marked Done."/> + +