This question has been flagged
8 Replies
15283 Views

I created and installed a module, barebones and everything was cool,

managed to add a field (cusvc_phone) to res.partner, verified in Models, but when I add the second field I get the following error

ProgrammingError: column res_partner.cusvc_email does not exist

My .py is as follows

# Merchant Application applicationfrom odoo import models, fields
#Extend res.partner model with customer service phone number
class Merchappl_respartner(models.Model):
        _inherit = 'res.partner'
        cusvc_phone = fields.Char('Customer Service Phone')
        cusvc_email = fields.Char('Customer Service Email')

It shouldn't be this hard to create a module which extends res.partner so I must be doing something wrong. Any help and/or pointers are much appreciated.

Avatar
Discard
Author

Apologies, but i have physically restarted my server many times to no avail. The only way I could get my changes to show was by creating a new database. It just wouldn't refresh my existing database. This wouldn't be a problem, but I have someone who is making changes to other applications, namely Website. I'll try to create and install a renamed version of my module and see if that takes in the existing database, fingers crossed.

Best Answer

Just restart your server and use  while restarting - u MODULE_NAME -d DATABASE_NAME

hope this will solve your problem.

Avatar
Discard
Author

My installation is using the Yenthe script which autoruns the database upon startup so using:

./odoo-bin -d mydb -u Merchappl --- gives me an error 98 address already in use. even restarting doesn't pick it up Thank you though for your time.

@Damon in that case you should first stop the service (sudo service odoo-server stop) and then run the Odoo in the terminal with ./odoo-bin.py -u Merchappl.

(Nice to see you've used my script)

Awesome, thanks!

On Tue, Dec 6, 2016 at 11:35 AM Yenthe <yenthespam@gmail.com> wrote:

@Damon in that case you should first stop the service (sudo service odoo-server stop) and then run the Odoo in the terminal with ./odoo-bin.py -u Merchappl.

(Nice to see you've used my script)

--
Yenthe


Sent by Odoo S.A. using Odoo.

I'm SolutionArts via PayPal.
Thanks again for the script and service
Damon

On Tue, Dec 6, 2016 at 11:41 AM Damon John Hoxworth <damon@solutionarts.net> wrote:
Awesome, thanks!
On Tue, Dec 6, 2016 at 11:35 AM Yenthe <yenthespam@gmail.com> wrote:

@Damon in that case you should first stop the service (sudo service odoo-server stop) and then run the Odoo in the terminal with ./odoo-bin.py -u Merchappl.

(Nice to see you've used my script)

--
Yenthe


Sent by Odoo S.A. using Odoo.

Author

Yenthe, when I run the (sudo service odoo-server stop) my Odoo installation is still available to me via 8069. When I run (service --status-all) the readout for Odoo shows "[?] odoo-server" indicating that it does not have a status command. It doesn't seem that odoo-server is infact stopping?

Best Answer

I had a similar experience to Damon.  It seems to be a problem with the characters for spacing or line breaks.  I tried manipulating the text in both Bluefish and the gnome Text Editor.  Still got errors.

Finally I opened the .py file in nano at the command prompt.  Some of the line breaks and spacing was shown in a different colour.  After deleting these and replacing it finally worked.

Additional editing in nano seems to work.


Avatar
Discard
Best Answer

Hi Damon,


You need to restart the server and upgrade your module to reflect the new fields that you have created in the model.


Hope this helps,


Thank you

Avatar
Discard
Author

Thank you, should work for me, but is not.

Best Answer

I had the same problem and doing as follow fix the issue:

  1. Stop your server
  2. Run this command at first:  python3 odoo-bin --update=purchase_request
  3. Reload your localhost in browser
  4. Upgrade your module
  5. Stop server again
  6. Now, using the old command (The command you use always) start server again
  7. Upgrade your module again
  8. Done.
Avatar
Discard
Best Answer

Hi,

I have this error when i add new field to base table such as res.users or res.partner,

if i run service by ugprade module command it is ok.

is there any way without upgrade module commad?

I want restart service and upgrade my module manualy. but is not possible.

thanks

Avatar
Discard
Best Answer

Hi guys! I'm new to Odoo and I just decided to ask a question in this post instead of making the new one, b/c I had the same problem.

I'm using Odoo v10 and I'm trying to customize existing view (base.view_partner_form). Here are my model and view:

class add_supplier1099(models.Model):
    # _name = 'add.supplier1099'     
    _inherit = ['res.partner']     
    _description = "Add Checkbox and TaxID Field if Supplier Requires 1099"    

    supp_test_field = fields.Char(string="test field")


<odoo>     
    <data>
        <record id="add_supplier1099_view_inherit" model="ir.ui.view">
        <field name="name">res.partner.form</field>
        <field name="model">res.partner</field>
        <field name="inherit_id" ref="base.view_partner_form"/>
        <field name="arch" type="xml">     
            <xpath expr="//field[@name='phone']" position="after">                
                <field name="supp_test_field"/>     
            </xpath>
        </field>         
        </record>    
    </data>
</odoo>

This code works and it adds "supp_test_field" to the form. But if you uncomment # _name = 'add.supplier1099' (I thinks it should add my new field to an existing table of "res.partner" model) it'll through an error:

ValueError: Can't validate view:
Field `supp_test_field` does not exist

I also tried to go with "_name = res.partner" (I thinks it should create a new table with my new field and fields from "res.partner" model), but I was getting the same error. Any ideas why i'm getting this error in the above cases and not getting an error when I comment out "_name" attribute?

Avatar
Discard
Author

Hi Art. I think, and I might be way off, but I think that having your _name in the model isn't needed as you're inheriting the parent model res.partner So you're not really creating a new class, you're inheriting and modifying res.partner. I think that's the reason for the error.

Damon, you're right, there was no need to have _name in my model. It worked well. And I was wrong: if _name and _inherit are the same (res.partner) it'll add a custom field to the existing model and if not then it'll create a new table with custom field and fields from an existing table.

So what is the difference between having _name = res.partner and not having it? Is it the same thing?

Author

Art, I think having _name = res.partner is just redundant in that case.

This is what odoo docs say:

_inherit:

- If _name is set, names of parent models to inherit from. Can be a str if inheriting from a single parent;

- If _name is unset, name of a single model to extend in-place.

Anyway as soon as it works I'm fine with it.

Author Best Answer

I created a new database, and was able to proceed, but only so far.

The first 11 fields (41 total in .py) were added to res.partner and the remaining 30 fields were left alone. So tried multiple times, checked syntax etc. I ended up commenting out the first 11 fields that were being successfully added, created a new db, installed module and all uncommented fields (last 30) populated res.partner, as expected and doing nothing with the commented out first 11.

I don't understand what is happening here, maybe a timeout of some sort?

following are fields 11 and 12 for reference: (the breakpoint as near as I can tell)

itr_name = fields.Char('Name on Income Tax Return') 
prod_svcs = fields.Text('Detailed Explanation of Type of Merchandise, Products or Services Sold:')

Thanks for your time and eyes

Avatar
Discard
Author

Update: This is crazy, but i took my first 11 fields, and moved them to the end of my last 30 fields ran

./odoo-bin -d mydb -i mymodule

and res.partner shows my addl 41 fields in total. I still don't know what the issue was/is.

and res.partner was updated to my initial desire.

Best Answer

Hi,

i too have gone through similar situation .The changes that I make in my py wasn't reflecting.hence I checked if there where many instances running in my backend.There were many idle postgres instances and when I killed them and restarted everything was fine.

Avatar
Discard
Author

Thank you, but just isn't working for me.