提交 9410732f authored 作者: 贺阳's avatar 贺阳

打印,单独打印没问题

上级 e0821e42
......@@ -12,6 +12,7 @@
<field name="ship_package_qty" string="Packages Qty"/>
<field name="goods_qty" string="Goods Qty"/>
<field name="is_cancel" string="Cancelled"/>
<field name="next_provider_name"/>
<field name="pallet_number"/>
<field name="pallet_usage_date"/>
<field name="tally_state" optional="show"/>
......
from . import models
from . import wizard
from . import reports
......@@ -18,9 +18,9 @@
'wizard/pallet_batch_wizard_view.xml',
'wizard/pallet_print_wizard_view.xml',
'wizard/associate_pallet_wizard_views.xml',
'reports/pallet_label_report.xml',
"reports/report_pallet_labe.xml",
'reports/pallet_label_report_templates.xml',
'views/cc_pallet_view.xml',
# 'views/cc_big_package_view.xml',
'views/menu_view.xml',
],
'installable': True,
......
......@@ -16,6 +16,7 @@ class CcPallet(models.Model):
_inherit = ['mail.thread', 'mail.activity.mixin']
# 模型描述
_description = 'Pallet'
_order = 'create_date desc'
@api.model
def create(self, vals):
......
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import report_pallet
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- 托盘标签纸张格式 -->
<record id="paperformat_pallet_label" model="report.paperformat">
<field name="name">托盘标签 (10x15cm)</field>
<field name="default" eval="True"/>
<field name="format">custom</field>
<field name="orientation">Portrait</field>
<field name="margin_top">0</field>
<field name="margin_bottom">0</field>
<field name="margin_left">0</field>
<field name="margin_right">0</field>
<field name="header_line" eval="False"/>
<field name="header_spacing">0</field>
<field name="dpi">90</field>
<field name="page_width">10</field>
<field name="page_height">15</field>
</record>
<!-- 托盘标签打印报告 -->
<record id="action_pallet_label_report" model="ir.actions.report">
<field name="name">托盘标签</field>
<field name="model">cc.pallet</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">ccs_pallet.pallet_label_report</field>
<field name="report_file">ccs_pallet.pallet_label_report</field>
<field name="paperformat_id" ref="paperformat_pallet_label"/>
<field name="binding_model_id" ref="model_cc_pallet"/>
<field name="binding_type">report</field>
</record>
<!-- 托盘标签模板 -->
<template id="pallet_label_report">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="pallet">
<div class="page" style="width: 100%; height: 100%; margin: 0; padding: 0.3cm; page-break-after: always; font-family: 'DejaVu Sans', Arial, sans-serif; box-sizing: border-box; position: relative;">
<!-- 客户名称和快递简称 -->
<div style="text-align: center; height: 2cm; display: flex; align-items: center; justify-content: center; margin-bottom: 0.2cm;">
<h2 style="margin: 0; font-size: 18px; font-weight: bold; line-height: 1.2;">
<t t-esc="pallet.partner_id.name or 'TIKTOK'"/> / <t t-esc="pallet.express_company_id.name or 'RM'"/>
</h2>
</div>
<!-- 条形码区域 -->
<div style="text-align: center; height: 8cm; border: 2px dashed #999; background-color: #f9f9f9; display: flex; flex-direction: column; justify-content: center; margin-bottom: 0.2cm;">
<div style="font-size: 14px; color: #666; margin-bottom: 0.5cm;">
<!-- 托盘号作为条形码 -->
<t t-if="pallet.name">
<div t-out="pallet.name" style="padding:0; margin-bottom: 0.3cm;" t-options="{'widget': 'barcode', 'quiet': 0, 'symbology': 'auto', 'width': 2, 'height': 60}"/>
<div class="o_label_name" style="height:1.2em;background-color: transparent; font-size: 12px;">
<span t-out="pallet.name"/>
</div>
</t>
</div>
</div>
<!-- 托盘号 -->
<div style="text-align: center; height: 3cm; display: flex; align-items: center; justify-content: center;">
<h1 style="margin: 0; font-size: 22px; font-weight: bold; line-height: 1.2;">
<t t-esc="pallet.name"/>
</h1>
</div>
</div>
</t>
</t>
</template>
</odoo>
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="report_palletlabel">
<t t-call="web.html_container">
<t t-set="barcode_size" t-value="'width:80mm;height:30mm'"/>
<t t-set="table_style" t-value="'width:100mm;height:150mm;'"/>
<t t-set="padding_page" t-value="'padding: 5mm'"/>
<t t-set="pallets" t-value="pallets"/>
<t t-foreach="pallets" t-as="pallet">
<t t-call="ccs_pallet.report_simple_pallet_barcode"/>
</t>
</t>
</template>
<!-- 托盘标签模板 -->
<template id="report_simple_pallet_barcode">
<div class="o_label_sheet o_label_dymo" t-att-style="padding_page">
<div class="o_label_full" t-att-style="table_style" style="display: flex; flex-direction: column; justify-content: space-between; align-items: center; text-align: center;">
<!-- 顶部标题 -->
<div style="flex: 0 0 auto; margin-bottom: 10mm; text-align: center;">
<div style="font-size: 24px; font-weight: bold; line-height: 1.2; font-family: Arial, sans-serif;">
<t t-esc="pallet.partner_id.name or 'TIKTOK'"/> / <t t-esc="pallet.express_company_id.abbreviation"/>
</div>
</div>
<!-- 中间条形码区域 -->
<div style="flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;">
<t t-if="pallet.name">
<div t-out="pallet.name" style="padding:0; margin: 0 auto;" t-options="{'widget': 'barcode', 'quiet': 0, 'symbology': 'auto', 'img_style': barcode_size}"/>
</t>
</div>
<!-- 底部托盘号 -->
<div style="flex: 0 0 auto; margin-top: 10mm; text-align: center;">
<div style="font-size: 32px; font-weight: bold; line-height: 1.2; font-family: Arial, sans-serif;">
<span t-field="pallet.name"/>
</div>
</div>
</div>
</div>
<!-- <div class="o_label_sheet o_label_dymo" t-att-style="padding_page">
<div class="o_label_full" t-att-style="table_style" style="position: relative; box-sizing: border-box;">
<table style="width: 100%; height: 100%; border-collapse: collapse;">
<tr>
<td style="height: 20mm; text-align: center; vertical-align: middle; padding: 0; margin: 0;">
<div style="font-size: 24px; font-weight: bold; line-height: 1.2; font-family: Arial, sans-serif;">
<t t-esc="pallet.partner_id.name or 'TIKTOK'"/> / <t t-esc="pallet.express_company_id.abbreviation"/>
</div>
</td>
</tr>
<tr>
<td style="height: 60mm; text-align: center; vertical-align: middle; padding: 5mm; background-color: #f0f0f0; border: 1px solid #ddd;">
<t t-if="pallet.name">
<div style="text-align: center; font-size: 12px; color: #666;">
<div t-out="pallet.name"
t-options="{'widget': 'barcode', 'symbology': 'auto', 'img_style': barcode_size}"
style="margin: 10px 0;"/>
</div>
</t>
</td>
</tr>
<tr>
<td style="height: 30mm; text-align: center; vertical-align: middle; padding: 0; margin: 0;">
<div style="font-size: 32px; font-weight: bold; line-height: 1.2; font-family: Arial, sans-serif;">
<span t-field="pallet.name"/>
</div>
</td>
</tr>
</table>
</div>
</div> -->
</template>
</odoo>
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models, _
from odoo.exceptions import UserError
class ReportPallet(models.AbstractModel):
_name = 'report.ccs_pallet.report_palletlabel'
_description = 'Pallet report'
@api.model
def _get_report_values(self, docids, data=None):
# Overriding data values here since used also in _get_routes.
pallets = self.env['cc.pallet'].browse(docids)
return {
'pallets': pallets,
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- 托盘标签纸张格式 -->
<record id="paperformat_pallet_label" model="report.paperformat">
<field name="name">托盘标签 (10x15cm)</field>
<field name="default" eval="True"/>
<field name="format">custom</field>
<field name="orientation">Portrait</field>
<field name="margin_top">0</field>
<field name="margin_bottom">0</field>
<field name="margin_left">0</field>
<field name="margin_right">0</field>
<field name="header_line" eval="False"/>
<field name="header_spacing">0</field>
<field name="dpi">90</field>
<field name="page_width">100</field>
<field name="page_height">150</field>
</record>
<!-- 托盘标签打印报告 -->
<record id="action_pallet_label_report" model="ir.actions.report">
<field name="name">托盘标签</field>
<field name="model">cc.pallet</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">ccs_pallet.report_palletlabel</field>
<field name="report_file">ccs_pallet.report_palletlabel</field>
<field name="paperformat_id" ref="paperformat_pallet_label"/>
<!-- <field name="binding_model_id" ref="model_cc_pallet"/> -->
<field name="binding_model_id" eval="False"/>
<field name="binding_type">report</field>
</record>
</odoo>
......@@ -27,6 +27,8 @@
<field name="express_company_id" required="1" options="{'no_create': True, 'no_quick_create': True}"/>
<field name="partner_id" options="{'no_create': True, 'no_quick_create': True}"/>
<field name="delivery_plate_number"/>
<field name="create_uid" readonly="1" string="Create By"/>
<field name="create_date" readonly="1" string="Create Date"/>
</group>
<group string="Status Information">
<field name="print_state" readonly="1"/>
......@@ -61,6 +63,8 @@
<field name="delivery_time"/>
<field name="package_count"/>
<field name="delivery_plate_number"/>
<field name="create_uid" string="Create By"/>
<field name="create_date" string="Create Date"/>
</tree>
</field>
</record>
......@@ -109,4 +113,18 @@
</p>
</field>
</record>
<!-- 增加server action,批量打印标签 -->
<record id="action_print_labels_pallet_server" model="ir.actions.server">
<field name="name">Print Labels</field>
<field name="groups_id" eval="[(4, ref('ccs_pallet.group_pallet_manager'))]"/>
<field name="model_id" ref="model_cc_pallet"/>
<field name="binding_model_id" ref="model_cc_pallet"/>
<field name="binding_view_types">list</field>
<field name="state">code</field>
<field name="code">
if records:
action = records.action_print_labels()
</field>
</record>
</odoo>
\ No newline at end of file
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from datetime import date
from odoo import models, fields, api, _
from odoo.exceptions import Warning, ValidationError
from odoo import models, fields, _
from odoo.exceptions import ValidationError
class AssociatePalletWizard(models.TransientModel):
......@@ -37,5 +36,4 @@ class AssociatePalletWizard(models.TransientModel):
if success_package:
# 更新托盘的使用状态(理货时间和交货时间会自动通过计算字段更新)
record.pallet_id.update_usage_state(success_package)
record.pallet_id.update_usage_state(success_package, record.usage_date)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论