[MIG] base_report_to_printer: Print attachments wizard

This commit is contained in:
sebalix
2020-08-06 12:30:44 +02:00
parent e4ce148208
commit 90816757ec
2 changed files with 55 additions and 52 deletions

View File

@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright 2020 Camptocamp SA # Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
import base64 import base64
from openerp import _, models, api, fields from odoo import _, models, api, fields
class PrintAttachment(models.TransientModel): class PrintAttachment(models.TransientModel):
@@ -59,7 +58,10 @@ class PrintAttachmentLine(models.TransientModel):
attachment_id = fields.Many2one( attachment_id = fields.Many2one(
'ir.attachment', 'ir.attachment',
required=True, required=True,
domain="['|', ('mimetype', '=', 'application/pdf'), ('mimetype', '=', 'application/octet-stream')]" domain=(
"['|', ('mimetype', '=', 'application/pdf'), "
"('mimetype', '=', 'application/octet-stream')]"
)
) )
record_name = fields.Char(related="attachment_id.res_name", readonly=True) record_name = fields.Char(related="attachment_id.res_name", readonly=True)
copies = fields.Integer(default=1) copies = fields.Integer(default=1)

View File

@@ -1,50 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<openerp> <odoo>
<data> <record id="wizard_print_attachment_form" model="ir.ui.view">
<record id="wizard_print_attachment_form" model="ir.ui.view"> <field name="name">wizard.print.attachment</field>
<field name="name">wizard.print.attachment</field> <field name="model">wizard.print.attachment</field>
<field name="model">wizard.print.attachment</field> <field name="arch" type="xml">
<field name="arch" type="xml"> <form string="Print attachments">
<form string="Print attachments"> <group>
<group> <field name="printer_id" />
<field name="printer_id" /> <field name="attachment_line_ids">
<field name="attachment_line_ids"> <tree editable="top">
<tree editable="top"> <field name="attachment_id" create="0" />
<field name="attachment_id" create="0" /> <field name="record_name" />
<field name="record_name" /> <field name="copies" />
<field name="copies" /> </tree>
</tree> </field>
</field> </group>
</group> <footer>
<footer> <button name="print_attachments" type="object"
<button name="print_attachments" string="Print" type="object" class="oe_highlight"/> string="Print" class="btn-primary"/>
or <button string="Cancel" class="btn-secondary" special="cancel"/>
<button string="Cancel" class="oe_link" special="cancel"/> </footer>
</footer> </form>
</form> </field>
</field> </record>
</record> <record id="wizard_print_attachment_line_form" model="ir.ui.view">
<record id="wizard_print_attachment_line_form" model="ir.ui.view"> <field name="name">wizard.print.attachment.line.form</field>
<field name="name">wizard.print.attachment.line.form</field> <field name="model">wizard.print.attachment.line</field>
<field name="model">wizard.print.attachment.line</field> <field name="arch" type="xml">
<field name="arch" type="xml"> <form>
<form> <group>
<group> <field name="attachment_id" create="0" />
<field name="attachment_id" create="0" /> <field name="record_name" />
<field name="record_name" /> <field name="copies" />
<field name="copies" /> </group>
</group> </form>
</form> </field>
</field> </record>
</record> <record id="action_wizard_print_attachment" model="ir.actions.act_window" >
<record id="action_wizard_print_attachment" model="ir.actions.act_window" > <field name="name">Print Attachments</field>
<field name="name">Print Attachments</field> <field name="type">ir.actions.act_window</field>
<field name="type">ir.actions.act_window</field> <field name="res_model">wizard.print.attachment</field>
<field name="res_model">wizard.print.attachment</field> <field name="view_type">form</field>
<field name="view_type">form</field> <field name="view_mode">form</field>
<field name="view_mode">form</field> <field name="target">new</field>
<field name="target">new</field> </record>
</record> <menuitem id="menu_action_wizard_print_attachment"
<menuitem id="menu_action_wizard_print_attachment" action="action_wizard_print_attachment" sequence="50" parent="printing_menu" /> action="action_wizard_print_attachment"
</data> sequence="50"
</openerp> parent="printing_menu" />
</odoo>