changes
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import fp_label_manual_wizard
|
||||
@@ -0,0 +1,81 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2026 Nexa Systems Inc.
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
"""Manual outbound-label entry wizard.
|
||||
|
||||
Opens automatically from fp.receiving.action_generate_outbound_label
|
||||
when:
|
||||
- the chosen carrier has no API integration (delivery_type='fixed'), or
|
||||
- the carrier API call fails (network, credential, malformed response).
|
||||
|
||||
Operator pastes the label PDF from the carrier's web tool + types the
|
||||
tracking number. On confirm, both land on the linked fusion.shipment.
|
||||
"""
|
||||
import base64
|
||||
|
||||
from markupsafe import Markup
|
||||
|
||||
from odoo import _, fields, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class FpLabelManualWizard(models.TransientModel):
|
||||
_name = 'fp.label.manual.wizard'
|
||||
_description = 'Fusion Plating — Manual Outbound Label Entry'
|
||||
|
||||
receiving_id = fields.Many2one(
|
||||
'fp.receiving', required=True, readonly=True, ondelete='cascade',
|
||||
)
|
||||
receiving_name = fields.Char(related='receiving_id.name', readonly=True)
|
||||
carrier_id = fields.Many2one(
|
||||
related='receiving_id.x_fc_carrier_id', readonly=True,
|
||||
)
|
||||
shipment_id = fields.Many2one(
|
||||
related='receiving_id.x_fc_outbound_shipment_id', readonly=True,
|
||||
)
|
||||
note = fields.Text(
|
||||
string='Why Manual?', readonly=True,
|
||||
help='Explanatory message — set by the caller (no API, API '
|
||||
'failure, etc.).',
|
||||
)
|
||||
label_pdf = fields.Binary(string='Shipping Label PDF')
|
||||
label_filename = fields.Char(string='Filename')
|
||||
tracking_number = fields.Char(string='Tracking Number')
|
||||
|
||||
def action_confirm(self):
|
||||
self.ensure_one()
|
||||
if not self.label_pdf:
|
||||
raise UserError(_(
|
||||
'Attach the shipping label PDF before confirming.'
|
||||
))
|
||||
if not (self.tracking_number or '').strip():
|
||||
raise UserError(_(
|
||||
'Enter the tracking number before confirming.'
|
||||
))
|
||||
ship = self.shipment_id
|
||||
if not ship:
|
||||
raise UserError(_(
|
||||
'No outbound shipment linked to this receiving — '
|
||||
'cannot save manual label.'
|
||||
))
|
||||
# Create the attachment, then write the shipment.
|
||||
att = self.env['ir.attachment'].sudo().create({
|
||||
'name': self.label_filename or 'shipping-label.pdf',
|
||||
'type': 'binary',
|
||||
'datas': self.label_pdf,
|
||||
'mimetype': 'application/pdf',
|
||||
'res_model': 'fusion.shipment',
|
||||
'res_id': ship.id,
|
||||
})
|
||||
ship.sudo().write({
|
||||
'label_attachment_id': att.id,
|
||||
'tracking_number': self.tracking_number.strip(),
|
||||
'status': 'confirmed',
|
||||
})
|
||||
ship.message_post(body=Markup(_(
|
||||
'Manual label saved — tracking <b>%s</b>.'
|
||||
)) % self.tracking_number)
|
||||
self.receiving_id.message_post(body=Markup(_(
|
||||
'Outbound label entered manually. Tracking: <b>%s</b>'
|
||||
)) % self.tracking_number)
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright 2026 Nexa Systems Inc.
|
||||
License OPL-1 (Odoo Proprietary License v1.0)
|
||||
Part of the Fusion Plating product family.
|
||||
-->
|
||||
<odoo>
|
||||
<record id="view_fp_label_manual_wizard_form" model="ir.ui.view">
|
||||
<field name="name">fp.label.manual.wizard.form</field>
|
||||
<field name="model">fp.label.manual.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Manual Outbound Label Entry">
|
||||
<sheet>
|
||||
<div class="oe_title">
|
||||
<h2>Enter Label Manually —
|
||||
<field name="receiving_name"
|
||||
readonly="1" nolabel="1" class="oe_inline"/>
|
||||
</h2>
|
||||
</div>
|
||||
<div class="alert alert-info" role="alert"
|
||||
invisible="not note">
|
||||
<i class="fa fa-info-circle"/>
|
||||
<field name="note" nolabel="1" readonly="1"/>
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
<field name="carrier_id" readonly="1"/>
|
||||
<field name="shipment_id" readonly="1"/>
|
||||
</group>
|
||||
</group>
|
||||
<separator string="Label Details"/>
|
||||
<group>
|
||||
<field name="label_pdf"
|
||||
filename="label_filename"/>
|
||||
<field name="label_filename" invisible="1"/>
|
||||
<field name="tracking_number"
|
||||
placeholder="e.g. 1Z999AA10123456784"/>
|
||||
</group>
|
||||
</sheet>
|
||||
<footer>
|
||||
<button name="action_confirm" type="object"
|
||||
string="Save Label" class="btn-primary"/>
|
||||
<button string="Cancel" class="btn-secondary"
|
||||
special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user