Tower: upload laundry_management 19.0.19.0.4 (via marketplace)
This commit is contained in:
51
addons/laundry_management/wizard/laundry_print_wizard.py
Normal file
51
addons/laundry_management/wizard/laundry_print_wizard.py
Normal file
@@ -0,0 +1,51 @@
|
||||
from odoo import models, fields, api
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class LaundryPrintWizard(models.TransientModel):
|
||||
"""Print template selection wizard — routes to A4, Thermal, or Tracking."""
|
||||
_name = 'laundry.print.wizard'
|
||||
_description = 'Laundry Print Wizard'
|
||||
|
||||
order_id = fields.Many2one(
|
||||
'laundry.order', string='Order',
|
||||
required=True, readonly=True,
|
||||
)
|
||||
|
||||
order_name = fields.Char(related='order_id.name', readonly=True)
|
||||
customer_name = fields.Char(related='order_id.partner_id.name', readonly=True)
|
||||
total_amount = fields.Monetary(
|
||||
related='order_id.amount_total',
|
||||
readonly=True,
|
||||
currency_field='currency_id',
|
||||
)
|
||||
currency_id = fields.Many2one(
|
||||
related='order_id.currency_id', readonly=True,
|
||||
)
|
||||
|
||||
template = fields.Selection([
|
||||
('a4', 'A4 Customer Receipt (Bilingual)'),
|
||||
('thermal', 'Thermal Receipt (80mm)'),
|
||||
('tracking', 'Item Tracking Slips'),
|
||||
], string='Print Template', required=True, default='a4')
|
||||
|
||||
include_prices = fields.Boolean(string='Include Prices', default=True)
|
||||
include_notes = fields.Boolean(string='Include Customer Notes', default=True)
|
||||
|
||||
def action_print(self):
|
||||
self.ensure_one()
|
||||
ref_map = {
|
||||
'a4': 'laundry_management.action_report_laundry_order_receipt',
|
||||
'thermal': 'laundry_management.action_report_laundry_thermal_receipt',
|
||||
'tracking': 'laundry_management.action_report_laundry_tracking_slip',
|
||||
}
|
||||
report_ref = ref_map.get(self.template)
|
||||
if not report_ref:
|
||||
raise UserError('Unknown print template.')
|
||||
return self.env.ref(report_ref).report_action(
|
||||
self.order_id,
|
||||
data={
|
||||
'include_prices': self.include_prices,
|
||||
'include_notes': self.include_notes,
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user