How to Override create invoice method with new custom field in Odoo 8

Asked by libu koshy

I have create a custom sale.order with tax_new field in .Calculation in the sale order works perfectly with new custom field.But I cannot understand this value is not updated in the invoice.How to override invoice method with new calculation. This is my code

class sale_order(osv.Model):
    _inherit = "sale.order"
    _description = "Validate quote"

    def _amount_all(self, cr, uid, ids, field_name, arg, context=None):
        print "############## INSide ###########"
        cur_obj = self.pool.get('res.currency')
        res = {}
        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,

            }
             print "tax",res[order.id]['amount_untaxed']
            val = val1 = 0.0
            cur = order.pricelist_id.currency_id
            for line in order.order_line:
                val1 += line.price_subtotal
                val += self._amount_line_tax(cr, uid, line, context=context)
            res[order.id]['amount_tax'] = cur_obj.round(cr, uid, cur, val)
            res[order.id]['amount_untaxed'] = cur_obj.round(cr, uid, cur, val1)
            res = super(sale_order, self)._amount_all(cr, uid, ids, field_name, arg, context)
            res[order.id]['amount_total'] = res[order.id]['amount_tax']+res[order.id]['amount_untaxed']+res[order.id]['amount_untaxed']*(order['tax_new']/100)
        return res

 _columns = {
                'tax_new': fields.float('Taxes in(%)'),
                  }

%%%%%%%%%%%%%%%%%%%%%%
Here How to pass my new tax_field('tax_new') for updating the invoice with my custom field....

class account_invoice(osv.Model):

    _inherit='account.invoice'

    _columns={
              'tax_new':fields.float('tax'),

              }

    def _amount_all(self, cr, uid, ids, name, args, context=None):
        print '-------override _amount_all ---'
        res = super(account_invoice, self)._amount_all(cr, uid, ids, name, args,context=context)
        res.update({'amount_total': 11})#for test
        return res

account_invoice()

Question information

Language:
English Edit question
Status:
Expired
For:
Odoo Addons (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.