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
1=== modified file 'sale_automatic_workflow/automatic_workflow_data.xml'
2--- sale_automatic_workflow/automatic_workflow_data.xml 2013-04-17 09:43:28 +0000
3+++ sale_automatic_workflow/automatic_workflow_data.xml 2013-04-17 09:43:28 +0000
4@@ -8,18 +8,28 @@
5 <openerp>
6 <data noupdate="1">
7
8- <!-- VIEW FOR THE OBJECT : payment_method -->
9 <record id="automatic_validation" model="sale.workflow.process">
10- <field name="name">Automatic Validation</field>
11- <field name="picking_policy">one</field>
12- <field name="order_policy">picking</field>
13+ <field name="name">Automatic</field>
14+ <field name="picking_policy">one</field>
15+ <field name="order_policy">manual</field>
16+ <field name="invoice_quantity">order</field>
17+ <field name="validate_order" eval="1"/>
18+ <field name="create_invoice_on">on_picking_done</field>
19+ <field name="validate_invoice" eval="1" />
20+ <field name="invoice_date_is_order_date" eval="0" />
21+ <field name="validate_picking" eval="0" />
22+ </record>
23+
24+ <record id="manual_validation" model="sale.workflow.process">
25+ <field name="name">Manual</field>
26+ <field name="picking_policy">one</field>
27+ <field name="order_policy">manual</field>
28 <field name="invoice_quantity">order</field>
29 <field name="validate_order" eval="0"/>
30- <field name="create_invoice" eval="1" />
31- <field name="validate_invoice" eval="1" />
32+ <field name="create_invoice_on">manual</field>
33+ <field name="validate_invoice" eval="0" />
34 <field name="invoice_date_is_order_date" eval="0" />
35 <field name="validate_picking" eval="0" />
36- <field name="validate_manufactoring_order" eval="0" />
37 </record>
38
39 <record forcecreate="True" id="ir_cron_automatic_workflow_job" model="ir.cron">
40
41=== modified file 'sale_automatic_workflow/sale.py'
42--- sale_automatic_workflow/sale.py 2013-04-17 09:43:28 +0000
43+++ sale_automatic_workflow/sale.py 2013-04-17 09:43:28 +0000
44@@ -72,3 +72,19 @@
45 if workflow.invoice_quantity:
46 result['invoice_quantity'] = workflow.invoice_quantity
47 return {'value': result}
48+
49+ def test_create_invoice(self, cr, uid, ids):
50+ """ Workflow condition: test if an invoice should be created,
51+ based on the automatic workflow rules """
52+ if isinstance(ids, (list, tuple)):
53+ assert len(ids) == 1
54+ ids = ids[0]
55+ order = self.browse(cr, uid, ids)
56+ if order.order_policy != 'manual' or not order.workflow_process_id:
57+ return False
58+ invoice_on = order.workflow_process_id.create_invoice_on
59+ if invoice_on == 'on_order_confirm':
60+ return True
61+ elif invoice_on == 'on_picking_done' and order.shipped:
62+ return True
63+ return False
64
65=== modified file 'sale_automatic_workflow/sale_workflow.xml'
66--- sale_automatic_workflow/sale_workflow.xml 2012-04-22 12:49:21 +0000
67+++ sale_automatic_workflow/sale_workflow.xml 2013-04-17 09:43:28 +0000
68@@ -5,7 +5,7 @@
69 <record id="trans_wait_invoice_invoice" model="workflow.transition">
70 <field name="act_from" ref="sale.act_wait_invoice"/>
71 <field name="act_to" ref="sale.act_invoice"/>
72- <field name="condition">(order_policy=='manual' and workflow_process_id.create_invoice)</field>
73+ <field name="condition">test_create_invoice()</field>
74 </record>
75
76 </data>
77
78=== modified file 'sale_automatic_workflow/sale_workflow_process.py'
79--- sale_automatic_workflow/sale_workflow_process.py 2013-04-17 09:43:28 +0000
80+++ sale_automatic_workflow/sale_workflow_process.py 2013-04-17 09:43:28 +0000
81@@ -28,21 +28,25 @@
82
83 _columns = {
84 'name': fields.char('Name', size=64),
85- 'picking_policy': fields.selection([('direct', 'Deliver each product when available'),
86- ('one', 'Deliver all products at once')],
87- string='Shipping Policy'),
88- 'order_policy': fields.selection([
89- ('prepaid', 'Before Delivery'),
90- ('manual', 'On Demand'),
91- # https://bugs.launchpad.net/openobject-addons/+bug/1160835
92- # ('postpaid', 'Invoice on Order After Delivery'),
93- ('picking', 'On Delivery Order'),
94- ], 'Invoice Policy'),
95- 'invoice_quantity': fields.selection([('order', 'Ordered Quantities'),
96- ('procurement', 'Shipped Quantities')],
97- string='Invoice on'),
98+ 'picking_policy': fields.selection(
99+ [('direct', 'Deliver each product when available'),
100+ ('one', 'Deliver all products at once')],
101+ string='Shipping Policy'),
102+ 'order_policy': fields.selection([('prepaid', 'Before Delivery'),
103+ ('manual', 'On Demand'),
104+ ('picking', 'On Delivery Order')],
105+ string='Invoice Policy'),
106+ 'invoice_quantity': fields.selection(
107+ [('order', 'Ordered Quantities'),
108+ ('procurement', 'Shipped Quantities')],
109+ string='Invoice on'),
110 'validate_order': fields.boolean('Validate Order'),
111- 'create_invoice': fields.boolean('Create Invoice'),
112+ 'create_invoice_on': fields.selection(
113+ [('manual', 'No automatic invoice'),
114+ ('on_order_confirm', 'On confirmation of Sale Order'),
115+ ('on_picking_done', 'After Delivery')],
116+ required=True,
117+ string='Create Invoice'),
118 'validate_invoice': fields.boolean('Validate Invoice'),
119 'validate_picking': fields.boolean('Confirm and Close Picking'),
120 # TODO not implemented actually
121@@ -56,6 +60,7 @@
122 _defaults = {
123 'picking_policy': 'direct',
124 'order_policy': 'manual',
125+ 'create_invoice_on': 'manual',
126 'invoice_quantity': 'order',
127 'validate_invoice': False,
128 }
129
130=== modified file 'sale_automatic_workflow/sale_workflow_process_view.xml'
131--- sale_automatic_workflow/sale_workflow_process_view.xml 2013-04-17 09:43:28 +0000
132+++ sale_automatic_workflow/sale_workflow_process_view.xml 2013-04-17 09:43:28 +0000
133@@ -23,7 +23,7 @@
134 <field name="validate_order"/>
135 <field name="validate_picking"/>
136 <!-- <field name="validate_manufactoring_order"/> -->
137- <field name="create_invoice" />
138+ <field name="create_invoice_on" attrs="{'readonly': [('order_policy', '!=', 'manual')]}" />
139 <field name="validate_invoice"/>
140 <field name="invoice_date_is_order_date"/>
141
142@@ -43,7 +43,7 @@
143 <field name="validate_order"/>
144 <field name="validate_picking"/>
145 <!-- <field name="validate_manufactoring_order"/> -->
146- <field name="create_invoice" />
147+ <field name="create_invoice_on" />
148 <field name="validate_invoice"/>
149 <field name="invoice_date_is_order_date"/>
150 </tree>

Subscribers

People subscribed via source and target branches