Odoo Help

Welcome!

This community 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.

0

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

By
Carlos
on 4/29/16, 7:09 PM 190 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

....

Example:

in produc.template have a custom field "mycolor"

in sale.order have a custom field "hiscolor"

hiscolor = mycolor some thing like that.

Thank you.



0

Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
2988
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


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

Hello,

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.

Carlos
on 5/2/16, 10:53 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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