[IMP] account: onboarding invoice report layout

Impacted modules : base, base_setup,
account, report, and base_vat

The purpose is here to ease the creation
of the first invoice. To do so, we need to
ease the configuration of VAT, company data,
and report layouting.

This commits brings
- better labelling for TIN, VAT and Tax Id
for partner and companies (form view, ...)
- change settings for footer of report : allow
to use custom or standart footer, and display them
in settings view.
- always display TIN in standart report footer
- remove (demo) data of main company to not set
company logo on reports

Also, a message is display on the report when the
data company are not configured yet.

The invoice report is now regenerated each time
the user want to print it.
This commit is contained in:
Pratima Gupta
2016-12-23 09:29:09 +01:00
committed by Jérome Maes
parent 4c04a723fb
commit dccfdb0ddb
17 changed files with 58 additions and 46 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
<odoo>
<data>
<template id="external_layout_footer" inherit_id="report.external_layout_footer">
<template id="external_layout_footer" inherit_id="report.external_layout_footer_default">
<xpath expr="//ul[@name='financial_infos']" position="inside">
<t t-if="not company.custom_footer">
<t t-set="is_first" t-value="True"/>
@@ -349,7 +349,7 @@
<form string="Invoice">
<header>
<button name="action_invoice_sent" type="object" string="Send by Email" attrs="{'invisible':['|',('sent','=',True), ('state', 'not in', ('open', 'proforma', 'proforma2'))]}" class="oe_highlight" groups="base.group_user"/>
<button name="invoice_print" string="Print" type="object" attrs="{'invisible':['|',('sent','=',True), ('state', '!=', 'open')]}" class="oe_highlight" groups="base.group_user"/>
<button name="invoice_print" string="Print Invoice" type="object" attrs="{'invisible':['|',('sent','=',True), ('state', '!=', 'open')]}" class="oe_highlight" groups="base.group_user"/>
<button name="action_invoice_sent" type="object" string="Send by Email" attrs="{'invisible':['|',('sent','=',False), ('state', 'not in', ('open', 'proforma', 'proforma2'))]}" groups="base.group_user"/>
<button name="invoice_print" string="Print Invoice" type="object" attrs="{'invisible':['|',('sent','=',False), ('state', '!=', 'open')]}" groups="base.group_user"/>
<button name="%(action_account_invoice_payment)d" type="action" states="open" string="Register Payment" groups="account.group_account_invoice" class="oe_highlight"/>
+1 -2
View File
@@ -9,9 +9,8 @@
report_type="qweb-pdf"
name="account.report_invoice"
file="account.report_invoice"
attachment_use="True"
attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
/>
<record id="account_invoices" model="ir.actions.report.xml">
<field name="print_report_name">(object.type == 'out_invoice' and object.state == 'draft' and 'Draft Invoice' or
object.type == 'out_invoice' and object.state in ('open','paid') and 'Invoice'+'-'+(object.number) or
+1 -1
View File
@@ -9,7 +9,7 @@
<div name="invoice_address" class="col-xs-5 col-xs-offset-7">
<address t-field="o.partner_id"
t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}' />
<span t-if="o.partner_id.vat">TIN: <span t-field="o.partner_id.vat"/></span>
<span t-if="o.partner_id.vat">VAT: <span t-field="o.partner_id.vat"/></span>
</div>
</div>
+2 -3
View File
@@ -35,9 +35,8 @@ class BaseConfigSettings(models.TransientModel):
help="Allows to work in a multi currency environment")
# Report config from base/res/res_company.py
custom_footer = fields.Boolean(related="company_id.custom_footer", string="Custom footer *", help="Check this to define the report footer manually. Otherwise it will be filled in automatically.")
rml_footer = fields.Text(related="company_id.rml_footer", string='Custom Report Footer *', help="Footer text displayed at the bottom of all reports.")
rml_footer_readonly = fields.Text(related='rml_footer', string='Report Footer *', readonly=True)
custom_footer = fields.Selection(related="company_id.custom_footer")
rml_footer = fields.Text(related="company_id.rml_footer", string='Custom Report Footer', help="Footer text displayed at the bottom of all reports.")
rml_paper_format = fields.Selection(related="company_id.rml_paper_format", string="Paper Format *", required=True)
font = fields.Many2one(related='company_id.font', string="Font *", help="Set the font into the report header, it will be used as default font in the RML reports of the user company")
rml_header = fields.Text(related="company_id.rml_header", string="RML Header *")
+3 -7
View File
@@ -113,15 +113,11 @@
<group string="Report Configuration" name="report">
<label for="custom_footer"/>
<div>
<field name="custom_footer" class="oe_inline"/>
<field name="custom_footer" class="oe_inline" widget="radio"/>
</div>
<label for="rml_footer"/>
<label for="rml_footer" attrs="{'invisible':[('custom_footer','=', False)]}"/>
<div>
<field name="rml_footer" class="oe_inline"/>
</div>
<label for="rml_footer_readonly"/>
<div>
<field name="rml_footer_readonly" class="oe_inline"/>
<field name="rml_footer" class="oe_inline" attrs="{'invisible':[('custom_footer','=', False)]}"/>
</div>
</group>
<group string="RML Report Configuration" groups="base.group_no_one">
+4 -1
View File
@@ -5,9 +5,12 @@
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml">
<field name="currency_id" position="after">
<field name="parent_id" position="after">
<field name="vat_check_vies" />
</field>
<xpath expr="//field[@name='vat']" position="attributes">
<attribute name="string">VAT</attribute>
</xpath>
</field>
</record>
</odoo>
+4 -7
View File
@@ -3,14 +3,11 @@
<record id="view_partner_form" model="ir.ui.view">
<field name="name">res.partner.vat.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="account.view_partner_property_form"/>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<field name="property_account_position_id" position="after">
<label for="vat"/>
<div name="vat_info" class="o_row">
<field name="vat" placeholder="e.g. BE0477472701"/>
</div>
</field>
<xpath expr="//field[@name='vat']" position="attributes">
<attribute name="string">VAT</attribute>
</xpath>
</field>
</record>
</odoo>
@@ -8,6 +8,7 @@ class BaseConfigSettings(models.TransientModel):
_inherit = 'base.config.settings'
paperformat_id = fields.Many2one(related="company_id.paperformat_id", string='Paper format *')
report_footer_default = fields.Html(related="company_id.report_footer_default")
def edit_external_header(self):
return self.company_id.edit_external_header()
+8
View File
@@ -7,6 +7,14 @@ class ResCompany(models.Model):
_inherit = 'res.company'
paperformat_id = fields.Many2one('report.paperformat', 'Paper format')
report_footer_default = fields.Html('Standard Report Foorter', compute='_compute_report_footer_default', readonly=True)
@api.multi
def _compute_report_footer_default(self):
for company in self:
company.report_footer_default = self.env['ir.ui.view'].render_template('report.external_layout_footer_default', {
'company': company,
})
@api.model_cr
def init(self):
@@ -6,7 +6,7 @@
<field name="model">base.config.settings</field>
<field name="arch" type="xml">
<data>
<group name="report" position="inside">
<xpath expr="//group[@name='report']" position="inside">
<label for="paperformat_id"/>
<div>
<field name="paperformat_id" class="oe_inline"/>
@@ -16,7 +16,10 @@
<button name="edit_external_footer" string="Edit external footer" type="object" class="oe_link"/>
<button name="edit_internal_header" string="Edit internal header" type="object" class="oe_link"/>
</div>
</group>
</xpath>
<xpath expr="//label[@for='rml_footer']" position="before">
<field name="report_footer_default" class="oe_inline"/>
</xpath>
</data>
</field>
</record>
+21 -8
View File
@@ -100,25 +100,30 @@
</div>
<div class="col-xs-9 text-right" style="margin-top:20px;" t-field="company.rml_header1"/>
</div>
<div class="row zero_min_height">
<div t-if="company.logo or company.rml_header1" class="row zero_min_height">
<div class="col-xs-12">
<div style="border-bottom: 1px solid black;"></div>
</div>
</div>
<div class="row">
<div class="col-xs-6" name="company_address">
<t t-if="company.street and company.zip">
<span t-field="company.partner_id"
t-field-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}'
style="border-bottom: 1px solid black; display:inline-block;"/>
</t>
<t t-if="not (company.street and company.zip)">
<p name="report_company_data_warning">
<i class="fa fa-warning"/> Company address is not defined. Please, got to <i>Settings > General Settings > configure your company data </i>, to set the missing informations.
</p>
</t>
</div>
</div>
</div>
</template>
<template id="external_layout_footer">
<div class="footer">
<div class="text-center" style="border-top: 1px solid black;">
<ul t-if="not company.custom_footer" class="list-inline">
<template id="external_layout_footer_default">
<ul class="list-inline">
<t t-set="company" t-value="company.sudo()"/>
<li t-if="company.phone">Phone: <span t-field="company.phone"/></li>
@@ -132,12 +137,20 @@
<li t-if="company.website">Website: <span t-field="company.website"/></li>
</ul>
<ul t-if="not company.custom_footer" class="list-inline" name="financial_infos">
<ul class="list-inline" name="financial_infos">
<li t-if="company.vat">TIN: <span t-field="company.vat"/></li>
</ul>
</template>
<template id="external_layout_footer">
<div class="footer">
<div class="text-center" style="border-top: 1px solid black;">
<t t-if="not company.custom_footer">
<t t-call="report.external_layout_footer_default"/>
</t>
<t t-if="company.custom_footer">
<span t-raw="company.rml_footer"/>
<span t-raw="company.rml_footer" style="white-space: pre-wrap;"/>
</t>
<ul class="list-inline">
@@ -147,7 +160,7 @@
<li><span class="topage"/></li>
</ul>
</div>
</div>
</div>
</template>
<template id="internal_layout">
-3
View File
@@ -9,9 +9,6 @@
<field name="social_linkedin">https://www.linkedin.com/company/odoo</field>
</record>
<record id="base.main_company" model="res.company">
<field name="rml_header1">Great Product for Great People</field>
</record>
</data>
<data noupdate="1">
-2
View File
@@ -17,7 +17,6 @@
<record id="main_partner" model="res.partner" context="{'default_is_company': True}">
<field name="name">My Company</field>
<field name="company_id" eval="None"/>
<field name="image" type="base64" file="base/static/img/main_partner-image.png"/>
<field name="customer" eval="False"/>
<field name="is_company" eval="True"/>
<field name="street"></field>
@@ -32,7 +31,6 @@
<record id="main_company" model="res.company">
<field name="name">My Company</field>
<field name="partner_id" ref="main_partner"/>
<field name="rml_header1">My Company Tagline</field>
<field name="currency_id" ref="base.EUR"/>
</record>
-5
View File
@@ -22,12 +22,7 @@
<record id="main_partner" model="res.partner">
<field name="name">YourCompany</field>
<field name="company_name">YourCompany</field>
<field name="street">1725 Slough Ave.</field>
<field name="city">Scranton</field>
<field name="zip">18540</field>
<field name='country_id' ref='base.us'/>
<field name='state_id' ref='state_us_39'/>
<field name="phone">+1 555 123 8069</field>
<field name="email">info@yourcompany.example.com</field>
<field name="website">www.example.com</field>
+5 -3
View File
@@ -126,8 +126,10 @@ class Company(models.Model):
rml_header2 = fields.Text(string='RML Internal Header', required=True, default=_header2)
rml_header3 = fields.Text(string='RML Internal Header for Landscape Reports', required=True, default=_header3)
rml_footer = fields.Text(string='Custom Report Footer', translate=True, help="Footer text displayed at the bottom of all reports.")
rml_footer_readonly = fields.Text(related='rml_footer', string='Report Footer', readonly=True)
custom_footer = fields.Boolean(help="Check this to define the report footer manually. Otherwise it will be filled in automatically.")
custom_footer = fields.Selection([
(0, 'Use standard footer'),
(1, 'Use custom footer')
], "Report Footer", default=0, help="""Set to 'custom' this to define the report footer manually. Otherwise it will be filled in automatically.""")
font = fields.Many2one('res.font', string="Font", default=lambda self: self._get_font(),
domain=[('mode', 'in', ('Normal', 'Regular', 'all', 'Book'))],
help="Set the font into the report header, it will be used as default font in the RML reports of the user company")
@@ -149,7 +151,7 @@ class Company(models.Model):
phone = fields.Char(related='partner_id.phone', store=True)
fax = fields.Char(compute='_compute_address', inverse='_inverse_fax')
website = fields.Char(related='partner_id.website')
vat = fields.Char(related='partner_id.vat', string="Tax ID")
vat = fields.Char(related='partner_id.vat', string="TIN")
company_registry = fields.Char()
rml_paper_format = fields.Selection([('a4', 'A4'), ('us_letter', 'US Letter')], string="Paper Format", required=True, default='a4', oldname='paper_format')
sequence = fields.Integer(help='Used to order Companies in the company switcher', default=10)
@@ -183,6 +183,7 @@
<field name="country_id" placeholder="Country" class="o_address_country" options='{"no_open": True, "no_create": True}'
attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/>
</div>
<field name="vat" placeholder="e.g. BE0477472701"/>
<field name="website" widget="url" placeholder="e.g. www.odoo.com"/>
<field name="category_id" widget="many2many_tags" placeholder="Tags..." options="{'no_create_edit': True}"/>
</group>