Odoo Help


How to Override a field in OpenERP7.0

Rakhi sudevan
on 3/14/14, 1:41 AM 951 views

Hi, In my DB ,i create one float field"TotalQty" in sale.order.line using this code

from osv import osv from osv import fields

class jrquantity(osv.osv):

_name = 'sale.order.line'
_inherit = 'sale.order.line'

def _total(self, cr, uid, ids,name,args, context=None):
    res = {}
    for record in self.browse(cr, uid, ids, context=context):
        res[record.id] =  record.noofcarton * record.pcs
    return res
_columns = {
        'noofcarton':fields.integer('No of CartonBoxes',size=64, required=False, readonly=False),
          'pcs':fields.integer('No of Pcs', size=64, required=False, readonly=False),
          'qty': fields.function(_total, type='integer', method=True, string='TotalQty')


I need the value of the "TotalQty" to the existing field "product_uom_qty"(Quantity) I want to change the function in the field "product_uom_qty" (sale.order.line).



Atul Kumar jain

--Atul Kumar jain--
| 5 3 7
Indore, India
--Atul Kumar jain--


Atul Kumar jain
On 3/14/14, 3:06 AM

You can copy that function from the sale_order_line class and put it in your custom classs

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 3/14/14, 1:41 AM
Seen: 951 times
Last updated: 3/16/15, 8:10 AM