Merge lp:~initos.com/openerp-connector-magento/7.0-small-kwargs-improvement-sale into lp:~openerp-connector-core-editors/openerp-connector-magento/7.0

Proposed by Thomas Rehn
Status: Needs review
Proposed branch: lp:~initos.com/openerp-connector-magento/7.0-small-kwargs-improvement-sale
Merge into: lp:~openerp-connector-core-editors/openerp-connector-magento/7.0
Diff against target: 17 lines (+4/-3)
1 file modified
magentoerpconnect/sale.py (+4/-3)
To merge this branch: bzr merge lp:~initos.com/openerp-connector-magento/7.0-small-kwargs-improvement-sale
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp Needs Resubmitting
Review via email: mp+223564@code.launchpad.net

Description of the change

The method 'search' of the SaleOrderAdapter uses keyword arguments. This code branch changes the call so that is uses keyword arguments. This allows inheriting classes to be lazy and do something like

def search(self, filters=None, **kwargs):
    # add state to filters
    filters = filters or {}
    filters['state'] = 'complete'
    return super(mySaleOrderAdapter, self).search(filters=filters,
        **kwargs)

instead of explicitly writing down all other keyword arguments.

I know that there are some other places in the code where functions are not called by keyword. With this merge proposal I want to start a discussion if such a change goes in the right direction. Its obvious disadvantage is that it makes the call a bit more cumbersome.

To post a comment you must log in.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

I totally agree that keyword arguments should be called using the keyword.

I have just one remark about pep8 regarding the indentation, it says "Arguments on first line forbidden when not using vertical alignment" [0]

So I propose to write

    record_ids = self.backend_adapter.search(
        filters=filters,
        from_date=from_date,
        magento_storeview_ids=magento_storeview_ids)

[0] ref: http://legacy.python.org/dev/peps/pep-0008/#indentation

1004. By Thomas Rehn

make change pep-8 compliant

Revision history for this message
Thomas Rehn (thomas-rehn) wrote :

Thanks for the hint. I improved the code in my branch. I will keep my eyes open for other keyword-function calls that could be improved.

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Thanks!

review: Approve (code review)
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

This project is now hosted on https://github.com/OCA/connector-magento. Please move your proposal there. This guide may help you https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub

review: Needs Resubmitting

Unmerged revisions

1004. By Thomas Rehn

make change pep-8 compliant

1003. By Thomas Rehn

keyword arguments should be called as such

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'magentoerpconnect/sale.py'
2--- magentoerpconnect/sale.py 2014-05-26 11:25:41 +0000
3+++ magentoerpconnect/sale.py 2014-06-18 14:20:45 +0000
4@@ -273,9 +273,10 @@
5 filters['state'] = {'neq': 'canceled'}
6 from_date = filters.pop('from_date', None)
7 magento_storeview_ids = [filters.pop('magento_storeview_id')]
8- record_ids = self.backend_adapter.search(filters,
9- from_date,
10- magento_storeview_ids)
11+ record_ids = self.backend_adapter.search(
12+ filters=filters,
13+ from_date=from_date,
14+ magento_storeview_ids=magento_storeview_ids)
15 _logger.info('search for magento saleorders %s returned %s',
16 filters, record_ids)
17 for record_id in record_ids: