Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
920 Lượt xem

Hi,

I'm trying to add an extra field to Sale Order form:

sale.py​:

from odoo import _, api, fields, models


class SaleOrderTest(models.Model): 

​_inherit = "sale.order"

sale_test = fields.Char(string="Test", help="Test field")

record model="ir.ui.view" id="sale_order_am_excise">        

excise.sale_order_am_inherit       

sale.order        

       

            

                

            

         

   

  


odoo service has been restarted, but always get error: 


            
Field "sale_test" does not exist in model "sale.order" View error context: {'file': '/usr/lib/python3/dist-packages/odoo/addons/sale_test/views/sale_order.xml', 'line': 3, 'name': 'excise.sale_order_am_inherit', 'view': ir.ui.view(1606,), 'view.model': 'sale.order', 'view.parent': ir.ui.view(802,), 'xmlid': 'sale_order_am_excise'}


manifest file:

'depends': ['base', 'sale_management'],

>>>SaleOrderTest = env['sale.order']
>>>field_sot = 'sale_test' in SaleOrderTest
>>> print(field_sot)

False

>>>


Could someone help? 

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Thanks everyone!

Didn't add models to init.py.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello, visztani



I hope this message finds you well.


Make sure to add sales py file in init.py.

Please find the attached screenshot to add a custom field in the sale order form view. I’ve added field Test after field Payment terms.

Feel free to contact me if needed

Hope this will help you.

Thanks & Regards,

Email: odoo@aktivsoftware.com           

Skype: kalpeshmaheshwari

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello,

in you python module structure each directory contain a __init__.py in those file you should write a line with the file name wthout py extension as sample
from . import sale
from . import xxxxxxx  where xxxxxx is the file name of your python file


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Did you add sale.py to init file?

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 5 25
2448
1
thg 4 25
3467
1
thg 4 25
4296
1
thg 4 25
1778
4
thg 3 25
6884