[IMP] sale: report folder code cleanup

Code indentation
Attributes ordering
qweb code cleanup
...
This commit is contained in:
Victor Feyens
2022-01-03 12:22:45 +01:00
parent c7d8510084
commit bc9b2dbb45
6 changed files with 61 additions and 57 deletions
+2 -2
View File
@@ -7,7 +7,7 @@ from odoo import fields, models
class AccountInvoiceReport(models.Model):
_inherit = 'account.invoice.report'
team_id = fields.Many2one('crm.team', string='Sales Team')
team_id = fields.Many2one(comodel_name='crm.team', string="Sales Team")
def _select(self):
return super(AccountInvoiceReport, self)._select() + ", move.team_id as team_id"
return super()._select() + ", move.team_id as team_id"
@@ -6,12 +6,12 @@
<field name="model">account.invoice.report</field>
<field name="inherit_id" ref="account.view_account_invoice_report_search"/>
<field name="arch" type="xml">
<xpath expr="//group/filter[@name='user']" position="after">
<filter string="Sales Team" name="sales_channel" domain="[]" context="{'group_by':'team_id'}"/>
</xpath>
<xpath expr="//field[@name='invoice_user_id']" position="after">
<filter name="user" position="after">
<filter string="Sales Team" name="sales_channel" context="{'group_by':'team_id'}"/>
</filter>
<field name="invoice_user_id" position="after">
<field name="team_id"/>
</xpath>
</field>
</field>
</record>
+23 -23
View File
@@ -1,27 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="action_report_saleorder" model="ir.actions.report">
<field name="name">Quotation / Order</field>
<field name="model">sale.order</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">sale.report_saleorder</field>
<field name="report_file">sale.report_saleorder</field>
<field name="print_report_name">(object.state in ('draft', 'sent') and 'Quotation - %s' % (object.name)) or 'Order - %s' % (object.name)</field>
<field name="binding_model_id" ref="model_sale_order"/>
<field name="binding_type">report</field>
</record>
<record id="action_report_pro_forma_invoice" model="ir.actions.report">
<field name="name">PRO-FORMA Invoice</field>
<field name="model">sale.order</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">sale.report_saleorder_pro_forma</field>
<field name="report_file">sale.report_saleorder_pro_forma</field>
<field name="print_report_name">'PRO-FORMA - %s' % (object.name)</field>
<field name="binding_model_id" ref="model_sale_order"/>
<field name="binding_type">report</field>
<field name="groups_id" eval="[(4, ref('sale.group_proforma_sales'))]"/>
</record>
</data>
<record id="action_report_saleorder" model="ir.actions.report">
<field name="name">Quotation / Order</field>
<field name="model">sale.order</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">sale.report_saleorder</field>
<field name="report_file">sale.report_saleorder</field>
<field name="print_report_name">(object.state in ('draft', 'sent') and 'Quotation - %s' % (object.name)) or 'Order - %s' % (object.name)</field>
<field name="binding_model_id" ref="model_sale_order"/>
<field name="binding_type">report</field>
</record>
<record id="action_report_pro_forma_invoice" model="ir.actions.report">
<field name="name">PRO-FORMA Invoice</field>
<field name="model">sale.order</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">sale.report_saleorder_pro_forma</field>
<field name="report_file">sale.report_saleorder_pro_forma</field>
<field name="print_report_name">'PRO-FORMA - %s' % (object.name)</field>
<field name="binding_model_id" ref="model_sale_order"/>
<field name="binding_type">report</field>
<field name="groups_id" eval="[(4, ref('sale.group_proforma_sales'))]"/>
</record>
</odoo>
@@ -13,10 +13,16 @@
and doc.partner_invoice_id != doc.partner_id
or doc.partner_shipping_id != doc.partner_invoice_id">
<t t-set="information_block">
<strong t-if="doc.partner_shipping_id == doc.partner_invoice_id">Invoicing and Shipping Address:</strong>
<strong t-if="doc.partner_shipping_id != doc.partner_invoice_id">Invoicing Address:</strong>
<strong>
<t t-if="doc.partner_shipping_id == doc.partner_invoice_id">
Invoicing and Shipping Address:
</t>
<t t-else="">
Invoicing Address:
</t>
</strong>
<div t-field="doc.partner_invoice_id"
t-options='{"widget": "contact", "fields": ["address", "name", "phone"], "no_marker": True, "phone_icons": True}'/>
t-options='{"widget": "contact", "fields": ["address", "name", "phone"], "no_marker": True, "phone_icons": True}'/>
<t t-if="doc.partner_shipping_id != doc.partner_invoice_id">
<strong>Shipping Address:</strong>
<div t-field="doc.partner_shipping_id"
@@ -28,30 +34,25 @@
<div class="oe_structure"/>
<h2 class="mt16">
<t t-if="not (env.context.get('proforma', False) or is_pro_forma)">
<span t-if="doc.state not in ['draft','sent']">Order # </span>
<span t-if="doc.state in ['draft','sent']">Quotation # </span>
</t>
<t t-if="env.context.get('proforma', False) or is_pro_forma">
<span>Pro-Forma Invoice # </span>
</t>
<span t-if="env.context.get('proforma', False) or is_pro_forma">Pro-Forma Invoice # </span>
<span t-elif="doc.state in ['draft','sent']">Quotation # </span>
<span t-else="">Order # </span>
<span t-field="doc.name"/>
</h2>
<div class="row mt32 mb32" id="informations">
<div t-if="doc.client_order_ref" class="col-auto col-3 mw-100 mb-2">
<div t-if="doc.client_order_ref" class="col-auto col-3 mw-100 mb-2" name="informations_reference">
<strong>Your Reference:</strong>
<p class="m-0" t-field="doc.client_order_ref"/>
</div>
<div t-if="doc.date_order and doc.state not in ['draft','sent']" class="col-auto col-3 mw-100 mb-2">
<strong>Order Date:</strong>
<p class="m-0" t-field="doc.date_order"/>
</div>
<div t-if="doc.date_order and doc.state in ['draft','sent']" class="col-auto col-3 mw-100 mb-2">
<strong>Quotation Date:</strong>
<div t-if="doc.date_order" class="col-auto col-3 mw-100 mb-2" name="informations_date">
<strong t-if="doc.state in ['draft', 'sent']">Quotation Date:</strong>
<strong t-else="">Order Date:</strong>
<p class="m-0" t-field="doc.date_order" t-options='{"widget": "date"}'/>
</div>
<div t-if="doc.validity_date and doc.state in ['draft', 'sent']" class="col-auto col-3 mw-100 mb-2" name="expiration_date">
<div t-if="doc.validity_date and doc.state in ['draft', 'sent']"
class="col-auto col-3 mw-100 mb-2"
name="expiration_date">
<strong>Expiration:</strong>
<p class="m-0" t-field="doc.validity_date"/>
</div>
@@ -111,14 +112,14 @@
<span t-field="line.price_total" groups="account.group_show_line_subtotals_tax_included"/>
</td>
</t>
<t t-if="line.display_type == 'line_section'">
<t t-elif="line.display_type == 'line_section'">
<td name="td_section_line" colspan="99">
<span t-field="line.name"/>
</td>
<t t-set="current_section" t-value="line"/>
<t t-set="current_subtotal" t-value="0"/>
</t>
<t t-if="line.display_type == 'line_note'">
<t t-elif="line.display_type == 'line_note'">
<td name="td_note_line" colspan="99">
<span t-field="line.name"/>
</td>
@@ -170,7 +171,8 @@
<p t-if="not is_html_empty(doc.payment_term_id.note)">
<span t-field="doc.payment_term_id.note"/>
</p>
<p id="fiscal_position_remark" t-if="doc.fiscal_position_id and not is_html_empty(doc.fiscal_position_id.sudo().note)">
<p t-if="doc.fiscal_position_id and not is_html_empty(doc.fiscal_position_id.sudo().note)"
id="fiscal_position_remark">
<strong>Fiscal Position Remark:</strong>
<span t-field="doc.fiscal_position_id.sudo().note"/>
</p>
+5 -3
View File
@@ -53,9 +53,9 @@ class SaleReport(models.Model):
discount = fields.Float('Discount %', readonly=True)
discount_amount = fields.Float('Discount Amount', readonly=True)
campaign_id = fields.Many2one('utm.campaign', 'Campaign')
medium_id = fields.Many2one('utm.medium', 'Medium')
source_id = fields.Many2one('utm.source', 'Source')
campaign_id = fields.Many2one('utm.campaign', 'Campaign', readonly=True)
medium_id = fields.Many2one('utm.medium', 'Medium', readonly=True)
source_id = fields.Many2one('utm.source', 'Source', readonly=True)
order_id = fields.Many2one('sale.order', 'Order #', readonly=True)
@@ -158,6 +158,8 @@ class SaleReport(models.Model):
tools.drop_view_if_exists(self.env.cr, self._table)
self.env.cr.execute("""CREATE or REPLACE VIEW %s as (%s)""" % (self._table, self._query()))
# FIXME is this used somewhere ?
class SaleOrderReportProforma(models.AbstractModel):
_name = 'report.sale.report_saleproforma'
_description = 'Proforma Report'
+3 -3
View File
@@ -49,8 +49,8 @@
<search string="Sales Analysis">
<field name="date"/>
<filter string="Date" name="year" invisible="1" date="date" default_period="this_year"/>
<filter name="Quotations" string="Quotations" domain="[('state','in', ('draft', 'sent'))]"/>
<filter name="Sales" string="Sales Orders" domain="[('state','not in',('draft', 'cancel', 'sent'))]"/>
<filter string="Quotations" name="Quotations" domain="[('state','in', ('draft', 'sent'))]"/>
<filter string="Sales Orders" name="Sales" domain="[('state','not in',('draft', 'cancel', 'sent'))]"/>
<separator/>
<filter name="filter_date" date="date" default_period="this_month"/>
<separator/>
@@ -73,7 +73,7 @@
<filter string="Customer Industry" name="industry_id" context="{'group_by':'industry_id'}"/>
<filter string="Product" name="Product" context="{'group_by':'product_id'}"/>
<filter string="Product Category" name="Category" context="{'group_by':'categ_id'}"/>
<filter name="status" string="Status" context="{'group_by':'state'}"/>
<filter string="Status" name="status" context="{'group_by':'state'}"/>
<filter string="Company" name="company" groups="base.group_multi_company" context="{'group_by':'company_id'}"/>
<separator/>
<filter string="Order Date" name="date" context="{'group_by':'date'}"