How to print a POS receipt from Sale Order? - javascript

I need to print POS receipt from sale order with same products qty etc.
In Sale order I have created a button "Print POS receIpt". with this button I want to trigger a method that prints out a receipt with sale order lines on it.
So I need to find the method that creates POS receipts and pass the sale order line values to it.
So which method is printing receipts in POS and how can I trigger it? Is it in models.js?

In those Odoo versions, the receipts that are being printed in the POS are a screen capture (actually only the receipt div) made by JavaScript. But you cannot use this approach on the Sale Order view.
However, there is another way to print tickets into PDF with a normal Qweb Report. If you click on the POS menu you will find the "Orders" menu option on the left margin. You will have the print option under the "Print" menu on the form and list view.
If you go to the point_of_sale module you will find the report_receipt.xml file written with the Qweb language. You can customize it to make it work with the sale.order model. But take into account that the paperformat should be point_of_sale.paperformat_posreceipt, you will find the paperformat assigment at the bottom of these code:
<template id="report_receipt">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<div class="page">
<div class="row">
<div class="col-xs-12 text-center">
<h2 t-esc="o.user_id.company_id.name"/>
<div t-field="o.partner_id"
t-field-options='{"widget": "contact", "fields": ["address", "name", "phone", "fax"], "no_marker": true}'/>
User: <span t-field="o.user_id"/><br/>
Date: <span t-field="o.date_order"/><br/>
</div>
</div>
<div class="row">
</div>
<table class="table table-condensed">
<thead>
<tr>
<th>Description</th>
<th class="text-right">Quantity</th>
<th class="text-right">Price</th>
</tr>
</thead>
<tbody>
<tr t-foreach="o.lines" t-as="line">
<td><span t-field="line.product_id"/></td>
<td class="text-right">
<t t-if="o.state != 'cancel' and o.statement_ids">
<span t-field="line.qty"/>
</t>
</td>
<td class="text-right">
<t t-if="o.state != 'cancel' and o.statement_ids">
<span t-esc="formatLang(net(line.id), currency_obj=res_company.currency_id)"/>
</t>
<t t-if="line.discount != 0.0">
<span t-esc="line.discount"/>%
</t>
</td>
</tr>
</tbody>
</table>
<div class="row">
<div class="col-xs-12 pull-right">
<table class="table table-condensed">
<tr class="border-black">
<td><strong>Taxes</strong></td>
<td class="text-right">
<strong t-esc="formatLang(o.amount_tax, currency_obj=res_company.currency_id)"/>
</td>
</tr>
<tr>
<td><strong>Total</strong></td>
<td class="text-right">
<strong t-esc="formatLang(o.amount_total, currency_obj=res_company.currency_id)"/>
</td>
</tr>
</table>
</div>
</div>
<table class="table table-condensed">
<thead>
<tr>
<th>Payment Mode</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<tr t-foreach="get_journal_amt(o)" t-as="d">
<td>
<span t-esc="d['name']"/>
</td>
<td>
<span t-esc="formatLang(d['amt'], currency_obj=res_company.currency_id)"/>
</td>
</tr>
</tbody>
</table>
</div>
</t>
</t>
</template>
<report
id="action_report_pos_receipt"
string="Receipt"
model="pos.order"
report_type="qweb-pdf"
name="point_of_sale.report_receipt"
file="point_of_sale.report_receipt"
/>
<record id="action_report_pos_receipt" model="ir.actions.report.xml">
<field name="paperformat_id" ref="point_of_sale.paperformat_posreceipt"/>
</record>

Related

Repeat parent row in nested ng-repeat Angularjs?

I have a table which is displaying nested ng-repeat values. The HTML looks like this.
<table class="table">
<thead class="bgThead">
<tr>
<th>Environment</th>
<th>Configurations</th>
<th>Servers</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="environment in serverList.environments" ng-class-odd="''" ng-class-even="'dataTableOdd'">
<td>{{environment.Environment}}</td>
<td ng-repeat="servertypeinfo in environment.ServerTypeInfo">{{servertypeinfo.Type}}</td>
<td ng-repeat="servertypeinfo in environment.ServerTypeInfo">
{{servertypeinfo.ServerConfigInfo.length}}
<td ng-repeat="servers in servertypeinfo.ServerConfigInfo">{{servers.ServerName}}</td>
</td>
</tr>
</tbody>
</table>
Now, when there are multiple values in child ng-repeat, the TDs are getting repeated, instead I want the whole row to be repeated, with the same values, except the new children value. Same goes with further nested ng-repeats. I made a plunk which shows what I am aiming for.
http://plnkr.co/edit/vLw6MCO8NGoFYxaCKeJ0?p=preview
Example without table, may not be what you are looking for
<div class="form-group" ng-repeat="environment in serverList.environments track by $index">
<div class="col-md-4">
<span ng-bind="environment.environment"></span>
</div>
<div class="col-md-8">
<ul class="list-group">
<li id="{{$index}}" ng-repeat="servertypeinfo in environment.serverTypeInfo track by $index">
Server Type: <span style="font-size: 16px;" class="no-margin" ng-bind="servertypeinfo.type">{{servertypeinfo.serverConfigInfo.length}}</span>
<p class="no-margin" ng-repeat="server in servertypeinfo.serverConfigInfo">
Server Name: {{server.serverName}}
</p>
</li>
</ul>
</div>
</div>
use the format like this
<tbody>
<tr ng-repeat="environment in serverList.environments" ng-class-odd="''" ng-class-even="'dataTableOdd'">
<td>
<table>
<tr ng-repeat="servertypeinfo in environment.ServerTypeInfo">
<td>{{environment.Environment}}</td>
<td>{{servertypeinfo.Type}}</td>
<td>
{{servertypeinfo.ServerConfigInfo.length}}
<td ng-repeat="servers in servertypeinfo.ServerConfigInfo">{{servers.ServerName}}</td>
</td>
</tr>
</table>
</td>
</tr>
</tbody>

nested ng-repeat for object within an object within an object

I want to achieve the above image using angular-js ng-repeat. i got a problem for the third column.
<div tasty-table
bind-resource-callback="showTCS.loadAllTCS"
bind-init="showTCS.init"
bind-filters="showTCS.listParams"
bind-reload="showTCS.reloadCallback">
<table class="table table-striped table-condensed table-hover table-bordered table-overflow"
cellpadding="4"
cellspacing="4"
align="center">
<thead tasty-thead bind-not-sort-by="showMainCategory.notSortBy"></thead>
<tbody>
<tr ng-repeat="tcs in rows">
<td>{{tcs.trackName}}</td>
<td>
<table align="left">
<tbody>
<tr ng-repeat="category in tcs.category">
<td>{{category.categoryName}}</td>
<td>
<table> //this one should be on the 3rd <td> of parent table
<tbody>
<tr ng-repeat="skill in category.skill">
<td>{{skill.skillName}}</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
<td align="center">
<a ui-sref="mainCategoryDetails( {mainCatId: mainCategory.mainCat_id} )" class="glyphicon glyphicon-eye-open"></a>
</td>
</tr>
<tr>
<td ng-if="(!rows.length)" colspan="4" class="text-center">No results found.</td>
</tr>
</tbody>
</table>
<div tasty-pagination bind-items-per-page="showTCS.itemsPerPage" bind-list-items-per-page="showTCS.listItemsPerPage"></div>
</div>
This is what i have tried so far and the output is not what i want as shown in the sample image. The problem is how to output the last data which is skills in the third of the parent table.
Found an answer, not quite good since it keeps repeating the tbody but its still ok
<div class="row-fluid" style="padding-top: 2%">
<div tasty-table
bind-resource-callback="showTCS.loadAllTCS"
bind-init="showTCS.init"
bind-filters="showTCS.listParams"
bind-reload="showTCS.reloadCallback">
<table class="table table-striped table-condensed table-hover table-bordered table-overflow"
cellpadding="4"
cellspacing="4"
align="center">
<thead tasty-thead bind-not-sort-by="showTCS.notSortBy"></thead>
<tbody ng-repeat="tcs in rows">
<tr ng-repeat="category in tcs.category">
<td class="text-center" style="vertical-align:middle;">{{tcs.trackName}}</td>
<td class="text-center" style="vertical-align:middle;">{{category.categoryName}}</td>
<td>
<ul class="list-unstyled" >
<li ng-repeat="skill in category.skill">{{skill.skillName}}</li>
</ul>
</td>
<td align="center">
<a ui-sref="mainCategoryDetails( {mainCatId: mainCategory.mainCat_id} )" class="glyphicon glyphicon-eye-open"></a>
<a ui-sref="editMainCategory( {mainCatId: mainCategory.mainCat_id} )" class="glyphicon glyphicon-edit"></a>
<a ui-sref="deleteMainCategory( {mainCatId: mainCategory.mainCat_id} )" class="glyphicon glyphicon-minus-sign"></a>
</td>
</tr>
<tr>
<td ng-if="(!rows.length)" colspan="4" class="text-center">No results found.</td>
</tr>
</tbody>
</table>
<div tasty-pagination bind-items-per-page="showTCS.itemsPerPage" bind-list-items-per-page="showTCS.listItemsPerPage"></div>
</div>

Unable to sort Columns using “OrderBy” filter provided by AngularJs

I have tried running the code below to no success please someone kindly help I cant see any error but its not sorting the Columns tried varies ways and did not work.
<table >
<thead>
<tr>
<th class="textalignleft" >Name</Name
</th>
<th class="textalignleft" ng-repeat="col in selcolumns" ng-class="selectedCls(col)" ng-click="changeSorting(col)" >{{selcolumns[$index]}}
</th>
</tr>
</thead>
<tbody>
<tr data-ng-repeat="person in ItemsByPage[currentPage] | orderBy:columnToOrder:reverse" data-ng-class-odd="'odd'" data-ng-class-even="'even'">
<td>
{{person.FirstName}} {{person.LastName}}
</td>
<td ng-repeat="col in selcolumns">
<span ng-switch on =col>
<span ng-switch-when="Email">{{person.Email}}</span>
<span ng-switch-when="MobileNumber">{{person.MobileNumber}}</span>
<span ng-switch-when="OfficeName">{{person.Firm}}</span>
<span ng-switch-when="OfficeFaxNumber">{{person.OfficeFaxNumber}}</span>
<span ng-switch-when="Functions"><span ng-repeat="Function in person.Functions"><span ng-if="$index > 0">;</span> {{Function.Function}}</span>
</span>
</span>
</td>
</tr>
<tbody>
</table>

Auto refresh table with free marker

What i am trying to do is refreshing my table on my site. I am creating the site with bootstrap and drop wizard (free marker in drop wizard). But i have no clue on how to refresh the tables content but not the whole page. Any tips are welcome.
<table class="table table-hover">
<thead>
<tr bgcolor="lightgray">
<td><strong>Data4</strong></td>
<td><strong>Data3</strong></td>
<td><strong>Data2</strong></td>
<td><strong>Data1</strong></td>
<td></td>
</tr>
</thead>
<tbody>
<div>
<#list datas as data>
<tr>
<td>
${data.id}
</td>
<td>
${data.mobile}
</td>
<td>
${data.size}
</td>
<td>
${data.sizebytes}
</td>
<td>
<a data-toggle="modal"
title="Info" class="open-datainfo btn btn-default" href="#logInformation">
<i class="icon-info-sign icon-black"></i> Data information
</a>
</td>
</tr>
</#list>
</div>
</tbody>
</table>

ASP.NET MVC Jquery dialog with table show details on row click

I have an ASP.NET MVC application that popup a jQuery dialog. Inside the dialog I have a table that I built dynamicly from a Model I get from controller:
This is the dialog table html:
<script type="text/javascript">
$(function () {
$('#btnslide').click(function () {
});
$('#dtnotes tr').click(function () {
var noteUid = $(this).attr("noteuid");
//*******
// here somehow i need to filter my #Model to get the item
// and then update my DIV 'slideinner' with the details data.
//*******
$(".slideinner").slideToggle();
});
});
</script>
<div class="widget widget-table">
<div class="widget-header">
<span class="icon-list"></span>
<h3 class="icon chart">
Notes</h3>
</div>
<div class="widget-content">
<table id="dtnotes" class="table table-bordered table-striped data-table">
<thead>
<tr>
<th>
Subject
</th>
<th style="width: 70px;">
Type
</th>
<th style="width: 70px;">
UserName
</th>
</tr>
</thead>
<tbody>
#foreach (var item in Model)
{
<tr class="gradeA" noteuid="#item.NoteUid">
<td>
#item.Subject
</td>
<td>
#item.NoteTypeDesc
</td>
<td nowrap>
#item.UserName
</td>
</tr>
}
</tbody>
</table>
<button id="btnslide">slide it</button>
</div>
<!-- .widget-content -->
</div>
<div class="slideinner">
<p>Subject</p>
<p>Body</p>
</div>
<!-- .widget -->
I have also a div at the bottom that is a slide div. So when the user clicks on a table row then the div slides up.
What I want is to click on that table row and the DIV must show extra detail information from my Model item.
So I guess I have to be able to get the Model item from the table row "item.NoteUid" key, then update using jquery the "slideinner" div with the item model data.
Hope someone can help me. Appreciate
You can render all the model data you need in the table body and hide the ones you need to with css display:none. I hid the #model.body value in a so you can so retrieve with jquery
$('#dtnotes tr').click(function () {
var noteUid = $(this).attr("noteuid");
//*******
$('.slideinner > p.body').html($(this).children('.body').html());
$('.slideinner > p.subject').html($(this).children('.subject').html());
//*******
$(".slideinner").slideToggle();
});
<tbody>
#foreach (var item in Model)
{
<tr class="gradeA" noteuid="#item.NoteUid">
<td class="subject">
#item.Subject
</td>
<td class="body" style="display:none;">
#item.Body
</td>
<td class="notetypedesc">
#item.NoteTypeDesc
</td>
<td nowrap>
#item.UserName
</td>
</tr>
}
</tbody>
<div class="slideinner">
<p class="subject">Subject</p>
<p class="body">Body</p>
</div>

Categories

Resources