Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
1001 Zobrazení

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!

Avatar
Zrušit
Autor

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

Nejlepší odpověď

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


Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
srp 25
157
0
srp 25
274
1
srp 25
678
1
srp 25
526
4
čvc 25
1884