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 add one field in sale.order.line model in 'sale.py'

By
James Ford
on 2/25/16, 7:21 AM 553 views


Hello, this question may to be a simple question but I don't understand why i can't to add one field to sale.order.line model through 'sale.py'.

In the line 609 i added the next statement:

niu = fields.Char(string="NIU", compute="_niu_validation", defalut=" ", readonly=True)

Then, after de restart de server and when i review the model in the Odoo GUI, There isn't field in the sale.order.line model, like shows in the next image:

Image: http://en.zimagez.com/zimage/asssss.php

Please help with this doubt. I repeat, this can be very simple, but i'm newbie in Odoo and i don't understand why don't its work.


1

Akhil P Sivan

--Akhil P Sivan--
3423
| 5 3 6
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 2/26/16, 1:13 AM

Hi James,

When you want to add a new field to any model, you can either do from front end through UI or from back end through coding.

From front end, you can go to Settings >> Technical >> Database Structure >> Fields >> Create a new field.

But this change or the added field will affect only the current database.

Better option is to add from the backend, by using the inheritance or extension feature provided by Odoo. To create a new field, you need to define that field in the model and also call that field on the view.

You can create a simple your own custom module or addon by following the Odoo tutorial. Then in that module, you can inherit the sale.order.line model in the python file, define your field. Then in the xml file, inherit the view definition of sale.order.line and add this field. 

By doing like this, your changes will remain in your own module and doesn't affect the original code. Also just refer the field types available and how to inherit python classes & view definitions.

Its not a good practice to modify the original sale.py file, as it may create problems on upgrade etc.

0
Odoo Honduras
On 2/27/16, 2:36 AM

Try create custom module, maybe my answer to this question be usefull

I added a field to invoice line , just change it for sale order line.

Dont forget upvote my answer.


https://www.odoo.com/forum/help-1/question/add-a-field-to-the-invoice-line-v8-71698#answer-98321

0
James Ford
On 2/25/16, 8:17 AM

Thanks. I do it

0

Jusab Sida (jsi)

--Jusab Sida (jsi)--
Tiny ERP Pvt Ltd
http://www.odoo.com
874
| 2 1 5
Gandhinagar, India
--Jusab Sida (jsi)--


Jusab Sida (jsi)
On 2/26/16, 12:45 AM

Try with updating sale module...

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: 2/25/16, 7:21 AM
Seen: 553 times
Last updated: 2/27/16, 2:36 AM