🎉 Initial commit - Hazard Odoo 16 project
- Custom modules: hazard_shopify, hazard_inventory_report, hazard_website - Third-party modules: bi_sql_editor, query_deluxe, sql_request_abstract, l10n_mx_sat_sync_itadmin_ee - Docker setup: Odoo 16 + PostgreSQL 17 - Utility scripts: backup_hazard.sh, update_module.py - Agent configuration: .agents/AGENTS.md - Security: Enterprise modules, credentials, backups and production data excluded via .gitignore
This commit is contained in:
@@ -0,0 +1 @@
|
||||
from . import pdforientation
|
||||
@@ -0,0 +1,40 @@
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class PdfOrientation(models.TransientModel):
|
||||
_name = 'pdforientation'
|
||||
_description = "Select the orientation of the pdf"
|
||||
|
||||
def orientation_choices(self):
|
||||
return [('landscape', _('Landscape')), ('portrait', _('Portrait'))]
|
||||
|
||||
orientation = fields.Selection(string="PDF orientation", selection=orientation_choices, default='landscape')
|
||||
query_name = fields.Text(string="Query")
|
||||
|
||||
def print_pdf(self):
|
||||
self = self.sudo()
|
||||
try:
|
||||
self.env.cr.execute(self.query_name)
|
||||
except Exception as e:
|
||||
raise UserError(e)
|
||||
|
||||
try:
|
||||
if self.env.cr.description:
|
||||
headers = [d[0] for d in self.env.cr.description]
|
||||
bodies = self.env.cr.fetchall()
|
||||
except Exception as e:
|
||||
raise UserError(e)
|
||||
|
||||
action_print_pdf = self.env.ref('query_deluxe.action_print_pdf')
|
||||
if self.orientation == 'landscape':
|
||||
action_print_pdf.paperformat_id.orientation = "Landscape"
|
||||
elif self.orientation == 'portrait':
|
||||
action_print_pdf.paperformat_id.orientation = "Portrait"
|
||||
|
||||
append_data = {
|
||||
'query_name': self.query_name,
|
||||
'headers': headers,
|
||||
'bodies': bodies
|
||||
}
|
||||
return action_print_pdf.report_action(self, data=append_data)
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<odoo>
|
||||
<record id="pdforientation_form" model="ir.ui.view">
|
||||
<field name="name">pdforientation.form</field>
|
||||
<field name="model">pdforientation</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="query_name" invisible="0" readonly="1"/>
|
||||
<field name="orientation" widget="radio" options="{'horizontal': true}"/>
|
||||
</group>
|
||||
</sheet>
|
||||
|
||||
<footer>
|
||||
<button string="Print" name="print_pdf" type="object" class="oe_highlight"/>
|
||||
<button string="Cancel" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user