From b461dd366fb42ad42eaf46112acb8d8283704662 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 5 Oct 2012 12:30:33 +0530 Subject: [PATCH 1/4] [IMP]discount shown on ticket. if pos have no order lines it can not validate for ticket print. and improve report of sale detail bzr revid: sgo@tinyerp.com-20121005070033-o51n2w72j7322zg5 --- addons/point_of_sale/report/pos_details.py | 22 ++++++++++--------- addons/point_of_sale/report/pos_details.rml | 2 +- addons/point_of_sale/static/src/js/screens.js | 3 +++ addons/point_of_sale/static/src/xml/pos.xml | 13 ++++++++++- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/addons/point_of_sale/report/pos_details.py b/addons/point_of_sale/report/pos_details.py index f8565a8776a..293eeb722a3 100644 --- a/addons/point_of_sale/report/pos_details.py +++ b/addons/point_of_sale/report/pos_details.py @@ -91,16 +91,17 @@ class pos_details(report_sxw.rml_parse): def _get_sum_dis_2(self): return self.discount or 0.0 - def _get_sum_discount(self, objects): + def _get_sum_discount(self, form): #code for the sum of discount value - return reduce(lambda acc, object: - acc + reduce( - lambda sum_dis, line: - sum_dis + ((line.price_unit * line.qty) * (line.discount / 100)), - object.lines, - 0.0), - objects, - 0.0) + pos_obj = self.pool.get('pos.order') + user_obj = self.pool.get('res.users') + user_ids = form['user_ids'] or self._get_all_users() + company_id = user_obj.browse(self.cr, self.uid, self.uid).company_id.id + pos_ids = pos_obj.search(self.cr, self.uid, [('date_order','>=',form['date_start'] + ' 00:00:00'),('date_order','<=',form['date_end'] + ' 23:59:59'),('user_id','in',user_ids),('company_id','=',company_id)]) + for pos in pos_obj.browse(self.cr, self.uid, pos_ids): + for pol in pos.lines: + self.total_discount += ((pol.price_unit * pol.qty) * (pol.discount / 100)) + return self.total_discount or False def _get_payments(self, form): statement_line_obj = self.pool.get("account.bank.statement.line") @@ -179,11 +180,12 @@ class pos_details(report_sxw.rml_parse): self.qty = 0.0 self.total_invoiced = 0.0 self.discount = 0.0 + self.total_discount = 0.0 self.localcontext.update({ 'time': time, 'strip_name': self._strip_name, 'getpayments': self._get_payments, - 'getsumdisc': self._get_sum_dis_2, + 'getsumdisc': self._get_sum_discount, 'gettotalofthaday': self._total_of_the_day, 'gettaxamount': self._get_tax_amount, 'pos_sales_details':self._pos_sales_details, diff --git a/addons/point_of_sale/report/pos_details.rml b/addons/point_of_sale/report/pos_details.rml index b0019133009..8c20a786b6f 100644 --- a/addons/point_of_sale/report/pos_details.rml +++ b/addons/point_of_sale/report/pos_details.rml @@ -373,7 +373,7 @@ Total discount - [[ formatLang(getsumdisc(), dp='Sale Price') ]] [[ company.currency_id.symbol ]] + [[ formatLang(getsumdisc(data['form']), dp='Sale Price') ]] [[ company.currency_id.symbol ]] diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index 1ad03c5ead1..1f8a35c3105 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -966,6 +966,9 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa this.$('#payment-paid-total').html(paidTotal.toFixed(2)); this.$('#payment-remaining').html(remaining.toFixed(2)); this.$('#payment-change').html(change.toFixed(2)); + if((currentOrder.selected_orderline == undefined)) + remaining = 1 + if(this.pos_widget.action_bar){ this.pos_widget.action_bar.set_button_disabled('validation', remaining > 0); } diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml index 854dd61cc1b..49864f8ae68 100644 --- a/addons/point_of_sale/static/src/xml/pos.xml +++ b/addons/point_of_sale/static/src/xml/pos.xml @@ -541,6 +541,7 @@
+

@@ -553,12 +554,22 @@ + +
  • + % discount +
  • +
    - + + +
  • + - +
  • +
    From 5b48e0894e293cb811a52b236186ad0b7f7e2b50 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 5 Oct 2012 16:35:04 +0530 Subject: [PATCH 2/4] [IMP]discount shows grey and small font under product and total discount amt shows after tax bzr revid: sgo@tinyerp.com-20121005110504-63l1uzxi0fomn4ic --- addons/point_of_sale/static/src/css/pos.css | 5 +++++ addons/point_of_sale/static/src/js/models.js | 5 +++++ addons/point_of_sale/static/src/xml/pos.xml | 14 ++++++-------- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/addons/point_of_sale/static/src/css/pos.css b/addons/point_of_sale/static/src/css/pos.css index cbb625c02d7..5881fb30f17 100644 --- a/addons/point_of_sale/static/src/css/pos.css +++ b/addons/point_of_sale/static/src/css/pos.css @@ -102,6 +102,11 @@ border: 1px solid #cecbcb; border-radius: 4px; } +.point-of-sale .pos-disc-font { + font-size: 12px; + font-style:italic; + color: #808080; +} /* ********* The black header bar ********* */ diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 2c6f4e8b6e0..fd46476dbe2 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -614,6 +614,11 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal return sum + orderLine.get_price_with_tax(); }), 0); }, + getDiscountTotal: function() { + return (this.get('orderLines')).reduce((function(sum, orderLine) { + return sum + (orderLine.get_list_price() * (orderLine.get_discount()/100) * orderLine.get_quantity()); + }), 0); + }, getTotalTaxExcluded: function() { return (this.get('orderLines')).reduce((function(sum, orderLine) { return sum + orderLine.get_price_without_tax(); diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml index 49864f8ae68..cbaf1423b1b 100644 --- a/addons/point_of_sale/static/src/xml/pos.xml +++ b/addons/point_of_sale/static/src/xml/pos.xml @@ -555,8 +555,8 @@ -
  • - % discount +
  • + With a % discount
  • @@ -564,12 +564,7 @@ - - -
  • - - -
  • -
    + @@ -578,6 +573,9 @@ Tax: + Discount: + + Total: From 062a78f8dae1b7747ec62c4a2eb502e8c4f63b03 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 5 Oct 2012 16:56:33 +0530 Subject: [PATCH 3/4] [IMP]improve pos reprint wizard bzr revid: sgo@tinyerp.com-20121005112633-a7er5yxbykgij52s --- addons/point_of_sale/report/pos_receipt.rml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/report/pos_receipt.rml b/addons/point_of_sale/report/pos_receipt.rml index 55873887210..03a7decd81e 100644 --- a/addons/point_of_sale/report/pos_receipt.rml +++ b/addons/point_of_sale/report/pos_receipt.rml @@ -104,12 +104,18 @@ [[ repeatIn(o.lines,'line') ]] [[ line.product_id.name ]] + + With a [[ line and line.discount == 0.0 and removeParentNode('font') ]] ([[ '%.2f' % line.discount ]]) % discount. + + + + [[o.state=='cancel' and o.statement_ids and '-' or '']][['%.f' % line.qty ]] - [[o.state=='cancel' and o.statement_ids and '-' or '']][[ '%.2f' % net(line.id) ]] [[company.currency_id.symbol]] [[ line and line.discount == 0.0 and removeParentNode('font') ]] ([[ '%.2f' % line.discount ]]%) [[company.currency_id.symbol]] + [[o.state=='cancel' and o.statement_ids and '-' or '']][[ '%.2f' % net(line.id) ]] [[company.currency_id.symbol]] From a014d89ab64649d6f347ae5d9efa9b0e018ade7f Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 5 Oct 2012 19:03:15 +0530 Subject: [PATCH 4/4] [IMP]add receipt ref for receipt in pos and pos order bzr revid: sgo@tinyerp.com-20121005133315-qjwl6nx360em8u43 --- addons/point_of_sale/point_of_sale.py | 5 +++-- addons/point_of_sale/point_of_sale_view.xml | 3 +++ addons/point_of_sale/static/src/xml/pos.xml | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index dfd0d73ad55..81df43996d4 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -484,7 +484,8 @@ class pos_order(osv.osv): 'name': order['name'], 'user_id': order['user_id'] or False, 'session_id': order['pos_session_id'], - 'lines': order['lines'] + 'lines': order['lines'], + 'pos_reference':order['name'] }, context) for payments in order['statement_ids']: @@ -592,7 +593,7 @@ class pos_order(osv.osv): 'picking_id': fields.many2one('stock.picking', 'Picking', readonly=True), 'note': fields.text('Internal Notes'), 'nb_print': fields.integer('Number of Print', readonly=True), - + 'pos_reference': fields.char('Receipt Ref', size=64, readonly=True), 'sale_journal': fields.related('session_id', 'config_id', 'journal_id', relation='account.journal', type='many2one', string='Sale Journal', store=True, readonly=True), } diff --git a/addons/point_of_sale/point_of_sale_view.xml b/addons/point_of_sale/point_of_sale_view.xml index 66b7e3b6eb5..e70b71f2604 100644 --- a/addons/point_of_sale/point_of_sale_view.xml +++ b/addons/point_of_sale/point_of_sale_view.xml @@ -88,6 +88,7 @@ + @@ -131,6 +132,7 @@ + @@ -149,6 +151,7 @@ + diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml index cbaf1423b1b..89d0a93fef2 100644 --- a/addons/point_of_sale/static/src/xml/pos.xml +++ b/addons/point_of_sale/static/src/xml/pos.xml @@ -543,7 +543,7 @@
    + Date.CultureInfo.formatPatterns.longTime)"/>


  • Phone: