Merge lp:~akretion-team/carriers-deliveries/7-add-base-class-for-carrier-configs into lp:~stock-logistic-core-editors/carriers-deliveries/7.0

Proposed by Florian da Costa
Status: Needs review
Proposed branch: lp:~akretion-team/carriers-deliveries/7-add-base-class-for-carrier-configs
Merge into: lp:~stock-logistic-core-editors/carriers-deliveries/7.0
Diff against target: 45 lines (+38/-0)
1 file modified
base_delivery_carrier_label/delivery.py (+38/-0)
To merge this branch: bzr merge lp:~akretion-team/carriers-deliveries/7-add-base-class-for-carrier-configs
Reviewer Review Type Date Requested Status
David BEAL (ak) Pending
Sébastien BEAU - http://www.akretion.com Pending
Yannick Vaucher @ Camptocamp Pending
Review via email: mp+224598@code.launchpad.net

Description of the change

Add a new class to configure the specific Carrier Accounts.
The purpose of this class is to be inherited by specific carrier modules so they add their specificities.

You can find an example of use here (the module is still work in progress)

http://bazaar.launchpad.net/~florian-dacosta/+junk/delivery_carrier_chronopost/view/head:/delivery_carrier_chronopost/config.py

To post a comment you must log in.
Revision history for this message
David BEAL (ak) (davidbeal) wrote :

Thank you florian,

Ok for me

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

This project is now hosted on https://github.com/OCA/carriers-deliveries. Please move your proposal there if you still want to merge it once fixed. This guide may help you https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub

Unmerged revisions

53. By Florian da Costa

[FIX] method comment

52. By Florian da Costa

[IMP] Add class CarrierAccount, so the specifics carriers modules use all the same base inheriting this one

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'base_delivery_carrier_label/delivery.py'
2--- base_delivery_carrier_label/delivery.py 2014-03-31 08:09:39 +0000
3+++ base_delivery_carrier_label/delivery.py 2014-06-26 11:33:03 +0000
4@@ -96,3 +96,41 @@
5 'delivery.carrier.option',
6 'carrier_id', 'Option'),
7 }
8+
9+
10+class CarrierAccount(orm.Model):
11+ _name = 'carrier.account'
12+ _description = 'Base account datas'
13+
14+ def _get_carrier_type(self, cr, uid, context=None):
15+ """ To inherit to add carrier type like Chronopost, Postlogistics..."""
16+ return []
17+
18+ def __get_carrier_type(self, cr, uid, context=None):
19+ """ Wrapper to preserve inheritance for selection field """
20+ return self._get_carrier_type(cr, uid, context=context)
21+
22+ def _get_file_format(self, cr, uid, context=None):
23+ """ To inherit to add label file types"""
24+ return [('PDF', 'PDF'),
25+ ('SPD', 'SPD'),
26+ ('PPR', 'PPR'),
27+ ('THE', 'THE'),
28+ ('ZPL', 'ZPL'),
29+ ('XML', 'XML')]
30+
31+ def __get_file_format(self, cr, uid, context=None):
32+ """ Wrapper to preserve inheritance for selection field """
33+ return self._get_file_format(cr, uid, context=context)
34+
35+ _columns = {
36+ 'name': fields.char('Name', size=64, required=True),
37+ 'account': fields.char('Account Number', size=32, required=True),
38+ 'password': fields.char('Account Password', size=32, required=True),
39+ 'file_format': fields.selection(__get_file_format, 'File Format',
40+ help="Default format of the carrier's label you want to print"),
41+ 'type': fields.selection(__get_carrier_type, 'Type', required=True,
42+ help="In case of several carriers, help to know which account belong to which carrier"),
43+ }
44+
45+

Subscribers

People subscribed via source and target branches