Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] partner_firstname for v8 #14

Merged
merged 11 commits into from
Aug 11, 2014
Merged

[ADD] partner_firstname for v8 #14

merged 11 commits into from
Aug 11, 2014

Conversation

eLBati
Copy link
Member

@eLBati eLBati commented Jul 23, 2014

because it's working as is

because it's working as is
@coveralls
Copy link

Coverage Status

Coverage increased (+8.3%) when pulling 94979df on eLBati:8.0 into bf69ae2 on OCA:8.0.

@eLBati
Copy link
Member Author

eLBati commented Jul 23, 2014

Fixed the error occurring when creating or copying users

@pedrobaeza
Copy link
Member

You have a false positive on Travis. This is the error:

2014-07-23 22:14:24,970 19346 ERROR openerp_test openerp.sql_db: bad query: ALTER TABLE "res_partner" ALTER COLUMN "lastname" SET NOT NULL
Traceback (most recent call last):
File "/home/travis/build/OCA/odoo-8.0/openerp/sql_db.py", line 230, in execute
res = self._obj.execute(query, params)
IntegrityError: column "lastname" contains null values
2014-07-23 22:14:24,970 19346 WARNING openerp_test openerp.models: WARNING: unable to set column lastname of table res_partner not null !
Try to re-run: openerp-server --update=module
If it doesn't work, update records and execute manually:
ALTER TABLE res_partner ALTER COLUMN lastname SET NOT NULL
Traceback (most recent call last):
File "/home/travis/build/OCA/odoo-8.0/openerp/models.py", line 2664, in _auto_init
cr.execute('ALTER TABLE "%s" ALTER COLUMN "%s" SET NOT NULL' % (self._table, k))
File "/home/travis/build/OCA/odoo-8.0/openerp/sql_db.py", line 155, in wrapper
return f(self, *args, **kwargs)
File "/home/travis/build/OCA/odoo-8.0/openerp/sql_db.py", line 230, in execute
res = self._obj.execute(query, params)
IntegrityError: column "lastname" contains null values

To fix it, I think there must be a routine on init that fills lastname with name value.

Regards.

@bwrsandman
Copy link
Contributor

@pedrobaeza: this is exactly what this function does. Maybe the API has changed the init functions.

Either way, it would be nice to have a logger tell us that the lastname field has been filled.

@pedrobaeza
Copy link
Member

We have to find then the problem. I wouldn't merge the module until we have this fixed, because it can cause a broken DB, don't you think?

Regards.

@coveralls
Copy link

Coverage Status

Coverage increased (+8.44%) when pulling 74426b4 on eLBati:8.0 into bf69ae2 on OCA:8.0.

@eLBati
Copy link
Member Author

eLBati commented Jul 26, 2014

Traceback (most recent call last):
File "/home/travis/build/OCA/odoo-8.0/openerp/models.py", line 2649, in _auto_init
cr.execute('ALTER TABLE "%s" ALTER COLUMN "%s" SET NOT NULL' % (self._table, k))
File "/home/travis/build/OCA/odoo-8.0/openerp/sql_db.py", line 155, in wrapper
return f(self, *args, **kwargs)
File "/home/travis/build/OCA/odoo-8.0/openerp/sql_db.py", line 230, in execute
res = self._obj.execute(query, params)
IntegrityError: column "lastname" contains null values

This happens because the _auto_init runs before the init and tries to set required=True for lastname field.
Just after that, the init correctly sets the NOT NULL constraint:

2014-07-26 00:10:48,523 19332 INFO openerp_test openerp.addons.partner_firstname.partner: NOT NULL constraint for res_partner.lastname correctly set

@bwrsandman
Copy link
Contributor

can _auto_init be overriden?
Is this an odoo 8.0 bug?

@bwrsandman
Copy link
Contributor

Coverage increased (+8.44%)

I love seeing that! 😄

@eLBati
Copy link
Member Author

eLBati commented Jul 26, 2014

can _auto_init be overriden?

It should be overridable, but it does a lot of things and does not have hooks. It creates tables and adds constraints, so overriding it would not solve the problem.

Anyway I don't see a big problem with this error.
The purpose of init is to make sure the NOT NULL constraint on lastname to be set.
It tries with 'lastname': fields.char("Lastname", required=True) (_auto_init) and if it fails, it adds the constraint with init. As the added log reports.
After having added the constraint, the error won't appear anymore.

@bwrsandman
Copy link
Contributor

I am sorry but, I cannot approve this while there are errors in the logs.

@rvalyi
Copy link
Member

rvalyi commented Jul 26, 2014

"It should be overridable, but it does a lot of things and does not have hooks"
-> then may be it's time to propose a small refactor in official Odoo and lobby to get that in v8 while we may still have a few days to do so...

@nhomar
Copy link
Member

nhomar commented Jul 26, 2014

2014-07-26 10:17 GMT-04:30 Raphaël Valyi notifications@github.com:

-> then may be it's time to propose a small refactor in official Odoo and
lobby to get that in v8 while we may still have a few days to do so...

Absolutly agreed with this point.


Saludos Cordiales

Nhomar G. Hernandez M.
+58-414-4110269
Skype: nhomar00
Web-Blog: http://geronimo.com.ve
Servicios IT: http://vauxoo.com
Linux-Counter: 467724
Correos:
nhomar@openerp.com.ve
nhomar@vauxoo.com
twitter @nhomar

@hbrunn
Copy link
Member

hbrunn commented Jul 28, 2014

how about 'lastname': fields.char(...., oldname='name')?

@eLBati
Copy link
Member Author

eLBati commented Jul 29, 2014

how about 'lastname': fields.char(...., oldname='name')?

I get

2014-07-29 10:40:50,067 25164 INFO demo_8 openerp.modules.module: module partner_firstname: creating or updating database tables
2014-07-29 10:40:50,160 25164 ERROR demo_8 openerp.sql_db: Programming error: column "name" of relation "res_partner" does not exist
, in query ALTER TABLE "res_partner" ALTER COLUMN "name" DROP NOT NULL
2014-07-29 10:40:50,160 25164 CRITICAL demo_8 openerp.service.server: Failed to initialize database `demo_8`.
Traceback (most recent call last):
  File "/home/elbati/workspace/odoo/buildout_cfg-odoo-8/parts/odoo/openerp/service/server.py", line 901, in preload_registries
    registry = RegistryManager.new(dbname, update_module=update_module)
  File "/home/elbati/workspace/odoo/buildout_cfg-odoo-8/parts/odoo/openerp/modules/registry.py", line 322, in new
    openerp.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/home/elbati/workspace/odoo/buildout_cfg-odoo-8/parts/odoo/openerp/modules/loading.py", line 357, in load_modules
    loaded_modules, update_module)
  File "/home/elbati/workspace/odoo/buildout_cfg-odoo-8/parts/odoo/openerp/modules/loading.py", line 263, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
  File "/home/elbati/workspace/odoo/buildout_cfg-odoo-8/parts/odoo/openerp/modules/loading.py", line 163, in load_module_graph
    init_module_models(cr, package.name, models)
  File "/home/elbati/workspace/odoo/buildout_cfg-odoo-8/parts/odoo/openerp/modules/module.py", line 276, in init_module_models
    result = obj._auto_init(cr, {'module': module_name})
  File "/home/elbati/workspace/odoo/buildout_cfg-odoo-8/parts/odoo/openerp/api.py", line 204, in wrapper
    return old_api(self, *args, **kwargs)
  File "/home/elbati/workspace/odoo/buildout_cfg-odoo-8/parts/odoo/openerp/models.py", line 2582, in _auto_init
    cr.execute('ALTER TABLE "%s" ALTER COLUMN "%s" DROP NOT NULL' % (self._table, k))
  File "/home/elbati/workspace/odoo/buildout_cfg-odoo-8/parts/odoo/openerp/sql_db.py", line 155, in wrapper
    return f(self, *args, **kwargs)
  File "/home/elbati/workspace/odoo/buildout_cfg-odoo-8/parts/odoo/openerp/sql_db.py", line 230, in execute
    res = self._obj.execute(query, params)
ProgrammingError: column "name" of relation "res_partner" does not exist

@eLBati
Copy link
Member Author

eLBati commented Jul 29, 2014

I fixed the error overriding _set_default_value_on_column instead of init: eLBati@ae4c47d

I also fixed PEP8 for the whole repo, but travis doesn't collaborate and doesn't rebuild

@coveralls
Copy link

Coverage Status

Coverage increased (+8.73%) when pulling ecd45fa on eLBati:8.0 into bf69ae2 on OCA:8.0.

cr.execute('SELECT id FROM res_partner WHERE lastname IS NOT NULL '
'Limit 1')
if not cr.fetchone():
cr.execute('UPDATE res_partner set lastname = name WHERE name '
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you do it always? It will affect 0 or n rows, but it's as fast as making a select.

@pedrobaeza
Copy link
Member

Please force a Travis rebuild making this in local repository in the updated PR branch:

git commit --ammend
git push <name_of_the_remote> <name_of_the_PR_branch> -f

Regards.

@bwrsandman
Copy link
Contributor

@pedrobaeza I can restart the build without having to do any amending

Done

@pedrobaeza
Copy link
Member

OK, as you want. It was only a trick I have discovered, because I don't have on some branches the possibility to make a rebuild on Travis.

@eLBati
Copy link
Member Author

eLBati commented Jul 30, 2014

Travis connection error is still there

@pedrobaeza
Copy link
Member

I don't know why is this happening. I haven't seen this error before in any repository.

@eLBati
Copy link
Member Author

eLBati commented Jul 30, 2014

On 07/30/2014 09:31 AM, Pedro M. Baeza wrote:

I don't know why is this happening. I haven't seen this error before
in any repository.

It should be a temporary connection problem while downloading a PIP package

@bwrsandman
Copy link
Contributor

Restarted build

@coveralls
Copy link

Coverage Status

Coverage increased (+9.15%) when pulling c792e1b on eLBati:8.0 into bf69ae2 on OCA:8.0.

@bwrsandman
Copy link
Contributor

Still errored from pip install -r /home/travis/maintainer-quality-tools/travis/requirements.txt

@eLBati
Copy link
Member Author

eLBati commented Jul 30, 2014

@bwrsandman
Copy link
Contributor

At
https://travis-ci.org/OCA/partner-contact/builds/31171276#L327
I see

error: [Errno 104] Connection reset by peer

Storing debug log for failure in /home/travis/.pip/pip.log

The command "travis_install_nightly ${VERSION}" failed and exited with 2 during .

Browse cache error, sorry.

@bwrsandman
Copy link
Contributor

All is well.
Thank you for your patience.
👍

@bwrsandman
Copy link
Contributor

You sure you don't want to convert it to the new api?

https://github.com/nbessi/odoo_new_api_guideline

@pedrobaeza
Copy link
Member

👍

Thanks.

@nbessi
Copy link
Contributor

nbessi commented Aug 4, 2014

@bwrsandman I would prefer it too as it is quite a small addons, But nothing was formely decide by OCA. I have allready made this work during partner day work shop.

https://code.launchpad.net/~camptocamp/partner-contact-management/partner-first-name-new-api-v8

I should port this MP to github now that view and model are mostly frozen.

Regards

Nicolas

@bwrsandman
Copy link
Contributor

I have a feeling that if we don't port while converting to v8 (which we often do minimalistically), we will only have modules in the new API from people who feel like doing it.

@nbessi Can your openerp-conventions be made to test for the new API this on v8s?

'SET NOT NULL')
_logger.info("NOT NULL constraint for "
"res_partner.lastname correctly set")
return res

Copy link
Sponsor Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why to not use install hooks?
odoo/odoo@4105b5f

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why to not use install hooks?
odoo/odoo@4105b5f
odoo/odoo@4105b5f

How?

Anyway, I think _set_default_value_on_column is the right place to
do it, as we are doing just that: setting a default value for the new
column lastname and adding the NOT NULL constraint on it

Copy link
Sponsor Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After reading the code in openerp.models, you're right, the set_default_value_on_column is the right way to do it since it's only called on the first installation or when upgrading the module 'ONLY' if the 'Not null' constrains is not yet applied. In proposing the 'install hooks', I wanted to avoid that this operation (_set_default_value_on_calumn) is called each time the module is upgraded.

@eLBati
Copy link
Member Author

eLBati commented Aug 4, 2014

On 07/30/2014 04:50 PM, Sandy wrote:

You sure you don't want to convert it to the new api?

https://github.com/nbessi/odoo_new_api_guideline

I'm sure it would be good 😏

I just have no time in these days.

@bwrsandman
Copy link
Contributor

I tired it. It is not an easy port...

Coverting create to @api.one means the api will drop the 'name' value for res users when creating related partner.

However, using the new fields, especially the compute fields are really good.

@nbessi
Copy link
Contributor

nbessi commented Aug 5, 2014

@bwrsandman I'm working on convention on my free time.
I have made major refactoring to support both API version and have all the correct bases to add required checks. I'm working on redefining name space correctly and intergrate stuff with travis. But I do not expect a release before the end of august.

@bwrsandman
Copy link
Contributor

We have two approves so far. Are we ready to merge or are there still objections?

@JonathanNEMRY
Copy link

👍

@hbrunn
Copy link
Member

hbrunn commented Aug 11, 2014

👍 - using the new api shouldn't be a prerequisite for porting currently, maybe at a later point.

hbrunn added a commit that referenced this pull request Aug 11, 2014
[ADD] partner_firstname for v8
@hbrunn hbrunn merged commit 332ca70 into OCA:8.0 Aug 11, 2014
JonathanNEMRY pushed a commit to acsone/partner-contact that referenced this pull request Sep 24, 2015
Code Cleanup and Rename rectification
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants