Merge lp:~extra-addons-commiter/e-commerce-addons/7.0-sale-workflow-create_invoice_on into lp:~extra-addons-commiter/e-commerce-addons/7.0

Proposed by Guewen Baconnier @ Camptocamp
Status: Work in progress
Proposed branch: lp:~extra-addons-commiter/e-commerce-addons/7.0-sale-workflow-create_invoice_on
Merge into: lp:~extra-addons-commiter/e-commerce-addons/7.0
Prerequisite: lp:~extra-addons-commiter/e-commerce-addons/7.0-sale-workflow
Diff against target: 150 lines (+55/-24)
5 files modified
sale_automatic_workflow/automatic_workflow_data.xml (+17/-7)
sale_automatic_workflow/sale.py (+16/-0)
sale_automatic_workflow/sale_workflow.xml (+1/-1)
sale_automatic_workflow/sale_workflow_process.py (+19/-14)
sale_automatic_workflow/sale_workflow_process_view.xml (+2/-2)
To merge this branch: bzr merge lp:~extra-addons-commiter/e-commerce-addons/7.0-sale-workflow-create_invoice_on
Reviewer Review Type Date Requested Status
Sébastien BEAU - http://www.akretion.com Needs Information
Review via email: mp+159321@code.launchpad.net

Commit message

[IMP] the option to create an invoice now allows to choose if it is created on the confirmation of the sale order or after the delivery

Description of the change

Since the postpaid invoice policy has been removed from OpenERP 7.0 (lp:1160835), I had to remove it from the automatic workflows.

In order to emulate it, I replace the boolean option 'create_invoice' by a selection of values allowing to choose if the invoice is:
 - not created automatically
 - created on the confirmation of the sale order
 - created after the delivery

This is efficient only if the invoice policy is 'On Demand', so i also set the field to readonly when an other policy is selected (it was the case before but the checkbox was not deactivated).

To post a comment you must log in.
304. By Guewen Baconnier @ Camptocamp

[FIX] updated base data according to last change and addded a manual workflow

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

Great job Guewen, I just read the code and I have some comment
Regarding the default value for the workflow method before it was 'creating invoice after delivery' now it's manual, maybe it' will be better to keep the same behaviour? And setting invoice => 'after delivery' instead of "manual".
also I am not sure that activating by default the option "invoice_date_is_order_date" is a good idea. It's usefull for importing an historic but in day to day you will have invoice number than will not match with the invoice date.

What do you think?

Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) :
review: Needs Information
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

'creating invoice after delivery' (with invoice in ordered quantities) is the 'postpaid' option which has disappeared.

That's why I put 'manual' (On Demand) with the option create invoice on 'on_picking_done', which emulates the automatic creation of the invoice after the delivery.

The whole purpose of this MP is to keep the same behaviour.

I will remove the 'Force Invoice Date'. BTW, it makes me wonder if it shouldn't be an option of the payment method instead of the workflow.

305. By Guewen Baconnier @ Camptocamp

[FIX] do not activate force invoice date in the base workflows

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Updated with the force invoice date set to False on the default workflows.

Unmerged revisions

305. By Guewen Baconnier @ Camptocamp

[FIX] do not activate force invoice date in the base workflows

304. By Guewen Baconnier @ Camptocamp

[FIX] updated base data according to last change and addded a manual workflow

303. By Guewen Baconnier @ Camptocamp

[IMP] the option to create an invoice now allows to choose if it is created on the confirmation of the sale order or after the delivery

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'sale_automatic_workflow/automatic_workflow_data.xml'
--- sale_automatic_workflow/automatic_workflow_data.xml 2013-04-17 09:43:28 +0000
+++ sale_automatic_workflow/automatic_workflow_data.xml 2013-04-17 09:43:28 +0000
@@ -8,18 +8,28 @@
8<openerp>8<openerp>
9 <data noupdate="1">9 <data noupdate="1">
1010
11 <!-- VIEW FOR THE OBJECT : payment_method -->
12 <record id="automatic_validation" model="sale.workflow.process">11 <record id="automatic_validation" model="sale.workflow.process">
13 <field name="name">Automatic Validation</field>12 <field name="name">Automatic</field>
14 <field name="picking_policy">one</field>13 <field name="picking_policy">one</field>
15 <field name="order_policy">picking</field>14 <field name="order_policy">manual</field>
15 <field name="invoice_quantity">order</field>
16 <field name="validate_order" eval="1"/>
17 <field name="create_invoice_on">on_picking_done</field>
18 <field name="validate_invoice" eval="1" />
19 <field name="invoice_date_is_order_date" eval="0" />
20 <field name="validate_picking" eval="0" />
21 </record>
22
23 <record id="manual_validation" model="sale.workflow.process">
24 <field name="name">Manual</field>
25 <field name="picking_policy">one</field>
26 <field name="order_policy">manual</field>
16 <field name="invoice_quantity">order</field>27 <field name="invoice_quantity">order</field>
17 <field name="validate_order" eval="0"/>28 <field name="validate_order" eval="0"/>
18 <field name="create_invoice" eval="1" />29 <field name="create_invoice_on">manual</field>
19 <field name="validate_invoice" eval="1" />30 <field name="validate_invoice" eval="0" />
20 <field name="invoice_date_is_order_date" eval="0" />31 <field name="invoice_date_is_order_date" eval="0" />
21 <field name="validate_picking" eval="0" />32 <field name="validate_picking" eval="0" />
22 <field name="validate_manufactoring_order" eval="0" />
23 </record>33 </record>
2434
25 <record forcecreate="True" id="ir_cron_automatic_workflow_job" model="ir.cron">35 <record forcecreate="True" id="ir_cron_automatic_workflow_job" model="ir.cron">
2636
=== modified file 'sale_automatic_workflow/sale.py'
--- sale_automatic_workflow/sale.py 2013-04-17 09:43:28 +0000
+++ sale_automatic_workflow/sale.py 2013-04-17 09:43:28 +0000
@@ -72,3 +72,19 @@
72 if workflow.invoice_quantity:72 if workflow.invoice_quantity:
73 result['invoice_quantity'] = workflow.invoice_quantity73 result['invoice_quantity'] = workflow.invoice_quantity
74 return {'value': result}74 return {'value': result}
75
76 def test_create_invoice(self, cr, uid, ids):
77 """ Workflow condition: test if an invoice should be created,
78 based on the automatic workflow rules """
79 if isinstance(ids, (list, tuple)):
80 assert len(ids) == 1
81 ids = ids[0]
82 order = self.browse(cr, uid, ids)
83 if order.order_policy != 'manual' or not order.workflow_process_id:
84 return False
85 invoice_on = order.workflow_process_id.create_invoice_on
86 if invoice_on == 'on_order_confirm':
87 return True
88 elif invoice_on == 'on_picking_done' and order.shipped:
89 return True
90 return False
7591
=== modified file 'sale_automatic_workflow/sale_workflow.xml'
--- sale_automatic_workflow/sale_workflow.xml 2012-04-22 12:49:21 +0000
+++ sale_automatic_workflow/sale_workflow.xml 2013-04-17 09:43:28 +0000
@@ -5,7 +5,7 @@
5 <record id="trans_wait_invoice_invoice" model="workflow.transition">5 <record id="trans_wait_invoice_invoice" model="workflow.transition">
6 <field name="act_from" ref="sale.act_wait_invoice"/>6 <field name="act_from" ref="sale.act_wait_invoice"/>
7 <field name="act_to" ref="sale.act_invoice"/>7 <field name="act_to" ref="sale.act_invoice"/>
8 <field name="condition">(order_policy=='manual' and workflow_process_id.create_invoice)</field>8 <field name="condition">test_create_invoice()</field>
9 </record>9 </record>
1010
11 </data>11 </data>
1212
=== modified file 'sale_automatic_workflow/sale_workflow_process.py'
--- sale_automatic_workflow/sale_workflow_process.py 2013-04-17 09:43:28 +0000
+++ sale_automatic_workflow/sale_workflow_process.py 2013-04-17 09:43:28 +0000
@@ -28,21 +28,25 @@
2828
29 _columns = {29 _columns = {
30 'name': fields.char('Name', size=64),30 'name': fields.char('Name', size=64),
31 'picking_policy': fields.selection([('direct', 'Deliver each product when available'),31 'picking_policy': fields.selection(
32 ('one', 'Deliver all products at once')],32 [('direct', 'Deliver each product when available'),
33 string='Shipping Policy'),33 ('one', 'Deliver all products at once')],
34 'order_policy': fields.selection([34 string='Shipping Policy'),
35 ('prepaid', 'Before Delivery'),35 'order_policy': fields.selection([('prepaid', 'Before Delivery'),
36 ('manual', 'On Demand'),36 ('manual', 'On Demand'),
37 # https://bugs.launchpad.net/openobject-addons/+bug/116083537 ('picking', 'On Delivery Order')],
38 # ('postpaid', 'Invoice on Order After Delivery'),38 string='Invoice Policy'),
39 ('picking', 'On Delivery Order'),39 'invoice_quantity': fields.selection(
40 ], 'Invoice Policy'),40 [('order', 'Ordered Quantities'),
41 'invoice_quantity': fields.selection([('order', 'Ordered Quantities'),41 ('procurement', 'Shipped Quantities')],
42 ('procurement', 'Shipped Quantities')],42 string='Invoice on'),
43 string='Invoice on'),
44 'validate_order': fields.boolean('Validate Order'),43 'validate_order': fields.boolean('Validate Order'),
45 'create_invoice': fields.boolean('Create Invoice'),44 'create_invoice_on': fields.selection(
45 [('manual', 'No automatic invoice'),
46 ('on_order_confirm', 'On confirmation of Sale Order'),
47 ('on_picking_done', 'After Delivery')],
48 required=True,
49 string='Create Invoice'),
46 'validate_invoice': fields.boolean('Validate Invoice'),50 'validate_invoice': fields.boolean('Validate Invoice'),
47 'validate_picking': fields.boolean('Confirm and Close Picking'),51 'validate_picking': fields.boolean('Confirm and Close Picking'),
48 # TODO not implemented actually52 # TODO not implemented actually
@@ -56,6 +60,7 @@
56 _defaults = {60 _defaults = {
57 'picking_policy': 'direct',61 'picking_policy': 'direct',
58 'order_policy': 'manual',62 'order_policy': 'manual',
63 'create_invoice_on': 'manual',
59 'invoice_quantity': 'order',64 'invoice_quantity': 'order',
60 'validate_invoice': False,65 'validate_invoice': False,
61 }66 }
6267
=== modified file 'sale_automatic_workflow/sale_workflow_process_view.xml'
--- sale_automatic_workflow/sale_workflow_process_view.xml 2013-04-17 09:43:28 +0000
+++ sale_automatic_workflow/sale_workflow_process_view.xml 2013-04-17 09:43:28 +0000
@@ -23,7 +23,7 @@
23 <field name="validate_order"/>23 <field name="validate_order"/>
24 <field name="validate_picking"/>24 <field name="validate_picking"/>
25 <!-- <field name="validate_manufactoring_order"/> -->25 <!-- <field name="validate_manufactoring_order"/> -->
26 <field name="create_invoice" />26 <field name="create_invoice_on" attrs="{'readonly': [('order_policy', '!=', 'manual')]}" />
27 <field name="validate_invoice"/>27 <field name="validate_invoice"/>
28 <field name="invoice_date_is_order_date"/>28 <field name="invoice_date_is_order_date"/>
2929
@@ -43,7 +43,7 @@
43 <field name="validate_order"/>43 <field name="validate_order"/>
44 <field name="validate_picking"/>44 <field name="validate_picking"/>
45 <!-- <field name="validate_manufactoring_order"/> -->45 <!-- <field name="validate_manufactoring_order"/> -->
46 <field name="create_invoice" />46 <field name="create_invoice_on" />
47 <field name="validate_invoice"/>47 <field name="validate_invoice"/>
48 <field name="invoice_date_is_order_date"/>48 <field name="invoice_date_is_order_date"/>
49 </tree>49 </tree>

Subscribers

People subscribed via source and target branches