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

Some time ago, I had someone help me by adding a custom field to a contact. They created a file:


/opt/odoo/customized_addons/odoo-custom-addons/partner_extra/models/res_partner.py

which contains this code:

class ResPartner(models.Model):

    """Adds ."""


    _inherit = "res.partner"


    recruitment = fields.Selection([

                                    ('c2c', 'Corp to Corp (C2C)'),

                                    ('w2', 'Full Time (W-2)')

                                   ],'Recruiter'

                                  )



And this works ok. But I would like to add additional options and maybe even additional whole fields. I am fluent in Python and have worked with Django and other things so I'm familiar with MVC and databases etc. But I have never written custom code for Odoo before.


I have changed the above to add an option like so:

    recruitment = fields.Selection([

                                    ('c2c', 'Corp to Corp (C2C)'),

                                    ('w2', 'Full Time (W-2)'),

                                    ('new option','New Option'),

                                   ],'Recruiter'

                                  )


and deleted the compiled and cached __pycache__/res_partner.cpython-36.pyc but the change does not appear in Odoo. Is there some other step I need to take? Maybe some command I need to run to update the database schema to allow for this new option?

Thanks!

Ảnh đại diện
Huỷ bỏ
Tác giả

I forgot to mention that I was restarting odoo after my change. But you gave me an important clue that I was missing: I needed to upgrade the app in by clicking the three dots on the tile in the odoo apps screen. Then my changes appeared! Thanks! Upvoting and marking your answer correct...

Câu trả lời hay nhất

Hello Tracy

In Odoo After changing anything in Python whether its model, wizard, controller 

You will need to restart the odoo service on the machine

for example if you run it on ubuntu you will need to run 

systemcl restart odoo(in this case odoo is the name of the service)

if you change anything in the XMl file you will need to upgrade the module

the cached file you are talking about is not related to Odoo, its related to pycharm

I hope this helps, 

If it helps please upvote my answer and Mark it as Correct


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 10 25
54
2
thg 10 25
235
1
thg 10 25
221
1
thg 9 25
305
1
thg 9 25
377