purchase_analytic_plans module won't work when grouping purchase orders

Registered by Raphaël Valyi - http://www.akretion.com

This blueprint originated from the following bug report that couldn't be fixed for v5:
https://bugs.launchpad.net/bugs/321873

Hi,

Take a fresh install, right on trunk, manufacturing profile for instance.
Install the addons/purchase_analytic_plans module

Create 2 sale orders to the same supplier, each with one product line at least.
For those 2 product purchase order lines, enter an "analytic distribution" (create some)
No need to validate the purchase orders, just save them
Now go in the purchase order list view
Select the two purchase orders
Click on 'action' in the tool bar and chose "merge purchase orders"

The bug is that in the new created merged purchase order, the purchase
lines lost their analytic distribution (analytics_id field)!

The problem is that the purchase/wizard/wizard_group.py wizard has the
purchase order lines fields somewhat hardcoded. indeed, the following
code:

       for order_line in porder.order_line:
           line_key = make_key(order_line, ('name', 'date_planned', 'taxes_id', 'price_unit', 'notes', 'product_id', 'move_dest_id', 'account_analytic_id'))

won't cope with any purchase.order.line extension like the
purchase_analytic_plans does. It doesn't provide any chance to subclass
something and add the missing keys either.

In the same way, the following code:

       order_infos = new_order[0]
       if not order_infos:
           order_infos.update({
               'origin': porder.origin,
               'date_order': time.strftime('%Y-%m-%d'),
               'partner_id': porder.partner_id.id,
               'partner_address_id': porder.partner_address_id.id,
               'dest_address_id': porder.dest_address_id.id,
               'warehouse_id': porder.warehouse_id.id,
               'location_id': porder.location_id.id,
               'pricelist_id': porder.pricelist_id.id,
               'state': 'draft',
               'order_line': {},
               'notes': '%s' % (porder.notes or '',),
           })

won't take new purchase order extension fields into accounts, while this
might be less important than for the purchase order lines.

Suggestion:
1) avoid to hardcode the purchase order line keys f possible
2) extract some overridable method so extension modules like purchase_analytic_plans can add their own keys.

Finally, this will happen with other third party modules too.

Hope this helps,

Raphaël Valyi.

note from Raphaël Valyi:
-> Hello Harry, I promise to check this as soon as possible, this is great news indeed.

Blueprint information

Status:
Not started
Approver:
None
Priority:
Undefined
Drafter:
None
Direction:
Needs approval
Assignee:
None
Definition:
New
Series goal:
None
Implementation:
Unknown
Milestone target:
None

Related branches

Sprints

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.