← Back to team overview

clearcorp team mailing list archive

lp:~dr.clearcorp/openerp-ccorp-addons/6.1-purchase_order_discount into lp:openerp-ccorp-addons

 

Diana Rodríguez Martínez has proposed merging lp:~dr.clearcorp/openerp-ccorp-addons/6.1-purchase_order_discount into lp:openerp-ccorp-addons.

Requested reviews:
  CLEARCORP drivers (clearcorp-drivers)

For more details, see:
https://code.launchpad.net/~dr.clearcorp/openerp-ccorp-addons/6.1-purchase_order_discount/+merge/139511

[ADD] Add new module purchase_order_discount that add discount for purchase order and purchase order line.
[FIX] Fix purchase_order_ccorp_report module. Add subtotal with discount in the purchase order report.
-- 
https://code.launchpad.net/~dr.clearcorp/openerp-ccorp-addons/6.1-purchase_order_discount/+merge/139511
Your team CLEARCORP development team is subscribed to branch lp:openerp-ccorp-addons.
=== modified file 'purchase_order_ccorp_report/i18n/es_CR.po'
--- purchase_order_ccorp_report/i18n/es_CR.po	2012-11-16 22:32:17 +0000
+++ purchase_order_ccorp_report/i18n/es_CR.po	2012-12-12 16:55:27 +0000
@@ -6,8 +6,8 @@
 msgstr ""
 "Project-Id-Version: OpenERP Server 6.1\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-11-16 22:03+0000\n"
-"PO-Revision-Date: 2012-11-16 22:03+0000\n"
+"POT-Creation-Date: 2012-12-12 16:45+0000\n"
+"PO-Revision-Date: 2012-12-12 16:45+0000\n"
 "Last-Translator: <>\n"
 "Language-Team: \n"
 "MIME-Version: 1.0\n"
@@ -16,50 +16,44 @@
 "Plural-Forms: \n"
 
 #. module: purchase_order_ccorp_report
-#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:67
-#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:69
-msgid "[Code] Description / (Taxes)"
-msgstr "[Código] Descripción / (Impuestos)"
-
-#. module: purchase_order_ccorp_report
-#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:94
+#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:96
 msgid "Sub Total"
 msgstr "Subtotal"
 
 #. module: purchase_order_ccorp_report
-#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:27
-msgid "Validated by: "
-msgstr "Validado por: "
-
-#. module: purchase_order_ccorp_report
-#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:96
-msgid "Total"
-msgstr "Total"
-
-#. module: purchase_order_ccorp_report
-#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:67
-msgid "Date Order"
-msgstr "Fecha de la orden"
-
-#. module: purchase_order_ccorp_report
-#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:39
+#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:41
 msgid "Delivery and Invoincing"
 msgstr "Entrega y facturación"
 
 #. module: purchase_order_ccorp_report
-#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:103
+#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:108
 msgid "Authorized by"
 msgstr "Autorizado por"
 
 #. module: purchase_order_ccorp_report
-#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:95
-msgid "Taxes"
-msgstr "Impuestos"
-
-#. module: purchase_order_ccorp_report
-#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:103
-msgid "Validated by"
-msgstr "Validado por"
+#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:71
+msgid "Unit Price"
+msgstr "Precio Unitario"
+
+#. module: purchase_order_ccorp_report
+#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:19
+msgid "Order N°"
+msgstr "Orden N°"
+
+#. module: purchase_order_ccorp_report
+#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:98
+msgid "Subtotal with discount"
+msgstr "Subtotal con descuento"
+
+#. module: purchase_order_ccorp_report
+#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:35
+msgid "Email"
+msgstr "Correo electrónico"
+
+#. module: purchase_order_ccorp_report
+#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:71
+msgid "Total Price"
+msgstr "Precio total"
 
 #. module: purchase_order_ccorp_report
 #: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:24
@@ -67,58 +61,74 @@
 msgstr "Fecha de la orden: "
 
 #. module: purchase_order_ccorp_report
-#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:38
+#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:97
+msgid "Discount"
+msgstr "Descuento"
+
+#. module: purchase_order_ccorp_report
+#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:32
+msgid "Ref."
+msgstr "Ref."
+
+#. module: purchase_order_ccorp_report
+#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:45
+msgid "Expected date: "
+msgstr "Fecha esperada "
+
+#. module: purchase_order_ccorp_report
+#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:69
+#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:71
+msgid "[Code] Description / (Taxes)"
+msgstr "[Código] Descripción / (Impuestos)"
+
+#. module: purchase_order_ccorp_report
+#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:99
+msgid "Taxes"
+msgstr "Impuestos"
+
+#. module: purchase_order_ccorp_report
+#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:40
 msgid "Purchase Order"
 msgstr "Pedido de compra"
 
 #. module: purchase_order_ccorp_report
+#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:49
+msgid "Date approved: "
+msgstr "Fecha de aprobación: "
+
+#. module: purchase_order_ccorp_report
+#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:28
+msgid "Validated by: "
+msgstr "Validado por: "
+
+#. module: purchase_order_ccorp_report
+#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:69
+msgid "Date Order"
+msgstr "Fecha de la orden"
+
+#. module: purchase_order_ccorp_report
+#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:69
+#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:71
+msgid "Qty"
+msgstr "Cant"
+
+#. module: purchase_order_ccorp_report
 #: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:16
 msgid "Quotation N°"
 msgstr "Cotización N°"
 
 #. module: purchase_order_ccorp_report
-#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:43
-msgid "Expected date: "
-msgstr "Fecha esperada "
-
-#. module: purchase_order_ccorp_report
-#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:30
-msgid "Ref."
-msgstr "Ref."
-
-#. module: purchase_order_ccorp_report
-#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:19
-msgid "Order N°"
-msgstr "Orden N°"
-
-#. module: purchase_order_ccorp_report
-#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:69
+#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:108
+msgid "Validated by"
+msgstr "Validado por"
+
+#. module: purchase_order_ccorp_report
+#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:71
 msgid "Date planned"
-msgstr "Date planned"
-
-#. module: purchase_order_ccorp_report
-#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:67
-#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:69
-msgid "Qty"
-msgstr "Cant"
-
-#. module: purchase_order_ccorp_report
-#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:47
-msgid "Date approved: "
-msgstr "Fecha de aprobación: "
-
-#. module: purchase_order_ccorp_report
-#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:33
-msgid "Email"
-msgstr "Correo electrónico"
-
-#. module: purchase_order_ccorp_report
-#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:69
-msgid "Total Price"
-msgstr "Precio total"
-
-#. module: purchase_order_ccorp_report
-#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:69
-msgid "Unit Price"
-msgstr "Precio Unitario"
+msgstr "Fecha planeada"
+
+#. module: purchase_order_ccorp_report
+#: report:addons/purchase_order_ccorp_report/report/purchase_order_report.mako:100
+msgid "Total"
+msgstr "Total"
 

=== modified file 'purchase_order_ccorp_report/purchase_order_ccorp_report.xml'
--- purchase_order_ccorp_report/purchase_order_ccorp_report.xml	2012-11-16 22:32:17 +0000
+++ purchase_order_ccorp_report/purchase_order_ccorp_report.xml	2012-12-12 16:55:27 +0000
@@ -9,7 +9,15 @@
         file="purchase_order_ccorp_report/report/purchase_order_report.mako"
         string="Purchase Order"
         report_type="webkit" />
-             
+        
+     <report auto="False"
+        id="purchase.report_purchase_quotation"
+        model="purchase.order"
+        name="purchase_quotation_report_inherit"
+        file="purchase_order_ccorp_report/report/purchase_order_report.mako"
+        string="Request for Quotation"
+        report_type="webkit" />
+        
     </data>
 </openerp>
 

=== modified file 'purchase_order_ccorp_report/report/purchase_order_report.mako'
--- purchase_order_ccorp_report/report/purchase_order_report.mako	2012-11-20 15:08:42 +0000
+++ purchase_order_ccorp_report/report/purchase_order_report.mako	2012-12-12 16:55:27 +0000
@@ -94,6 +94,8 @@
         %endfor
         %if purchase_order.state != 'draft' :
             <tr><td style="border-style:none"/><td style="border-style:none"/><td style="border-style:none"/><td style="border-top:2px solid"><b>${_("Sub Total")}:</b></td><td style="border-top:2px solid;text-align:right">${purchase_order.pricelist_id.currency_id.symbol_prefix or ''|entity} ${formatLang(purchase_order.amount_untaxed)} ${purchase_order.pricelist_id.currency_id.symbol_suffix or ''|entity}</td></tr>
+            <tr><td style="border-style:none"/><td style="border-style:none"/><td style="border-style:none"/><td style="border-style:none"><b>${_("Discount")}:</b></td><td style="text-align:right">${purchase_order.pricelist_id.currency_id.symbol_prefix or ''|entity} ${formatLang(purchase_order.amount_discount)} ${purchase_order.pricelist_id.currency_id.symbol_suffix or ''|entity}</td></tr>
+            <tr><td style="border-style:none"/><td style="border-style:none"/><td style="border-style:none"/><td style="border-style:none"><b>${_("Subtotal with discount")}:</b></td><td style="text-align:right">${purchase_order.pricelist_id.currency_id.symbol_prefix or ''|entity} ${formatLang(purchase_order.amount_subtotal_discount)} ${purchase_order.pricelist_id.currency_id.symbol_suffix or ''|entity}</td></tr>                        
             <tr><td style="border-style:none"/><td style="border-style:none"/><td style="border-style:none"/><td style="border-style:none"><b>${_("Taxes")}:</b></td><td style="text-align:right">${purchase_order.pricelist_id.currency_id.symbol_prefix or ''|entity} ${formatLang(purchase_order.amount_tax)} ${purchase_order.pricelist_id.currency_id.symbol_suffix or ''|entity}</td></tr>
             <tr><td style="border-style:none"/><td style="border-style:none"/><td style="border-style:none"/><td style="border-style:none"><b>${_("Total")}:</b></td><td style="text-align:right">${purchase_order.pricelist_id.currency_id.symbol_prefix or ''|entity} ${formatLang(purchase_order.amount_total)} ${purchase_order.pricelist_id.currency_id.symbol_suffix or ''|entity}</td></tr>
         %endif         

=== added directory 'purchase_order_discount'
=== added file 'purchase_order_discount/__init__.py'
--- purchase_order_discount/__init__.py	1970-01-01 00:00:00 +0000
+++ purchase_order_discount/__init__.py	2012-12-12 16:55:27 +0000
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Addons modules by CLEARCORP S.A.
+#    Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import purchase_order_discount
\ No newline at end of file

=== added file 'purchase_order_discount/__openerp__.py'
--- purchase_order_discount/__openerp__.py	1970-01-01 00:00:00 +0000
+++ purchase_order_discount/__openerp__.py	2012-12-12 16:55:27 +0000
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Addons modules by CLEARCORP S.A.
+#    Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+{
+    'name': 'Purchase Order Discount',
+    'version': '1.0',
+    'url': 'http://launchpad.net/openerp-ccorp-addons',
+    'author': 'ClearCorp S.A.',
+    'website': 'http://clearcorp.co.cr',
+    'category': 'Purchase Management',
+    'complexity': 'normal',
+    'description': """This module add discount to purchase order object. Also, calculate the discout for the object""",
+    'depends': [
+        'purchase',
+    ],
+    'init_xml': [],
+    'demo_xml': [],
+    'update_xml': ['purchase_order_discount.xml',],
+    'license': 'AGPL-3',
+    'installable': True,
+    'active': False,
+}

=== added directory 'purchase_order_discount/i18n'
=== added file 'purchase_order_discount/i18n/es_CR.po'
--- purchase_order_discount/i18n/es_CR.po	1970-01-01 00:00:00 +0000
+++ purchase_order_discount/i18n/es_CR.po	2012-12-12 16:55:27 +0000
@@ -0,0 +1,63 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* purchase_order_discount
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 6.1\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2012-12-12 15:52+0000\n"
+"PO-Revision-Date: 2012-12-12 15:52+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: purchase_order_discount
+#: sql_constraint:purchase.order:0
+msgid "Order Reference must be unique per Company!"
+msgstr "¡La referencia de la compra debe ser única por compañía!"
+
+#. module: purchase_order_discount
+#: help:purchase.order,amount_discount:0
+msgid "Amount discount"
+msgstr "Descuento"
+
+#. module: purchase_order_discount
+#: view:purchase.order:0
+msgid "Compute"
+msgstr "Calcular"
+
+#. module: purchase_order_discount
+#: model:ir.model,name:purchase_order_discount.model_purchase_order_line
+msgid "Purchase Order Line"
+msgstr "Línea pedido de compra"
+
+#. module: purchase_order_discount
+#: model:ir.model,name:purchase_order_discount.model_purchase_order
+msgid "Purchase Order"
+msgstr "Pedido de compra"
+
+#. module: purchase_order_discount
+#: field:purchase.order,amount_discount:0
+msgid "Discount"
+msgstr "Descuento"
+
+#. module: purchase_order_discount
+#: sql_constraint:purchase.order.line:0
+msgid "The line discount must be leaser than 100 !"
+msgstr "El descuento debe ser menor que 100% !"
+
+#. module: purchase_order_discount
+#: field:purchase.order,amount_subtotal_discount:0
+#: help:purchase.order,amount_subtotal_discount:0
+msgid "Subtotal with discount"
+msgstr "Subtotal con descuento"
+
+#. module: purchase_order_discount
+#: field:purchase.order.line,discount:0
+msgid "Discount (%)"
+msgstr "Descuento (%)"
+

=== added file 'purchase_order_discount/purchase_order_discount.py'
--- purchase_order_discount/purchase_order_discount.py	1970-01-01 00:00:00 +0000
+++ purchase_order_discount/purchase_order_discount.py	2012-12-12 16:55:27 +0000
@@ -0,0 +1,151 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Addons modules by CLEARCORP S.A.
+#    Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import fields,osv
+import decimal_precision as dp
+
+class purchase_order_line(osv.osv):
+    _name = 'purchase.order.line'
+    _inherit = 'purchase.order.line'
+    _description = 'Purchase Order Line'
+    
+    _columns = {
+        'discount': fields.float('Discount (%)', digits=(16, 2)),        
+    }
+    
+    _defaults = {
+        'discount': lambda *a: 0.0,        
+        }
+    
+    _sql_constraints = [
+        ('check_discount', 'CHECK (discount > 100)','The line discount must be leaser than 100 !'),
+    ]
+    
+purchase_order_line()
+
+class purchase_order(osv.osv):
+    _name = 'purchase.order'
+    _inherit = 'purchase.order'
+    _description = 'Purchase Order'
+    
+    def action_invoice_create(self, cr, uid, ids, context=None):               
+        
+        """
+        You have to make a super original method and 
+        updated invoice lines with the discount that lines has 
+        on the purchase order. You can not directly update the discount 
+        because the discount is calculated on the invoice
+        """
+        
+        account_invoice_obj = self.pool.get('account.invoice')        
+        account_invoice_line_obj = self.pool.get('account.invoice.line')
+      
+        res = super(purchase_order, self).action_invoice_create(cr, uid, ids, context)
+        invoice_lines_ids = account_invoice_line_obj.search(cr,uid,[('invoice_id','=',res)],context)
+        invoice_lines = account_invoice_line_obj.browse(cr,uid,invoice_lines_ids,context)
+        
+        for purchase in self.browse(cr, uid, ids, context=context):
+            #zip is a function that enables iterating through two lists simultaneously.
+            #for a,b in (list_a,list_b), where a is iterator for list_a and b is iterator for list_b
+            #zip know if any of list is empty and stop the iteration
+            
+            #In this for, iterates in both list and extract the discount for purchase line
+            #and update the invoice line with the id (invoice_line.id)
+            for purchase_line,invoice_line in zip(purchase.order_line,invoice_lines):
+                if purchase_line.discount is not None:
+                    discount = purchase_line.discount  
+                    account_invoice_line_obj.write(cr, uid,[invoice_line.id], {'discount': discount}, context=context)
+        return res
+    
+    def _get_order_ccorp(self, cr, uid, ids, context=None):
+        return self.pool.get('purchase.order')._get_order(cr, uid, ids, context)
+
+    def _amount_all_ccorp(self, cr, uid, ids, field_name, arg, context=None):
+        res = {}
+        cur_obj=self.pool.get('res.currency')
+        for order in self.browse(cr, uid, ids, context=context):
+            res[order.id] = {
+                'amount_untaxed': 0.0,
+                'amount_tax': 0.0,
+                'amount_total': 0.0,
+                'amount_discount':0.0,
+                'amount_subtotal_discount':0.0,
+            }
+            
+            amount_untaxed_not_discount = por_disc = amount_discounted = amount_tax = total = 0.0 
+            cur = order.pricelist_id.currency_id
+            
+            for line in order.order_line:
+                #subtotal without discount and taxes
+                amount_untaxed_not_discount += line.price_subtotal
+                #----discount-------------#
+                if line.discount > 0:
+                   por_disc = line.discount / 100
+                   amount_discounted += por_disc * line.price_subtotal
+                #-----taxes---------------# 
+                #taxes must be calculate with unit_price - discount
+                price_unit_discount = line.price_unit - (line.price_unit * (line.discount / 100) )
+                for c in self.pool.get('account.tax').compute_all(cr, uid, line.taxes_id, price_unit_discount, line.product_qty, order.partner_address_id.id, line.product_id.id, order.partner_id)['taxes']:
+                   amount_tax += c.get('amount', 0.0)
+            
+            res[order.id]['amount_untaxed']=cur_obj.round(cr, uid, cur, amount_untaxed_not_discount)
+            res[order.id]['amount_discount']=cur_obj.round(cr, uid, cur, amount_discounted)
+            res[order.id]['amount_subtotal_discount']=cur_obj.round(cr, uid, cur, (amount_untaxed_not_discount - amount_discounted))
+            res[order.id]['amount_tax']=cur_obj.round(cr, uid, cur, amount_tax)
+            res[order.id]['amount_total']=res[order.id]['amount_subtotal_discount'] + res[order.id]['amount_tax']
+            
+        return res
+
+    _columns = {
+        'amount_untaxed': fields.function(_amount_all_ccorp, digits_compute= dp.get_precision('Purchase Price'), string='Subtotal',
+            store={
+                'purchase.order.line': (_get_order_ccorp, None, 10),
+            }, multi="sums", help="The amount without tax and discount"),
+                
+        'amount_tax': fields.function(_amount_all_ccorp, digits_compute= dp.get_precision('Purchase Price'), string='Taxes',
+            store={
+                'purchase.order.line': (_get_order_ccorp, None, 10),
+            }, multi="sums", help="The tax amount"),
+                
+        'amount_total': fields.function(_amount_all_ccorp, digits_compute= dp.get_precision('Purchase Price'), string='Total',
+            store={
+                'purchase.order.line': (_get_order_ccorp, None, 10),
+            }, multi="sums",help="The total amount"),
+                
+        'amount_discount': fields.function(_amount_all_ccorp, digits_compute= dp.get_precision('Sale Price'), string='Discount',
+            store={
+                'purchase.order.line': (_get_order_ccorp, None, 10),
+            }, multi="sums",help="Amount discount"),   
+        
+        'amount_subtotal_discount': fields.function(_amount_all_ccorp, digits_compute= dp.get_precision('Sale Price'), string='Subtotal with discount',
+            store={
+                'purchase.order.line': (_get_order_ccorp, None, 10),
+            }, multi="sums",help="Subtotal with discount"),   
+    }
+   
+    
+purchase_order()
+
+
+
+
+    
\ No newline at end of file

=== added file 'purchase_order_discount/purchase_order_discount.xml'
--- purchase_order_discount/purchase_order_discount.xml	1970-01-01 00:00:00 +0000
+++ purchase_order_discount/purchase_order_discount.xml	2012-12-12 16:55:27 +0000
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<openerp>
+    <data>              
+       <record id="purchase_order_form_inherit" model="ir.ui.view">
+            <field name="name">purchase.order.form.inherit</field>
+            <field name="model">purchase.order</field>
+            <field name="type">form</field>
+            <field name="inherit_id" ref="purchase.purchase_order_form"/>
+            <field name="arch" type="xml">                   
+                <xpath expr="/form/notebook/page[@string='Purchase Order']/field[@name='order_line']/tree/field[@name='price_unit']" position="after">
+                    <field name="discount" /> 
+                </xpath>
+                <xpath expr="/form/notebook/page[@string='Purchase Order']/group[1]" position="replace">
+                    <group colspan="4" col="8">
+                        <group colspan="4" col="4"> </group>
+                        <group colspan="2" col="2">
+                            <button name="button_dummy" states="draft" string="Compute" type="object" icon="gtk-execute"/>                        
+                            <field name = "amount_untaxed"></field>
+                            <field name = "amount_discount"></field>
+                            <field name = "amount_subtotal_discount"></field>
+                            <field name = "amount_tax"></field>
+                            <field name = "amount_total"></field>
+                        </group> 
+                    </group>
+                </xpath>
+            </field>
+        </record> 
+                    
+        <record id="purchase_order_line_form_inherit" model="ir.ui.view">
+            <field name="name">purchase.order.line.form.inherit</field>
+            <field name="model">purchase.order.line</field>
+            <field name="type">form</field>
+            <field name="inherit_id" ref="purchase.purchase_order_line_form"/>
+            <field name="arch" type="xml">                   
+                <xpath expr="/form/notebook/page[@string='Order Line']/field[@name='company_id']" position="after">
+                    <field name="discount" /> 
+                </xpath>                
+            </field>
+        </record> 
+        
+    </data>
+</openerp>
+


Follow ups