No results when i try to create custum dashboard in odoo - odoo

No results when i try to create custum dashboard in odoo
I create a new module for custom dashboard in odoo following this tutorial : link
but always i found the same result is false, here is my code :
The result :
** model.py : **
create a dashboard model (kanban.count) and add some filed
class KanbanCount(models.Model)
_name = "kanban.count"
color = fields.Integer(string='Color Index')
name = fields.Char(string="Name")
#api.one
def _get_count(self):
quotations_count = self.env['sale.order'].search(
[('sate', '=', 'draft')])
orders_count = self.env['sale.order'].search(
[('sate', '=', 'sales_order')])
orders_done_count = self.env['sale.order'].search(
[('sate', '=', 'done')])
self.orders_count = len(orders_count)
self.quotations_count = len(quotations_count)
self.orders_done_count = len(orders_done_count)
orders_count = fields.Integer(compute = '_get_count')
quotations_count = fields.Integer(compute= '_get_count')
orders_done_count = fields.Integer(compute= '_get_count')
The Kanban View :
Create a kanban view of this above-created model
<record model="ir.ui.view" id="count_kanban_form_view">
<field name="name">Count form</field>
<field name="model">kanban.count</field>
<field name="arch" type="xml">
<kanban
class="oe_background_grey o_kanban_dashboard o_salesteam_kanban o_project_kanban "
create="0">
<field name="color"/>
<field name="name"/>
<templates>
<span t-name="kanban-box">
<div t-attf-class="#{kanban_color(record.color.raw_value)} ">
<div class="o_project_kanban_manage">
<a class="o_kanban_manage_toggle_button" href="#">More
<i class="fa fa-caret-down"/>
</a>
</div>
<div class="o_project_kanban_main" >
<div class="o_kanban_card_content o_visible">
<div class="o_kanban_primary_left" >
<div class="">
<center>
<span>
<span t-field="record.name.value"/>
</span>
</center>
</div>
<div>
<center>
<button
class="btn btn-primary"
type="action"
name="dashboard_sales_action_id"
string="Quotations">Quotations</button>
<button
class="btn btn-primary"
type="action"
name="dashboard_sales_order_action_id" >Sales order</button>
<h3>Custom Dashboard for Sales</h3>
</center>
</div>
</div>
</div>
<div class="o_kanban_card_manage_pane o_invisible">
<div class="col-xs-6 o_kanban_card_manage_section o_kanban_manage_view">
<div class="o_kanban_card_manage_title">
<span>View</span>
</div>
<div>
<a type="action">Quotations</a>
</div>
<div>
<a type="action">Sales Order</a>
</div>
<div>
<a type="action">Done</a>
</div>
<div>
<a type="action">Cancel</a>
</div>
</div>
<div t-if="widget.editable" class="o_project_kanban_colorpicker" >
<ul class="oe_kanban_colorpicker" data-field="color"/>
</div>
</div>
</div>
<div class="o_project_kanban_boxes" >
<a class="o_project_kanban_box" name="" type="action">
<span class="o_value" style="overflow:visible !important">
<span t-esc="record.quotations_count.value"/>
</span>
<span class="o_label" style="overflow:visible !important">
Quotations
</span>
</a>
<a class="o_project_kanban_box" name="" type="action">
<span class="o_value" style="overflow:visible !important">
<span t-esc="record.orders_count.value"/>
</span>
<span class="o_label" style="overflow:visible !important">
Sales Orders
</span>
</a>
<a class="o_project_kanban_box" name="" type="action">
<span class="o_value" style="overflow:visible !important">
<span t-esc="record.order_done_count.value"/>
</span>
<span class="o_label" style="overflow:visible !important">
Done
</span>
</a>
</div>
</div>
</span>
</templates>
</kanban>
</field>
</record>

<record id="kanabn_count_dashbord" model="kanban.count">
<field name="name">Kanban Dashboard</field>
</record>

Remove the "span" tag with a "t" tag.
For example:
<span t-name="kanban-box">
Simply replace above line as(closing tags also):
<t t-name="kanban-box">
try, i hope it's will be work
Thanks

Related

Correct bootstrap3 way to give padding on grid

I have four inputs in the same row and one of the input is conditionally visible by clicking "Click" button.
So if all four inputs are visible, the inputs datepicker1 and datepicker2 are sticked on the inputs above.
What is the correct bootstrap way to arrange and beautify the distances between the inputs?.
Gutters are not available on bootstrap 3.
<div class="col-md-3">
<select class="lookup-type-select form-control" name="created_lookup_type_1">
<option value="range">Range</option>
<option value="range__exclude">Exclude Range</option>
</select>
</div>
<div class="lookup-value">
<div class="col-md-3">
<select name="created__1_0" class="filter-input shortcut form-control" id="id_created__1_0">
</select>
</div>
<div class="col-md-8 row custom" style="display: inline;">
<div class="col-md-6">
<div class="datetimepicker input-group start-date date" data-date-format="YYYY-MM-DD HH:mm:ss">
<input class="filter-input form-control" name="created__1_1" value="" type="text" id="datepicker1" placeholder="From">
<span class="input-group-addon">
<span class="glyphicon-calendar glyphicon"></span>
</span>
</div>
</div>
<div class="col-md-6">
<div class="datetimepicker input-group end-date date" data-date-format="YYYY-MM-DD HH:mm:ss">
<input class="filter-input form-control" name="created__1_2" value="" type="text" id="datepicker2" placeholder="To">
<span class="input-group-addon">
<span class="glyphicon-calendar glyphicon"></span>
</span>
</div>
</div>
</div>
<div class="col-md-3 row month_only" style="display: none;">
<div>
<div class="datetimepicker input-group start-date date month_only" style="display: none;">
<input class="filter-input form-control" name="created__1_3" value="" type="text" id="id_created__1_3" placeholder="Month">
<span class="input-group-addon">
<span class="glyphicon-calendar glyphicon"></span>
</span>
</div>
</div>
</div>
</div>
<button type="button" class="btn remove-button">
<span class="glyphicon glyphicon-remove"></span>
</button>
<button onclick="myFunction()">Ckick</button>
<script>
function myFunction() {
if (document.getElementById('id_created__1_0').style.display != "none") {
document.getElementById("id_created__1_0").style.display = "none";
} else {
document.getElementById("id_created__1_0").style.display = "inline";
}
}
</script>
Jsfiddle example
Should be like the following pic

How to use Form in FOREACH with ASP.NET

The problem is when I use the form inside ModalDialog and put Modal in a loop. If I have several records.
The problem is when I use the form inside ModalDialog and put Modal in a loop. If I have several records.
When I select each record, only the first record information is sent. Please check and help
When I select each record, only the first record information is sent. Please check and help
#{ var count = 0;}
#foreach (var item in Model.ProjectViewModels)
{
<tr>
#if (item.PersonState == 1)
{
<td style="width:35px; color:black;">
<span class="badge badge-success" style="width:50px; border-radius:15px;">
فعال
</span>
</td>
}
else
{
<td style="width:35px; color:black;">
<span class="badge badge-danger" style="width:50px; border-radius:15px;">
غیرفعال
</span>
</td>
}
<td>#item.PersonName #item.Family</td>
<td>#item.PersonCode</td>
<td>#item.projectName</td>
<td style="width:300px">
#if (item.PersonState == 1)
{
<div class="text-center row d-flex justify-content-between">
<div style="margin-top:3px">
<a class="fa fa-edit" style="font-size:28px;color:darkblue" asp-controller="Home" asp-action="updatePerson" asp-route-id="#item.PersonID"></a>
</div>
<form asp-controller="Home" asp-action="RemovePerson" asp-route-id="#item.PersonID" method="post">
<a value="submit" class="fa fa-trash-o ajax_delete1 " style="font-size: 27px; color: red; cursor: pointer;"> </a>
</form>
<div>
<a class="btn btn-sm btn-outline-primary" asp-controller="Home" asp-action="detailsPerson" asp-route-id="#item.PersonID">جزئیات</a>
<a class="btn btn-sm btn-outline-secondary" asp-controller="Report" asp-action="SingelGhrardad" asp-route-id="#item.PersonID">قرارداد</a>
<a class="btn btn-sm btn-outline-danger" data-toggle="modal" data-target="#myModal#(count)">ترک کار</a>
<!-- The Modal -->
<div class="modal fade" id="myModal#(count)">
<div class="modal-dialog ">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">ثبت تاریخ ترک کار پرسنل</h4>
</div>
<!-- Modal body -->
<div class="modal-body">
<form asp-controller="Home" asp-action="PersonTarkKar" asp-route-id="#item.PersonID" asp-route-PersonNewState="0" method="post">
<div class="row">
<div class="col-md-5 col-xs-12">
<label>تاریخ ترک کار</label>
<div class="input-group" style="padding-left:9px; padding-right:9px;">
<div class="input-group-addon"
style="border:1px solid gray; padding:6px">
<span> <i class="right fa fa-calendar"></i></span>
</div>
<input id="calender1" name="calender1" type="text" required autocomplete="off" class="form-control" />
</div>
</div>
</div>
<button class="btn btn-dark mt-5" type="submit">ثبت تاریخ</button>
</form>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">بستن</button>
</div>
</div>
</div>
</div>
#{count++;}
</div>
</div>
}
#section Scripts{
<script>
$('#calender1').MdPersianDateTimePicker({
targetTextSelector: '#calender1',
});
</script>
}
When I select each record, only the first record information is sent. Please check and help
That is because your modal ids are always the same.
You need change your view like below:
#{ var i = 0; }
#foreach (var item in Model.ProjectViewModels)
{
<tr>
//...
<td style="width:300px">
#if (item.PersonState == 1)
{ //change here......
<a class="btn btn-sm btn-outline-danger"
data-toggle="modal" data-target="#myModal_#i">ترک کار</a>
<!-- The Modal -->
//change here...........
<div class="modal fade" id="myModal_#i">
<div class="modal-dialog ">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">ثبت تاریخ ترک کار پرسنل</h4>
</div>
<!-- Modal body -->
<div class="modal-body">
//...
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">بستن</button>
</div>
</div>
</div>
</div>
}
</td>
</tr>
i++; //add this.......
}
Update:
You need loop the js like below:
#section Scripts
{
<link href="/lib/md.bootstrappersiandatetimepicker/dist/jquery.md.bootstrap.datetimepicker.style.css" rel="stylesheet" />
<script src="/lib/md.bootstrappersiandatetimepicker/dist/jquery.md.bootstrap.datetimepicker.js"></script>
<script>
for (j = 0; j < #Model.ProjectViewModels.Count(); j++)
{
$('#calender_'+j).MdPersianDateTimePicker({
targetTextSelector: '#calender_'+ j,
});
}
</script>
}
Change:
<input id="calender" name="calender1" type="text" required autocomplete="off" class="form-control" />
To:
<input id="calender_#i" name="calender1" type="text" required autocomplete="off" class="form-control" />

How to make a QWeb report widget?

I'm trying to create a simple Qweb widget. My code is like this
<template id="contact_name">
<address t-ignore="true" class="mb0" itemscope="itemscope" itemtype="http://schema.org/Signature">
<div t-att-class="'name' not in fields and 'css_non_editable_mode_hidden'">
<span itemprop="name" t-esc="name"/>
</div>
</address>
</template>
Then I called the widget like this
<address t-field="o.partner_id" t-field-options='{"widget": "contact_name", "fields": ["name"], "no_marker": true}' />
It did not print out name but print out the object res.partner(703,)
How is it to print the name? Is it not enough to just to use <span itemprop="name" t-esc="name"/>?
<div class="page">
<div class="oe_structure"/>
<div class="col-xs-6 pull-left">
<h2 style="color:red">
<span>Plan Order :
<span style="color:Red" t-field='doc.name'/>
</span>
</h2>
</div>
<div colspan="4" class="col-xs-6 text-right">
<span>
<img t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('Code128', doc.name, 500, 50)"
style="width:100%;height:50px"/>
</span>
</div>

How to hide "Automatic reconciliation" button from Qweb in Odoo10?

Go to Accounting => Accounting Dashboard => click on Reconcile button
We get below Qweb view.
In that Qweb view, How can we hide "Automatic reconciliation" button ?
I have tried following but didn't work:
<templates xml:space="preserve">
<!-- 1st try -->
<t t-name="automatic_reconciliation_1st" t-extend="reconciliation">
<t t-jquery=".btn" t-operation="replace"></t>
</t>
<!-- 2nd try -->
<t t-name="automatic_reconciliation_2nd" t-extend="reconciliation">
<t t-jquery=".js_automatic_reconciliation" t-operation="replace"></t>
</t>
<!-- 3rd try -->
<t t-name="automatic_reconciliation_3rd" t-extend="reconciliation">
<t t-jquery=".oe_form_sheet oe_form_sheet_width o_form_sheet" t-operation="replace">
<div class="oe_form_sheet oe_form_sheet_width o_form_sheet">
<h1><t t-esc="title"/></h1>
<div t-if="! hide_progress" class="progress progress-striped">
<div class="progress-text"><span class="valuenow">0</span> / <span class="valuemax"><t t-esc="total_lines"/></span></div>
<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" t-att-aria-valuemax="total_lines" style="width: 0%;">
</div>
</div>
<div class="oe_clear o_clear"></div>
<div class="notification_area"></div>
<div class="interface_options oe_form o_form"></div>
<div class="reconciliation_lines_container"></div>
<div class="show_more_container"><button class="show_more btn btn-default btn-sm">Show more... (<span class="num_items_remaining"></span> remaining)</button></div>
<p class="o_protip text-muted" align="right">Tip: Hit CTRL-Enter to reconcile all the balanced items in the sheet.</p>
</div>
</t>
</t>
</templates>
Try this .
<t t-name="account.reconciliation">
<div class="o_form_view"><div class="oe_form_sheetbg o_form_sheet_bg"><div class="oe_form_sheet oe_form_sheet_width o_form_sheet">
<h1><t t-esc="title"/></h1>
<div t-if="! hide_progress" class="progress progress-striped">
<div class="progress-text"><span class="valuenow">0</span> / <span class="valuemax"><t t-esc="total_lines"/></span></div>
<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" t-att-aria-valuemax="total_lines" style="width: 0%;">
</div>
</div>
<div class="oe_clear clearer"></div>
<div class="notification_area"></div>
<div class="interface_options oe_form o_form"></div>
<div class="reconciliation_lines_container"></div>
<div class="show_more_container"><button class="show_more btn btn-default btn-sm">Show more... (<span class="num_items_remaining"></span> remaining)</button></div>
<p class="o_protip text-muted" align="right">Tip: Hit CTRL-Enter to reconcile all the balanced items in the sheet.</p>
</div></div></div>
</t>
Alternative solution:
.js_automatic_reconciliation { display:none; }

How to display the company header only on the first page?

i want to show the company reportheader only on the first page.I have now beautifull qweb report in PDF. But if my reports (sale order, for example) have more than one page, the header is on EACH page.
How to put company header only on the first page?
Thanks,
Header is only displayed once, in first page.report. The others are empty
<template id="report_quotation_header" inherit_id="report.external_layout_header">
<xpath expr="//div[#class='header']" position="replace">
<div class="header">
<t t-set="data_report_margin_top" t-value="12"/>
<t t-set="data_report_header_spacing" t-value="9"/>
<t t-set="data_report_dpi" t-value="110"/>
<div class="row">
<div class="col-xs-3" name="company_address">
<div t-field="company.partner_id"
t-field-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}'
style="border-bottom: 1px solid black;"/>
</div>
</div>
</div>
</xpath>
</template> <!-- end teamplate header-->
Call your header inside page div. This will print header only on first page of qweb report in odoo
in odoo 10 I have done this as follows:
<template id="custom_report_header" inherit_id="report.external_layout_header" primary="True">
<xpath expr="//div[#class='header']" position="replace">
<div class="header">
<div class="row">
<div class="col-xs-3">
<img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % company.logo" style="max-height: 45px;"/>
</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 class="col-xs-12">
<div style="border-bottom: 1px solid black;"></div>
</div>
</div>
</div>
</xpath>
</template>
<template id="your_custom_header_id" inherit_id="report.external_layout" primary="True">
<xpath expr="//t[#t-call='report.external_layout_header']" position="replace">
<t t-call="your_module_name.custom_report_header" />
</xpath>
</template>
<template id="your_report_name"
<t t-call="report.html_container">
<div class="page">
<t t-call="your_module_name.your_custom_header_id">
</t>
....
</div>
</t>
</template>
pramod24
You can use the OCA App Report Qweb Element Page Visibility.
You can use this class first-page shows an element only on the first page.
Thanks