Odoo Help


assing the value from custom field in products to other one custom field in the sale order form using custom modules

on 4/29/16, 7:09 PM 599 views

Code for custom module for product.template:

# -*- coding: utf-8 -*-

from openerp import models, fields, api

class myfieldinproduct(models.Model):

_inherit = 'product.template'

#Add custom field "reg_model"

reg_model = fields.Char('Model', default='NL-XXXX-XXX')


My code for custom module for sale.order:

# -*- coding: utf-8 -*-

from openerp import models, fields, api

class myfieldinsaleorder(models.Model):

_inherit = 'sale.order'

#Add custom field "reg_model"

reg_modelinsaleorder = fields.Char('Model', default='NL-XXXX-XXX')

In this point how i can get the value of "reg_model" from product.template custom module (myfieldinproduct) and assing to reg_modelinsaleorder



in produc.template have a custom field "mycolor"

in sale.order have a custom field "hiscolor"

hiscolor = mycolor some thing like that.

Thank you.

--Ahmed M.Elmubarak--

Ahmed M.Elmubarak
On 4/30/16, 6:15 AM


I just don't understand something: that is the sale order can contains several lines with products ! it'll be more logical if you added your custom field to sale order line rather than the sale order.

Usually to fetch some values you can use onchange method, or make the fields related.

You can check how the system fetch the product's information in the sale order line in this method So most probably you'll need to override this function ...

Hope this could help

for example i need know how many products in budgets (quotations) are pink, how many products are blue... For example in products for store values i add several custom fields for computers like product_ memory_capacity, product_cpu_speed, product_hdd_capacity because i need to see this values in listview(treeeview) like list prices... In the case of the sale order to store values i will add the same fields like salorder_memory_capacity, saleorder_cpu_speed, saleorder_hdd_capacity BECAUSE i need to make a filter in listview (treeview) to know how many computer in salorder_ memory_capacity = 8GB, or 4 GB... or saleorder_cpu_speed = 2.7GHz or 3.0 GHz... And also In this point when i create a new budgets (quotations) i need to fill this values with hand, and i will like to get default values from the current product in sale order line because maybe just the memory capacity was changed. And yes, i use just one product for every budgets (quotations) in sale order line, of course i do not sell computers.

on 5/2/16, 10:53 AM

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

1 follower(s)


Asked: 4/29/16, 7:09 PM
Seen: 599 times
Last updated: 4/30/16, 6:15 AM