How can remove header and footer from standard report in odoo 13 - odoo-13

I try to add this code:
<template id="web_external_layout_iherited"
inherit_id="web.external_layout_standard"
customize_show="True"
name="Automatic Header">
<xpath expr="//div[#class='header']"
position="replace">
</xpath>
</template>
but not work!!

This works for me:
<template id="web_external_layout_iherited" inherit_id="web.external_layout_standard">
<xpath expr="//div[#t-attf-class='header o_company_#{company.id}_layout']" position="replace">
</xpath>
<xpath expr="//div[#t-attf-class='footer o_standard_footer o_company_#{company.id}_layout']" position="replace">
</xpath>

If want to hide in specific report then pass one variable into the external layout template from report id as follows:
<template id="report_invoice_without_layout">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-set="lang" t-value="o.partner_id.lang"/>
<t t-set="print_with_payments" t-value="True"/>
**<t t-set="hide_header_footer" t-value="True"/>**
<t t-if="o._get_name_invoice_report() == 'l10n_gcc_invoice.arabic_english_invoice'" t-call="report_extension.arabic_english_invoice" t-lang="lang"/>
</t>
</t>
</template>
And then add t-if condition in header and footer to hide as follows:
<template id="external_layout_standard" inherit_id="l10n_gcc_invoice.external_layout_standard">
<xpath expr="//div[contains(#t-attf-class,'header')]" position="attributes">
**<attribute name="t-if">not hide_header_footer</attribute>**
</xpath>
<xpath expr="//ul[hasclass('list-inline')]" position="attributes">
**<attribute name="t-if">not hide_header_footer</attribute>**
</xpath>
</template>

Related

Inherit mail.activity on res.partner form

I cannot find the view which contain Activities on res.partner form view
I tried to inherit mail.mail_activity_type_view_form but it is not
<record id="mail_activity_view_inherit" model="ir.ui.view">
<field name="name">mail.activity.type.view.form.inherit</field>
<field name="model">mail.activity.type</field>
<field name="inherit_id" ref="mail.mail_activity_type_view_form" />
</record>
The XML-ID is:
mail.res_partner_view_form_inherit_mail
So, mail addon, res_partner_view_form_inherit_mail view.
The view is this one:
<record id="res_partner_view_form_inherit_mail" model="ir.ui.view">
<field name="name">res.partner.view.form.inherit.mail</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//field[#name='email']" position="replace">
<field name="is_blacklisted" invisible="1"/>
<label for="email" class="oe_inline"/>
<div class="o_row o_row_readonly">
<i class="fa fa-ban" style="color: red;" role="img" title="This email is blacklisted for mass mailing" aria-label="Blacklisted" attrs="{'invisible': [('is_blacklisted', '=', False)]}" groups="base.group_user"></i>
<field name="email" widget="email" context="{'gravatar_image': True}" attrs="{'required': [('user_ids','!=', [])]}" />
</div>
</xpath>
<xpath expr="//sheet" position="after">
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="activity_ids" widget="mail_activity"/>
<field name="message_ids" widget="mail_thread"/>
</div>
</xpath>
</field>
</record>
Let me try to help, you're trying to _inherit mail.activity view which is not possible by using xml, because it will not inherit from xml it is written in qweb, so for that you have to extend it like.
<t t-extend="idOfMailAvtivityQweb">
<t t-jquery='i[title="Mark as Todo"]' t-operation="before">
//Here in thread i will add something before title "Mark as Todo"
</t>
</t>

Odoo - hide a website menu base on website fields

I have a website menu defined by this code:
<record id="website_menu_apps" model="website.menu">
<field name="name">Apps</field>
<field name="url">/apps</field>
<field name="parent_id" ref="website.main_menu" />
<field name="sequence" type="int">19</field>
</record>
and a field defined by this code:
class Website(models.Model):
_inherit = 'website'
dedicate_apps_store = fields.Boolean(string='Dedicated Apps Store', default=True)
How can I make website menu disappear when user set website.dedicate_apps_store to False?
<template id="custom_layout" inherit_id="website.layout" name="custom layout">
<xpath expr="//ul[#id='top_menu']/t/t" position="attributes">
<attribute name="t-if">submenu.name != 'Apps' or website.dedicate_apps_store</attribute>
</xpath>
</template>
You inherit webiste.layout and set position="attributes" then you can write your condition inside the attribute tag.

add div tag in invoice configuration in odoo 12

can anyone please help me regarding invoice configuration in odoo 12.
i am trying to add div tag inside invoice configuration page but got no success.
<record id="res_config_inherit_view_form" model="ir.ui.view">
<field name="name">res.config.form.inherit</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="base.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[hasclass('app_settings_block')]" position="inside">
<h2>Notification</h2>
<div></div>
</xpath>
</field>
</record>
i have inherited transient model of res.config.settings in my py file.
i just changed reference from base.res_config_settings_view_form to account.res_config_settings_view_form and
in xpath i added data-key which is sat in the div tag of class named app_settings_block in account.res_config_settings_view_form xml,
in account.invoice it adds all the divs of invoice configuration.
<record id="res_config_inherit_view_form" model="ir.ui.view">
<field name="name">res.config.form.inherit</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="account.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[#data-key='account']" position="inside">
<h2>Notification</h2>
<div class="row mt16 o_settings_container" id="notification">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="unpaid_notification"/>
</div>
<div class="o_setting_right_pane">
<label for="unpaid_notification" string="Unpaid invoice reminder"/>
<div class="text-muted">
Auto send unpaid invoice emails to the partners
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>

Manage webservice from odoo

I am new to Odoo 11, I have created a module called 'coupon', for this module I have created a security group and a default user that is added to this group:
<record id="default_coupon_user" model="res.users">
<field name="login">couponuser</field>
<field name="password">couponuser</field>
<field name="password_crypt">couponuser</field>
<field name="name">Default User Coupon</field>
<field name="display_name">Default Coupon User</field>
<field name="customer">False</field>
</record>
<record id="coupon_managers_group" model="res.groups" >
<field name="name">Coupon Managers Group</field>
<field name="comment">Coupon Managers Group that will be used in the Coupon microservice.</field>
<field name="category_id" ref="base.module_category_coupon"/>
<field name="users" eval="[(4, ref('coupon.default_coupon_user'))]"/>
</record>
My module depends on website because I need to create a website, for that site I created an index page:
<!-- === Coupon Page === -->
<template id="index_template">
<t t-call="website.layout">
<div id="wrap">
<div class="container">
<h1>Coupons</h1>
<a href="/payum_coupon/create" class="btn btn-primary btn-lg">
Add
</a>
<p>paginas:
<t t-esc="coupons['pg']"/>
</p>
<p>total:
<t t-esc="coupons['total']"/>
</p>
<ul class="clientes">
<t t-foreach="coupons['items']" t-as="i">
<li>
<a t-attf-href="/payum_coupon/{{i['email']}}">
<t t-esc="i['firstName']"/>
<t t-esc="i['lastName']"/>
-
<t t-esc="i['email']"/>
</a>
</li>
</t>
</ul>
</div>
</div>
</t>
</template>
<record id="coupon_page" model="website.page">
<field name="name">Index Coupon page</field>
<field name="website_published">True</field>
<field name="url">/coupon</field>
<field name="view_id" ref="index_template"/>
<field name="groups">coupon.coupon_managers_group</field>
</record>
and website.menu with the following code:
<record id="coupon_page_link" model="website.menu">
<field name="name">Coupon</field>
<field name="page_id" ref="coupon_page"/>
<field name="parent_id" ref="website.main_menu"/>
</record>
the python code in the controller that will be executed by said menu is this:
#http.route('/coupon', auth='user', website=True)
def index(self, **kw):
#<<my code here>>
I need several things:
when the 'index' page is displayed if the user in session is not in the 'coupon.coupon_managers_group' group then the menu is not shown
And that when the controller method '/coupon' is executed it is verified that the user in session is in the group 'coupon.coupon_managers_group'
This site has a particularity and that my module does not have models, since it is to manage the data of an api rest application, that is, in odoo I have to create the views of list, create, etc., but the data is written and they are read from a remote web service.
I have searched many sites on the internet but I have not found anything, as they always refer to local cases in odoo.
To hide the website menu based on the user group you could do something like this:
from odoo import api, models
class Menu(models.Model):
_inherit = "website.menu"
#api.one
def _compute_visible(self):
if self.clean_url() == '/coupon' and not self.env.user.has_group('coupon.coupon_managers_group'):
return False
return super(Menu, self)._compute_visible()
In the controller of the route /coupon you could check the user group like:
request.env.user.has_group('coupon.coupon_managers_group')

Odoo 11 Qweb Report empty page

I am trying to create a qweb report for Odoo 11 but without any success. 0 byte pdf I am getting, I edit the report to qweb-html and then only white page. Please help me to solve the issue. Below is my code. I am a beginner and trying to create this report after reading different posts and different modules.
Below is my code in 4 seprate files.
1st file
from odoo import models, fields, api
class TrueReportFields(models.TransientModel):
_name = 'true.report'
#api.multi
def print_true_report(self):
sales = self.env['sale.order'].sudo().search(
[('state', 'in', ('sale', 'done'))])
total_sale = total_cost = 0
for sale in sales:
total_sale += sale.amount_total
for lines in sale.order_line:
total_cost += lines.product_id.standard_price * lines.product_uom_qty
purchases = self.env['purchase.order'].sudo().search(
[('state', 'not in', ('draft', 'canceled'))])
total_purchase = 0
for purchase in purchases:
total_purchase += purchase.amount_total
pos_sales = self.env['pos.order'].sudo().search(
[('state', 'not in', ['cancel', 'draft'])])
total_pos_sale = total_pos_cost = 0
for pos in pos_sales:
total_pos_sale += pos.amount_total
for posl in pos.lines:
total_pos_cost += posl.product_id.standard_price * posl.qty
datas = {
'ids': self,
'model': 'true.report',
'total_sale': total_sale,
'total_cost': total_cost,
'total_purchase': total_purchase,
'total_pos_sale': total_pos_sale,
'total_pos_cost': total_pos_cost
}
return self.env.ref('true_report.action_true_report').report_action(self, data=datas)
2nd file
from odoo import api, models
class TrueReport(models.AbstractModel):
_name = 'report.true_report.report_details'
#api.model
def get_report_values(self, docids, data=None):
return {
'doc_ids': data.get('ids'),
'doc_model': data.get('model'),
'total_sale': data['total_sale'],
'total_cost': data['total_cost'],
'total_purchase': data['total_purchase'],
'total_pos_sale': data['total_pos_sale'],
'total_pos_cost': data['total_pos_cost']
}
xml views
<odoo>
<data>
<record id="view_true_report" model="ir.ui.view">
<field name="name">product.detail.form</field>
<field name="model">true.report</field>
<field name="arch" type="xml">
<form string="True Details">
<!--<group>
<group>
<field name="start_date"/>
</group>
<group>
<field name="end_date"/>
</group>
</group>-->
<footer>
<button string='Print' name="print_true_report" type="object" default_focus="1"
class="oe_highlight"/>
<button string="Cancel" class="btn-default" special="cancel"/>
</footer>
</form>
</field>
</record>
<record id="open_true_report_action" model="ir.actions.act_window">
<field name="name">Top Sold Products</field>
<field name="res_model">true.report</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="view_id" ref="view_true_report"/>
</record>
<menuitem
id="menu_true_report"
name="True Report"
parent="sale.menu_sale_report"
sequence="4"
action="true_report.open_true_report_action"/>
<report
id="action_true_report"
string="True PDF Report"
model="true.report"
report_type="qweb-pdf"
file="true_report.report_details"
name="true_report.report_details"
/>
</data>
</odoo>
xml templates
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="report_details_documents">
<t t-call="web.html_container">
<t t-set="o" t-value="doc.with_context({'lang':doc.partner_id.lang})" />
<!--<t t-foreach="docs" t-as="o">-->
<!--<t t-foreach="docs" t-as="o">-->
<t t-call="web.external_layout">
<div class="page">
<div class="row">
<div class="oe_structure"/>
<div style="text-align: center;">
<span style="font-size: 25px;">True Report Details</span>
</div>
<!--<div class="row mt32 mb32">
<div class="col-xs-4">
<p>
<t>
<strong>From Date :</strong>
<span t-esc="o.start_date"/>
<br/>
</t>
<t>
<strong>To Date :</strong>
<span t-esc="o.end_date"/>
</t>
</p>
</div>
</div>-->
<table class="table table-condensed">
<thead>
<tr>
<th>Total Sales</th>
<th class="text-right">Total Cost</th>
<th>Total Purchase</th>
<th>Pos Sale</th>
<th>Pos Cost</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<span t-esc="o.total_sale"/>
</td>
<!-- <td class="text-right" style="white-space: text-nowrap;">
<span t-esc="o.total_cost"/>
</td>
<td>
<span t-esc="o.total_purchase"/>
</td>
<td>
<span t-esc="o.total_pos_sale"/>
</td>
<td>
<span t-esc="o.total_pos_cost"/>
</td>-->
</tr>
</tbody>
</table>
</div>
</div>
</t>
<!--</t>-->
</t>
</template>
<template id="report_details">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="true_report.report_details_documents" t-lang="o.company_id.partner_id.lang"/>
</t>
</t>
</template>
</odoo>
Please help me to solve the issue. I will be a great help.
Thanks in advance.
you can try
<t t-call="web.external_layout"> instead of <t t-call="web.html_container">

Resources