Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 

 3 Answer(s)

  • Hello Faisal,

    If you want to add fields in purchase.order.line then inherit this class purchase_order_line and add fields according your client requirment and use xpath in .xml file in your module .
    Exp- In .py file in your module

    class purchase_order_line(osv.osv):
        _name='purchase.order.line
        _inherit='purchase.order.line'
        _columns={
                'cartage':fields.float('Cartage',readonly=False),
                    }
    

    And then add same fields account.invoice.line to inherit account_invoice_line class form account module and also inherit the this function given below.

    class account_invoice_line(osv.osv):
        _name='account.invoice.line'
        _inherit='account.invoice.line'
        _columns={
                'cartage':fields.float('Cartage',readonly=False),
                    }
    
    def _amount_line(self, cr, uid, ids, prop, unknow_none, unknow_dict):
            print"==========_amount_line222=========="
            res = {}
            tax_obj = self.pool.get('account.tax')
            cur_obj = self.pool.get('res.currency')
            for line in self.browse(cr, uid, ids):
                price = line.price_unit * (1-(line.discount or 0.0)/100.0)
                taxes = tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, price, line.quantity, product=line.product_id, partner=line.invoice_id.partner_id)
                res[line.id] = taxes['total'] + (line.quantity * line.cartage)
                print"==========Add here fields cartage ==========",res[line.id]
                if line.invoice_id:
                    cur = line.invoice_id.currency_id
                    res[line.id] = cur_obj.round(cr, uid, cur, res[line.id])
            return res
    
  • If you want to Get custom field in invoice from purchase order in OpenERP (Odoo) follow the below mentioned steps:

    Step-1 Go to settings Menu and click it.
    Step-2 Go to sales -> sales form content -> custom fields-> PURCHASE ORDER.LINE all three available fields > After that click on done Button

    In Odoo/OpenERP-8 we can inherit product.template model or inherit the tree view of purchase.order.line and add the invoice filed .( by inheriting and using xpath in .xml file)

    For Example..

    field_name = field.Char(related="product_id.invoce_line", string="add_newfield") ,

  • yeah i want that in odoo v8 i inherited that field using xpath in purchase.order.line but i want that field also in invoice and i want to calculate totat and subtotal amount based on that field if price_unit field is empty or equal to 0

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: