Merge lp:~akretion-team/openobject-addons/date_planned_refactor into lp:openobject-addons

Proposed by Benoit Guillot - http://www.akretion.com
Status: Merged
Merged at revision: 6077
Proposed branch: lp:~akretion-team/openobject-addons/date_planned_refactor
Merge into: lp:openobject-addons
Diff against target: 25 lines (+6/-2)
1 file modified
sale/sale.py (+6/-2)
To merge this branch: bzr merge lp:~akretion-team/openobject-addons/date_planned_refactor
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+86362@code.launchpad.net

Description of the change

This is a refactoring of date_planned in order to overload it easily. I just defined a new function : _get_date_planned. I need it for a module calculating the delivery delays and managing the supplier shortages.

To post a comment you must log in.
Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

Hello Benoît,

Overall I agree with the idea, but technically could you please consider my last commit here:
https://code.launchpad.net/~akretion-team/openobject-addons/sale-modular-picking-better-context/+merge/82944
(that is http://bazaar.launchpad.net/~akretion-team/openobject-addons/sale-modular-picking-better-context/revision/6026 )

So as you can see, according to our recent discussions on LP, we assume that ideally methods called by workflow action have a normal context aware signature. My last commit bring that normalization to the methods I recently refactored. I'm now requesting the merge of 82944 to OpenERP SA. Could you please refactor your method to have a context as the last arg like if my merge were approved already?

Thanks.

Revision history for this message
Benoit Guillot - http://www.akretion.com (benoit-guillot-z) wrote :

Hello Raphaël,

I changed the method with context as the last arg.

Revision history for this message
Benoit Guillot - http://www.akretion.com (benoit-guillot-z) wrote :

Hum actually the merge as already been done, but you can change the method in your merge if you want. Otherwise I can propose a new merge with the modifications.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'sale/sale.py'
2--- sale/sale.py 2011-12-19 21:47:45 +0000
3+++ sale/sale.py 2011-12-20 10:10:07 +0000
4@@ -771,6 +771,11 @@
5 self.pool.get('procurement.order').write(cr, uid, [proc_id], {'product_qty': mov.product_qty, 'product_uos_qty': mov.product_uos_qty})
6 return True
7
8+ def _get_date_planned(self, cr, uid, order, line, start_date, *args):
9+ date_planned = datetime.strptime(start_date, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(days=line.delay or 0.0)
10+ date_planned = (date_planned - timedelta(days=order.company_id.security_lead)).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
11+ return date_planned
12+
13 def _create_pickings_and_procurements(self, cr, uid, order, order_lines, picking_id=False, *args):
14 """Create the required procurements to supply sale order lines, also connecting
15 the procurements to appropriate stock moves in order to bring the goods to the
16@@ -799,8 +804,7 @@
17 if line.state == 'done':
18 continue
19
20- date_planned = datetime.strptime(order.date_order, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(days=line.delay or 0.0)
21- date_planned = (date_planned - timedelta(days=order.company_id.security_lead)).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
22+ date_planned = self._get_date_planned(cr, uid, order, line, order.date_order, *args)
23
24 if line.product_id:
25 if line.product_id.product_tmpl_id.type in ('product', 'consu'):

Subscribers

People subscribed via source and target branches

to all changes: