← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~akretion-team/carriers-deliveries/7-add-base-class-for-carrier-configs into lp:carriers-deliveries

 

Florian da Costa has proposed merging lp:~akretion-team/carriers-deliveries/7-add-base-class-for-carrier-configs into lp:carriers-deliveries.

Requested reviews:
  Yannick Vaucher @ Camptocamp (yvaucher-c2c)

For more details, see:
https://code.launchpad.net/~akretion-team/carriers-deliveries/7-add-base-class-for-carrier-configs/+merge/224598

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
-- 
https://code.launchpad.net/~akretion-team/carriers-deliveries/7-add-base-class-for-carrier-configs/+merge/224598
Your team Stock and Logistic Core Editors is subscribed to branch lp:carriers-deliveries.
=== modified file 'base_delivery_carrier_label/delivery.py'
--- base_delivery_carrier_label/delivery.py	2014-03-31 08:09:39 +0000
+++ base_delivery_carrier_label/delivery.py	2014-06-26 11:33:03 +0000
@@ -96,3 +96,41 @@
             'delivery.carrier.option',
             'carrier_id', 'Option'),
     }
+
+
+class CarrierAccount(orm.Model):
+    _name = 'carrier.account'
+    _description = 'Base account datas'
+
+    def _get_carrier_type(self, cr, uid, context=None):
+        """ To inherit to add carrier type like Chronopost, Postlogistics..."""
+        return []
+
+    def __get_carrier_type(self, cr, uid, context=None):
+        """ Wrapper to preserve inheritance for selection field """
+        return self._get_carrier_type(cr, uid, context=context)
+
+    def _get_file_format(self, cr, uid, context=None):
+        """ To inherit to add label file types"""
+        return [('PDF', 'PDF'),
+                ('SPD', 'SPD'),
+                ('PPR', 'PPR'),
+                ('THE', 'THE'),
+                ('ZPL', 'ZPL'),
+                ('XML', 'XML')]
+
+    def __get_file_format(self, cr, uid, context=None):
+        """ Wrapper to preserve inheritance for selection field """
+        return self._get_file_format(cr, uid, context=context)
+
+    _columns = {
+        'name': fields.char('Name', size=64, required=True),
+        'account': fields.char('Account Number', size=32, required=True),
+        'password': fields.char('Account Password', size=32, required=True),
+        'file_format': fields.selection(__get_file_format, 'File Format',
+            help="Default format of the carrier's label you want to print"),
+        'type': fields.selection(__get_carrier_type, 'Type', required=True,
+            help="In case of several carriers, help to know which account belong to which carrier"),
+    }
+
+


Follow ups