Sanjay Gohel (Open ERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-imp-point-of-sale-apa-ticket-sgo into 
lp:~openerp-dev/openobject-addons/trunk-imp-point-of-sale-apa.

Requested reviews:
  Amit Patel (OpenERP) (apa-tiny)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-imp-point-of-sale-apa-ticket-sgo/+merge/128172

Hello sir,
          I have made following changes on point of sale.
1.discount shown on ticket.
2. if pos have no order lines it can not validate for ticket print.
3. improve report of sale detail which gives wrong value for total discount.

Thank You.
Sanjay Gohel(SGO)
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-imp-point-of-sale-apa-ticket-sgo/+merge/128172
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-imp-point-of-sale-apa.
=== modified file 'point_of_sale/report/pos_details.py'
--- point_of_sale/report/pos_details.py	2012-03-05 18:40:03 +0000
+++ point_of_sale/report/pos_details.py	2012-10-05 07:07:22 +0000
@@ -91,16 +91,17 @@
     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 @@
         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,

=== modified file 'point_of_sale/report/pos_details.rml'
--- point_of_sale/report/pos_details.rml	2011-12-29 16:58:23 +0000
+++ point_of_sale/report/pos_details.rml	2012-10-05 07:07:22 +0000
@@ -373,7 +373,7 @@
           <para style="terp_default_Bold_9">Total discount</para>
         </td>
         <td>
-          <para style="terp_default_Right_9_Bold">[[ formatLang(getsumdisc(), dp='Sale Price') ]] [[ company.currency_id.symbol ]]</para>
+          <para style="terp_default_Right_9_Bold">[[ formatLang(getsumdisc(data['form']), dp='Sale Price') ]] [[ company.currency_id.symbol ]]</para>
         </td>
       </tr>
       <tr>

=== modified file 'point_of_sale/report/pos_details.sxw'
Binary files point_of_sale/report/pos_details.sxw	2011-11-25 09:47:15 +0000 and point_of_sale/report/pos_details.sxw	2012-10-05 07:07:22 +0000 differ
=== modified file 'point_of_sale/static/src/js/screens.js'
--- point_of_sale/static/src/js/screens.js	2012-09-18 13:37:32 +0000
+++ point_of_sale/static/src/js/screens.js	2012-10-05 07:07:22 +0000
@@ -966,6 +966,9 @@
             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);
             }

=== modified file 'point_of_sale/static/src/xml/pos.xml'
--- point_of_sale/static/src/xml/pos.xml	2012-09-28 15:20:41 +0000
+++ point_of_sale/static/src/xml/pos.xml	2012-10-05 07:07:22 +0000
@@ -541,6 +541,7 @@
 
     <t t-name="PosTicket">
         <div class="pos-sale-ticket">
+            
             <div class="pos-right-align"><t t-esc="new Date().toString(Date.CultureInfo.formatPatterns.shortDate + ' ' +
                 Date.CultureInfo.formatPatterns.longTime)"/></div>
             <br />
@@ -553,12 +554,22 @@
                 <tr t-foreach="widget.currentOrderLines.toArray()" t-as="order">
                     <td>
                         <t t-esc="order.get_product().get('name')"/>
+                         <t t-if="order.get_discount() > 0">
+                            <li>
+                                <t t-esc="order.get_discount()"/>% discount
+                            </li>
+                        </t>
                     </td>
                     <td class="pos-right-align">
                         <t t-esc="order.get_quantity().toFixed(0)"/>
                     </td>
                     <td class="pos-right-align">
-                        <t t-esc="widget.format_currency(order.get_list_price() * (1 - order.get_discount()/100) * order.get_quantity().toFixed(2))"/>
+                        <t t-esc="widget.format_currency(order.get_list_price() * order.get_quantity().toFixed(2))"/>
+                        <t t-if="order.get_discount() > 0">
+                        <li class="pos-right-align">
+                            -<t t-esc="widget.format_currency(order.get_list_price() * (order.get_discount()/100) * order.get_quantity().toFixed(2))"/>
+                        </li>
+                    </t>
                     </td>
                 </tr>
             </table>

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to