Merge lp:~manu-tiedra/openobject-addons/trunk into lp:openobject-addons

Proposed by Manu
Status: Rejected
Rejected by: Olivier Dony (Odoo)
Proposed branch: lp:~manu-tiedra/openobject-addons/trunk
Merge into: lp:openobject-addons
Diff against target: 125 lines (+23/-4)
5 files modified
delivery/delivery_view.xml (+2/-0)
delivery/partner.py (+1/-1)
delivery/sale.py (+7/-1)
delivery/stock.py (+11/-1)
delivery/wizard/delivery_sale_order.py (+2/-1)
To merge this branch: bzr merge lp:~manu-tiedra/openobject-addons/trunk
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+77953@code.launchpad.net

Commit message

[IMP] Delivery module: support for carrier tracking when using the "Delivery Cost" button in a sale order

We can not work with the current delivery module as is because we need to track the delivery.carrier assigned to each picking in order to create a text file that integrates with the logistic platform of the carrier.
The standard delivery module has a field called carrier_id, displayed as Delivery Method that is used to track the carrier used but also has a second meaning: when the field is set, it means that the system should compute the shipping costs of the picking when creating the invoice for the picking.

Unfortunately there are companies that use the "Delivery Costs" button in the sales order to add the delivery costs to the sale order. When this is done, filling the Delivery Method field of the sale.order would cause the invoice to have another line added because that field is used to indicate the delivery.carrier and that the system should compute the shipping costs of the picking when creating the invoice for the picking. This led these kind of companies with the problem that they can not track the carrier used in the shipments. However, this can easily be fixed as I have done:

* I have added another field to the sale.order and to the stock.picking called invoice_shipping_after_picking (displayed as Auto-Invoice Delivery) that controls if the system needs to add the delivery line to the invoice.
* the carrier_id field (displayed as Delivery Method) will be used to indicate the carrier used to ship the order, and in the picking the carrier used to ship the picking. This way I have splitted the previous functionality of the carrier_id field in two fields as it was really doing two things (specifying the carrier and telling the system to invoice the delivery after picking).
* I have changed the wizard that adds the delivery costs to a sale.order. Now when the delivery costs are added to the sale order, the carrier_id is set to the carrier selected in the wizard and the invoice_shipping_after_picking field is set to false as the delivery line has been added. If the user never clicks on the Delivery Cost button, the system will behave as expected as the default value for invoice_shipping_after_picking is true.
* when creating the invoice from the picking, I check the invoice_shipping_after_picking field and if it is not set, it won't try to add the delivery line to the invoices.
* this branch also fixes bug 625235

With this solution you can know the carrier used if you add the delivery costs manually or if they get added later, so it seems more natural.

As I said before, this changes are critical for us now so please tell me if I need to change anything to get this merged ASAP.

Thank you very much.

Description of the change

[IMP] Delivery module: support for carrier tracking when using the "Delivery Cost" button in a sale order

We can not work with the current delivery module as is because we need to track the delivery.carrier assigned to each picking in order to create a text file that integrates with the logistic platform of the carrier.
The standard delivery module has a field called carrier_id, displayed as Delivery Method that is used to track the carrier used but also has a second meaning: when the field is set, it means that the system should compute the shipping costs of the picking when creating the invoice for the picking.

Unfortunately there are companies that use the "Delivery Costs" button in the sales order to add the delivery costs to the sale order. When this is done, filling the Delivery Method field of the sale.order would cause the invoice to have another line added because that field is used to indicate the delivery.carrier and that the system should compute the shipping costs of the picking when creating the invoice for the picking. This led these kind of companies with the problem that they can not track the carrier used in the shipments. However, this can easily be fixed as I have done:

* I have added another field to the sale.order and to the stock.picking called invoice_shipping_after_picking (displayed as Auto-Invoice Delivery) that controls if the system needs to add the delivery line to the invoice.
* the carrier_id field (displayed as Delivery Method) will be used to indicate the carrier used to ship the order, and in the picking the carrier used to ship the picking. This way I have splitted the previous functionality of the carrier_id field in two fields as it was really doing two things (specifying the carrier and telling the system to invoice the delivery after picking).
* I have changed the wizard that adds the delivery costs to a sale.order. Now when the delivery costs are added to the sale order, the carrier_id is set to the carrier selected in the wizard and the invoice_shipping_after_picking field is set to false as the delivery line has been added. If the user never clicks on the Delivery Cost button, the system will behave as expected as the default value for invoice_shipping_after_picking is true.
* when creating the invoice from the picking, I check the invoice_shipping_after_picking field and if it is not set, it won't try to add the delivery line to the invoices.
* this branch also fixes bug 625235

With this solution you can know the carrier used if you add the delivery costs manually or if they get added later, so it seems more natural.

As I said before, this changes are critical for us now so please tell me if I need to change anything to get this merged ASAP.

Thank you very much.

To post a comment you must log in.
Revision history for this message
Manu (manu-tiedra) wrote :

Any news on this one? I got a "rejected" and "needs review" messages from Fabien last month but nothing new since then.

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Hello Manu,

Sorry for the response delay, we're rather overloaded with merge proposals and the preparation of OpenERP 6.1.
Your merge proposal looks good on a technical level, but functionally we'd prefer to keep this feature in an extra module rather than modifying the logic of the original delivery module (currently the carrier_id field added by the delivery module on sale_order has only one meaning: the invoicing to be done).

I imagine it would have been quite dirty to do this in an extra module with the current state of the code, so I've just applied a quick refactoring to the delivery module, extracting a new '_prepare_shipping_invoice_line' method for preparing the creation of the shipping invoice line (see [2]). This should make it easier for you to implement what you need in an extra module.

Once your module is ready, don't hesitate to publish it on OpenERP Apps, it may be useful for other users!
See also our updated merge proposal policy and guidelines [3].

Thanks for your understanding and for your contributions!

PS: Concerning bug 625235, you'll be glad to see it was finally fixed along with bug 816138, so the patch is unnecessary now.

[1] addons rev.5395 revid:<email address hidden>
[2] http://bazaar.launchpad.net/~<email address hidden>
[3] http://bit.ly/openerp-contrib-mp

Revision history for this message
Manu (manu-tiedra) wrote :

Olivier,

thank you very much for looking into it.

I was afraid that you would reject my merge proposal. However, in that case, what I really wanted was the possibility to add the functionallity I needed to the delivery module (currently it was complex to add as the module wasn't extensible). So I'm really glad you made those changes.

I will add my changes on the top of that as a module.

Keep on your great work! 6.1 will be awesome.

Unmerged revisions

5290. By Manu

We can not work with the current delivery module as is because we need to track the delivery.carrier assigned to each picking in order to create a text file that integrates with the logistic platform of the carrier.
The standard delivery module has a field called carrier_id, displayed as Delivery Method that is used to track the carrier used but also has a second meaning: when the field is set, it means that the system should compute the shipping costs of the picking when creating the invoice for the picking.

Unfortunately there are companies that use the "Delivery Costs" button in the sales order to add the delivery costs to the sale order. When this is done, filling the Delivery Method field of the sale.order would cause the invoice to have another line added because that field is used to indicate the delivery.carrier and that the system should compute the shipping costs of the picking when creating the invoice for the picking. This led these kind of companies with the problem that they can not track the carrier used in the shipments. However, this can easily be fixed as I have done:

* I have added another field to the sale.order and to the stock.picking called invoice_shipping_after_picking (displayed as Auto-Invoice Delivery) that controls if the system needs to add the delivery line to the invoice.
* the carrier_id field (displayed as Delivery Method) will be used to indicate the carrier used to ship the order, and in the picking the carrier used to ship the picking. This way I have splitted the previous functionality of the carrier_id field in two fields as it was really doing two things (specifying the carrier and telling the system to invoice the delivery after picking).
* I have changed the wizard that adds the delivery costs to a sale.order. Now when the delivery costs are added to the sale order, the carrier_id is set to the carrier selected in the wizard and the invoice_shipping_after_picking field is set to false as the delivery line has been added. If the user never clicks on the Delivery Cost button, the system will behave as expected as the default value for invoice_shipping_after_picking is true.
* when creating the invoice from the picking, I check the invoice_shipping_after_picking field and if it is not set, it won't try to add the delivery line to the invoices.
* this branch also fixes bug 625235

With this solution you can know the carrier used if you add the delivery costs manually or if they get added later, so it seems more natural.

As I said before, this changes are critical for us now so please tell me if I need to change anything to get this merged ASAP.

Thank you very much.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'delivery/delivery_view.xml'
2--- delivery/delivery_view.xml 2011-10-02 16:12:38 +0000
3+++ delivery/delivery_view.xml 2011-10-03 14:34:22 +0000
4@@ -179,6 +179,7 @@
5 <group name="logistics" position="inside">
6 <field name="id" invisible="True"/>
7 <field name="carrier_id" context="{'order_id':active_id or False}"/>
8+ <field name="invoice_shipping_after_picking"/>
9 </group>
10 </field>
11 </record>
12@@ -193,6 +194,7 @@
13 <field name="carrier_id"/>
14 <field name="carrier_tracking_ref" groups="base.group_extended"/>
15 <field name="number_of_packages" groups="base.group_extended"/>
16+ <field name="invoice_shipping_after_picking"/>
17 <field name="weight"/>
18 <field name="weight_net"/>
19 </field>
20
21=== modified file 'delivery/partner.py'
22--- delivery/partner.py 2011-07-05 12:28:57 +0000
23+++ delivery/partner.py 2011-10-03 14:34:22 +0000
24@@ -30,7 +30,7 @@
25 relation='delivery.carrier',
26 string="Delivery Method",
27 view_load=True,
28- help="This delivery method will be used when invoicing from picking."),
29+ help="The default delivery method for this partner."),
30 }
31 res_partner()
32
33
34=== modified file 'delivery/sale.py'
35--- delivery/sale.py 2011-01-14 00:11:01 +0000
36+++ delivery/sale.py 2011-10-03 14:34:22 +0000
37@@ -25,10 +25,15 @@
38 class sale_order(osv.osv):
39 _inherit = 'sale.order'
40 _columns = {
41- 'carrier_id':fields.many2one("delivery.carrier", "Delivery Method", help="Complete this field if you plan to invoice the shipping based on picking."),
42+ 'carrier_id':fields.many2one("delivery.carrier", "Delivery Method", help="Carrier used for shipping"),
43+ 'invoice_shipping_after_picking': fields.boolean("Auto-Invoice Delivery", help="Check this field if you plan to invoice the shipping based on picking."),
44 'id': fields.integer('ID', readonly=True,invisible=True),
45 }
46
47+ _defaults = {
48+ 'invoice_shipping_after_picking': lambda *a: 1,
49+ }
50+
51 def onchange_partner_id(self, cr, uid, ids, part):
52 result = super(sale_order, self).onchange_partner_id(cr, uid, ids, part)
53 if part:
54@@ -42,6 +47,7 @@
55 pids = [ x.id for x in order.picking_ids]
56 self.pool.get('stock.picking').write(cr, uid, pids, {
57 'carrier_id':order.carrier_id.id,
58+ 'invoice_shipping_after_picking': order.invoice_shipping_after_picking,
59 })
60 return result
61 sale_order()
62
63=== modified file 'delivery/stock.py'
64--- delivery/stock.py 2011-07-01 23:41:24 +0000
65+++ delivery/stock.py 2011-10-03 14:34:22 +0000
66@@ -52,7 +52,8 @@
67 return result.keys()
68
69 _columns = {
70- 'carrier_id':fields.many2one("delivery.carrier","Carrier"),
71+ 'carrier_id':fields.many2one("delivery.carrier","Carrier used for shipping"),
72+ 'invoice_shipping_after_picking': fields.boolean("Auto-Invoice Delivery", help="Check this field if you plan to invoice the shipping based on picking."),
73 'volume': fields.float('Volume'),
74 'weight': fields.function(_cal_weight, type='float', string='Weight', digits_compute= dp.get_precision('Stock Weight'), multi='_cal_weight',
75 store={
76@@ -68,6 +69,10 @@
77 'number_of_packages': fields.integer('Number of Packages'),
78 }
79
80+ _defaults = {
81+ 'invoice_shipping_after_picking': lambda *a: 1,
82+ }
83+
84 def action_invoice_create(self, cursor, user, ids, journal_id=False,
85 group=False, type='out_invoice', context=None):
86 invoice_obj = self.pool.get('account.invoice')
87@@ -90,6 +95,8 @@
88
89 for picking in picking_obj.browse(cursor, user, picking_ids,
90 context=context):
91+ if not picking.invoice_shipping_after_picking:
92+ continue
93 if not picking.carrier_id:
94 continue
95 grid_id = carrier_obj.grid_get(cursor, user, [picking.carrier_id.id],
96@@ -128,6 +135,9 @@
97 'quantity': 1,
98 'invoice_line_tax_id': [(6, 0,taxes_ids)],
99 })
100+
101+ # recalculates taxes because a line may have been added to the invoices in the previous code
102+ invoice_obj.button_compute(cursor, user,invoice_ids, context=context, set_total=True)
103 return result
104
105 stock_picking()
106
107=== modified file 'delivery/wizard/delivery_sale_order.py'
108--- delivery/wizard/delivery_sale_order.py 2011-05-19 12:13:36 +0000
109+++ delivery/wizard/delivery_sale_order.py 2011-10-03 14:34:22 +0000
110@@ -26,7 +26,7 @@
111
112 class make_delivery(osv.osv_memory):
113 _name = "delivery.sale.order"
114- _description = 'Make Delievery'
115+ _description = 'Make Delivery'
116
117 _columns = {
118 'carrier_id': fields.many2one('delivery.carrier','Delivery Method', required=True),
119@@ -111,6 +111,7 @@
120 'tax_id': [(6,0,taxes_ids)],
121 'type': 'make_to_stock'
122 })
123+ order_obj.write(cr, uid, [order.id], {'carrier_id': grid.carrier_id.id, 'invoice_shipping_after_picking': False})
124
125 return {'type': 'ir.actions.act_window_close'}
126

Subscribers

People subscribed via source and target branches

to all changes: