Merge lp:~akretion-team/carriers-deliveries/7-base-delivery-carrier-dbl into lp:~stock-logistic-core-editors/carriers-deliveries/7.0

Proposed by David BEAL (ak)
Status: Merged
Merged at revision: 51
Proposed branch: lp:~akretion-team/carriers-deliveries/7-base-delivery-carrier-dbl
Merge into: lp:~stock-logistic-core-editors/carriers-deliveries/7.0
Diff against target: 28 lines (+18/-0)
1 file modified
base_delivery_carrier_label/stock.py (+18/-0)
To merge this branch: bzr merge lp:~akretion-team/carriers-deliveries/7-base-delivery-carrier-dbl
Reviewer Review Type Date Requested Status
Pedro Manuel Baeza code review Approve
Sébastien BEAU - http://www.akretion.com Approve
Yannick Vaucher @ Camptocamp code review Approve
Review via email: mp+221226@code.launchpad.net

Description of the change

add _customize_sender_address method to base_delivery_carrier_label module

Some companies have differents brands, shop or backend and they ship
parcels from each brands without customer knows the real name of the company.

This method does nothing by itself.

It's just a common way to set this info. Python 'super' use allow to override values

Each module carrier module have to implement its own method.

To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, David, docstring convention says that you have to put one-line doc with three ".

Regards.

review: Needs Fixing (code review)
50. By David BEAL (ak)

[FIX] docstring

Revision history for this message
David BEAL (ak) (davidbeal) wrote :

Hi Pedro,

Thanks for the review, I fixed it

Here is a use case of sender customization
http://bazaar.launchpad.net/~akretion-team/+junk/sale-multi-shop/view/head:/shop_sender/stock.py

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

Thanks for the changes. I'm thinking that if the method is intended for customizing sender address, you should return a dictionary that it's written on base module, because in this way, you have to do it your way in your custom module and inheritance is not possible in this way.

You can see one of this type of hooks in prepare_inv_line of sale module.

Regards.

review: Needs Fixing (code review)
51. By David BEAL (ak)

[FIX] _customize_sender_address return method

Revision history for this message
David BEAL (ak) (davidbeal) wrote :

Hi Pedro,

You're right, it's cleaner to have a real return and set a default behavior.

I changed my code to return a partner.
The code is cleaner in shop_sender module.

Thanks for your advices

Regards

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

Hi again, David, one thing I don't see is where you use the value returned by this method. Is there something I'm missing?

Regards.

review: Needs Information (code review)
Revision history for this message
David BEAL (ak) (davidbeal) wrote :
52. By David BEAL (ak)

[IMP] add comment in _customize_sender_adress()

53. By David BEAL (ak)

[FIX] method name to get sender address

54. By David BEAL (ak)

[FIX] method comment

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

As itself base_delivery_carrier_label module only provide an interface class, this method here makes sense.

LGTM

review: Approve (code review)
Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote :

LGTM, I agree too. It's only an abstract module that provider a standard API for real implementation

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

OK, I see. Thanks for the clarification.

I approve it and proceed with the merge.

Regards.

review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'base_delivery_carrier_label/stock.py'
2--- base_delivery_carrier_label/stock.py 2014-03-28 13:19:50 +0000
3+++ base_delivery_carrier_label/stock.py 2014-06-17 11:16:57 +0000
4@@ -355,6 +355,24 @@
5 return picking_obj.action_generate_carrier_label(
6 cr, uid, ids, context=context)
7
8+ def _get_label_sender_address(self, cr, uid, picking, context=None):
9+ """ On each carrier label module you need to define
10+ which is the sender of the parcel.
11+ The most common case is 'picking.company_id.partner_id'
12+ which is suitable for each delivery carrier label module.
13+ But your client might want to customize sender address
14+ if he has several brands and/or shops in his company.
15+ In this case he doesn't want his customer to see
16+ the address of his company in his transport label
17+ but instead, the address of the partner linked to his shop/brand
18+
19+ To reach this modularity, call this method to get sender address
20+ in your delivery_carrier_label_yourcarrier module, then every developer
21+ can manage specific needs by inherit this method in module like :
22+ delivery_carrier_label_yourcarrier_yourproject.
23+ """
24+ return picking.company_id.partner_id
25+
26 def carrier_id_change(self, cr, uid, ids, carrier_id, context=None):
27 """ Inherit this method in your module """
28 picking_obj = self.pool.get('stock.picking')

Subscribers

People subscribed via source and target branches