Merge lp:~camptocamp/carriers-deliveries/7.0-change-class-name-to-avoid-error_rde into lp:~stock-logistic-core-editors/carriers-deliveries/7.0

Proposed by Romain Deheele - Camptocamp
Status: Merged
Merged at revision: 41
Proposed branch: lp:~camptocamp/carriers-deliveries/7.0-change-class-name-to-avoid-error_rde
Merge into: lp:~stock-logistic-core-editors/carriers-deliveries/7.0
Diff against target: 25 lines (+3/-3)
1 file modified
base_delivery_carrier_files_document/carrier_file.py (+3/-3)
To merge this branch: bzr merge lp:~camptocamp/carriers-deliveries/7.0-change-class-name-to-avoid-error_rde
Reviewer Review Type Date Requested Status
Yannick Vaucher @ Camptocamp Approve
Stefan Rijnhart (Opener) Approve
Pedro Manuel Baeza code review Approve
Leonardo Pistone Approve
Alexandre Fayolle - camptocamp code review, no test Approve
Review via email: mp+213881@code.launchpad.net

Description of the change

Hi,

In base_delivery_carrier_files_document, file carrier_file.py,
by coincidence, the class and a frequently used parameter are both named "carrier_file".
in l.61, the super method will take carrier_file parameter while it needs carrier_file, the class name.
It causes logically the error : TypeError: 'must be type, not browse_record'

Great catch from Leonardo Pistone, thank you.

Regards,

Romain

To post a comment you must log in.
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

LGTM

review: Approve (code review, no test)
Revision history for this message
Leonardo Pistone (lepistone) wrote :

thanks

review: Approve
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

A frequent problem if you put a common python class name...

Thanks for the patch.

Regards.

review: Approve (code review)
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Maybe take the occasion to switch the affected code to the Python convention for CapCase class names, which prevents this problem? http://legacy.python.org/dev/peps/pep-0008/#class-names

review: Needs Information
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

+1 for Stefan comment

Revision history for this message
Leonardo Pistone (lepistone) wrote :

I abstain on Stefan's remark.

I would love to see python conventions like that one to be used. The habit to have in OpenERP the class name with underscores is perhaps because normally that makes the class name correspond to the table name (in fact, the table name is _name with dots changed to underscores).

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Sure, but the mapping from class 'CarrierFile' (instead of 'carrier_file') to model 'carrier.file' is still equally obvious.

Revision history for this message
Leonardo Pistone (lepistone) wrote :

Stefan, what I mean is that I prefer CamelCase too, but I abstain here because SA uses underscores all over the place.

42. By Romain Deheele - Camptocamp

[UPD] class name : switch with CapWords convention

Revision history for this message
Romain Deheele - Camptocamp (romaindeheele) wrote :

ok for CapWords convention, thanks Stefan.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Thanks for taking my suggestion!

review: Approve
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'base_delivery_carrier_files_document/carrier_file.py'
2--- base_delivery_carrier_files_document/carrier_file.py 2014-03-27 14:49:41 +0000
3+++ base_delivery_carrier_files_document/carrier_file.py 2014-04-03 16:45:52 +0000
4@@ -24,11 +24,11 @@
5 from openerp.osv import orm, fields
6
7
8-class carrier_file(orm.Model):
9+class CarrierFile(orm.Model):
10 _inherit = 'delivery.carrier.file'
11
12 def get_write_mode_selection(self, cr, uid, context=None):
13- res = super(carrier_file, self).\
14+ res = super(CarrierFile, self).\
15 get_write_mode_selection(cr, uid, context=context)
16 if 'document' not in res:
17 res.append(('document', 'Document'))
18@@ -58,6 +58,6 @@
19 self.pool['ir.attachment'].create(cr, uid, vals, context=context)
20 return True
21 else:
22- return (super(carrier_file, self)
23+ return (super(CarrierFile, self)
24 ._write_file(cr, uid, carrier_file, filename, file_content,
25 context=None))

Subscribers

People subscribed via source and target branches