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

How to use custom fields in sales.order?

By
evon_dun
on 5/2/13, 10:35 AM 1,392 views

I created a module that depends on sale, and now I want to use fields of this module in sales order view and may be invoices too. How can i do that please help.

1

I suppose you inherit the sale object, do you know that you have 2 kinds of inheritance? With the first one the parent could access to the fields, methods... and with the second one, the parent couldn't.

1st kind of inheritance (From OpenERP Doc):

There are two possible ways to do this kind of inheritance. Both ways result in a new class of data, which holds parent fields and behaviour as well as additional fields and behaviour, but they differ in heavy programatical consequences.

While Example 1 creates a new subclass “custom_material” that may be “seen” or “used” by any view or tree which handles “network.material”, this will not be the case for Example 2.

This is due to the table (other.material) the new subclass is operating on, which will never be recognized by previous “network.material” views or trees.

Example 1:

class custom_material(osv.osv): _name = 'network.material' _inherit = 'network.material' _columns = { 'manuf_warranty': fields.boolean('Manufacturer warranty?'), } _defaults = { 'manuf_warranty': lambda *a: False, } custom_material()

please tell me about the first one

evon_dun
on 5/3/13, 2:13 AM

my module also inherits res.partner and i created my module as customers if i inherit sale.order too and create a new record sale.order.form.inherit in view.xml then i get this error: View error

Can't find field 'category' in the following view parts composing the view of object model 'sale.order': * sale.order.tree.inherit

Either you wrongly customized this view, or some modules bringing those views are not compatible with your current data model

evon_dun
on 5/3/13, 3:22 AM

You can see it above in my answer.

Else IT, Christophe dos Santos
on 5/3/13, 8:09 AM
0
jamesbale
On 5/2/13, 11:18 AM

its depend on your field definition, what are you try to do.

I tried adding my module fields in sale.py file but it gives error and the module cannot be loaded then. I inherited sale.order, do i need to inherit sale itself?

evon_dun
on 5/3/13, 2:13 AM

yes you have to inherit sale

jamesbale
on 5/3/13, 8:10 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

0 follower(s)

Stats

Asked: 5/2/13, 10:35 AM
Seen: 1392 times
Last updated: 3/16/15, 8:10 AM