Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
767 Представления

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!

Аватар
Отменить
Автор

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

Лучший ответ

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


Аватар
Отменить
Related Posts Ответы Просмотры Активность
1
июн. 25
191
1
июн. 25
212
0
июн. 25
159
2
июн. 25
235
2
июн. 25
568