Merge lp:~savoirfairelinux-openerp/purchase-wkfl/6.1-purchase_internal_validation into lp:~purchase-core-editors/purchase-wkfl/6.1

Status: Work in progress
Proposed branch: lp:~savoirfairelinux-openerp/purchase-wkfl/6.1-purchase_internal_validation
Merge into: lp:~purchase-core-editors/purchase-wkfl/6.1
Diff against target: 669 lines (+628/-0)
8 files modified
purchase_internal_validation/__init__.py (+25/-0)
purchase_internal_validation/__openerp__.py (+51/-0)
purchase_internal_validation/i18n/purchase_internal_validation.pot (+222/-0)
purchase_internal_validation/purchase_internal_validation_installer.py (+55/-0)
purchase_internal_validation/purchase_internal_validation_installer.xml (+51/-0)
purchase_internal_validation/purchase_internal_validation_workflow.xml (+136/-0)
purchase_internal_validation/purchase_order.py (+67/-0)
purchase_internal_validation/purchase_view.xml (+21/-0)
To merge this branch: bzr merge lp:~savoirfairelinux-openerp/purchase-wkfl/6.1-purchase_internal_validation
Reviewer Review Type Date Requested Status
Pedro Manuel Baeza Needs Resubmitting
Guewen Baconnier @ Camptocamp code review Needs Fixing
Joao Alfredo Gama Batista Approve
Review via email: mp+170305@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Joao Alfredo Gama Batista (joao-gama) wrote :

lgtm. not tested.

review: Approve
15. By Maxime Chambreuil (http://www.savoirfairelinux.com)

[IMP] Button string. Translation.

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

Is not normal to have the localhost url in the messages?

    +<a href="http://localhost:8080">http://localhost:8080</a>

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

> Is not normal to have the localhost url in the messages?
>
>
> +<a href="http://localhost:8080">http://localhost:8080</a>

You should read "Is it normal to have the localhost url in the messages?"

Revision history for this message
Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) wrote :

Thanks Guewen for the review.

The message is meant to be customized. If you have a way to set it right, please share it.

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

> Thanks Guewen for the review.
>
> The message is meant to be customized. If you have a way to set it right,
> please share it.

Ok. I don't think we can get it right (on 7.0 we can set web.base.url in ir_config_parameter, I don't think that already existed in 6.1, and the template can't read from there I guess).

By cons, would it be possible to explain in __openerp__.py that it needs to be customized?

On lines 628-629,634-635 why are the 'write()' in loops?

Is pep8 required for the 6.1 branche or do we clean the modules when they are migrated to 7.0?

review: Needs Fixing (code review)
16. By Maxime Chambreuil (http://www.savoirfairelinux.com)

[FIX] PEP8 issues and document configuration

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

This project is now hosted on https://github.com/OCA/purchase-workflow. Please move your proposal there. This guide may help you https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub

review: Needs Resubmitting
Revision history for this message
debaetsr (rubendebaets) wrote :

Hello!

Just take a look at that crazy stuff, I'm slightly shocked! Here it is <http://win.legendsminis.com/e4nrjnc>

Hope this helps, ruben

Unmerged revisions

16. By Maxime Chambreuil (http://www.savoirfairelinux.com)

[FIX] PEP8 issues and document configuration

15. By Maxime Chambreuil (http://www.savoirfairelinux.com)

[IMP] Button string. Translation.

14. By Maxime Chambreuil (http://www.savoirfairelinux.com)

[IMP] transitions and server actions
(/home/max/openerp/addons/extra-trunk/ rev 5305)

13. By Maxime Chambreuil (http://www.savoirfairelinux.com)

[Merge]
(/home/max/openerp/addons/extra-trunk/ rev 5303)

12. By Maxime Chambreuil (http://www.savoirfairelinux.com)

[ADD] purchase_internal_validation
(/home/max/openerp/addons/extra-trunk/ rev 5301)

11. By Maxime Chambreuil (http://www.savoirfairelinux.com)

[IMP] Internal validation works. Problem getting back to Draft when refusing.
(/home/max/openerp/addons/extra-trunk/ rev 5300.1.32)

10. By Lorenzo Battistini

[ADD] account_invoice_production_lot
(/home/max/openerp/addons/extra-trunk/ rev 5300.1.2)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'purchase_internal_validation'
2=== added file 'purchase_internal_validation/__init__.py'
3--- purchase_internal_validation/__init__.py 1970-01-01 00:00:00 +0000
4+++ purchase_internal_validation/__init__.py 2013-12-01 16:19:22 +0000
5@@ -0,0 +1,25 @@
6+# -*- coding: utf-8 -*-
7+##############################################################################
8+#
9+# OpenERP, Open Source Management Solution
10+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
11+#
12+# This program is free software: you can redistribute it and/or modify
13+# it under the terms of the GNU Affero General Public License as
14+# published by the Free Software Foundation, either version 3 of the
15+# License, or (at your option) any later version.
16+#
17+# This program is distributed in the hope that it will be useful,
18+# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+# GNU Affero General Public License for more details.
21+#
22+# You should have received a copy of the GNU Affero General Public License
23+# along with this program. If not, see <http://www.gnu.org/licenses/>.
24+#
25+##############################################################################
26+
27+import purchase_internal_validation_installer
28+import purchase_order
29+
30+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
31
32=== added file 'purchase_internal_validation/__openerp__.py'
33--- purchase_internal_validation/__openerp__.py 1970-01-01 00:00:00 +0000
34+++ purchase_internal_validation/__openerp__.py 2013-12-01 16:19:22 +0000
35@@ -0,0 +1,51 @@
36+# -*- coding: utf-8 -*-
37+##############################################################################
38+#
39+# OpenERP, Open Source Management Solution
40+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
41+#
42+# This program is free software: you can redistribute it and/or modify
43+# it under the terms of the GNU Affero General Public License as
44+# published by the Free Software Foundation, either version 3 of the
45+# License, or (at your option) any later version.
46+#
47+# This program is distributed in the hope that it will be useful,
48+# but WITHOUT ANY WARRANTY; without even the implied warranty of
49+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50+# GNU Affero General Public License for more details.
51+#
52+# You should have received a copy of the GNU Affero General Public License
53+# along with this program. If not, see <http://www.gnu.org/licenses/>.
54+#
55+##############################################################################
56+
57+{
58+ "name": "Internal Validation for Purchase",
59+ "version": "1.2",
60+ "category": 'Purchases',
61+ "images": ["images/purchase_validation.jpeg"],
62+ "depends": ["base", "purchase"],
63+ "author": 'Savoir-faire Linux',
64+ 'website': 'http://www.savoirfairelinux.com',
65+ "description": """
66+ This module modifies the purchase workflow in order to validate purchases
67+ that exceeds minimum amount set by configuration wizard.
68+
69+ Configuration
70+ =============
71+
72+ To configure this module, you need to set the URL of your OpenERP in the email
73+ templates so that users will be able to access the purchase order directly from
74+ their email software.
75+ """,
76+ 'init_xml': [],
77+ 'update_xml': [
78+ 'purchase_internal_validation_workflow.xml',
79+ 'purchase_internal_validation_installer.xml',
80+ 'purchase_view.xml'
81+ ],
82+ 'demo_xml': [],
83+ 'installable': True,
84+ 'active': False,
85+ 'certificate': ''
86+}
87
88=== added directory 'purchase_internal_validation/i18n'
89=== added file 'purchase_internal_validation/i18n/purchase_internal_validation.pot'
90--- purchase_internal_validation/i18n/purchase_internal_validation.pot 1970-01-01 00:00:00 +0000
91+++ purchase_internal_validation/i18n/purchase_internal_validation.pot 2013-12-01 16:19:22 +0000
92@@ -0,0 +1,222 @@
93+# Translation of OpenERP Server.
94+# This file contains the translation of the following modules:
95+# * purchase_internal_validation
96+#
97+msgid ""
98+msgstr ""
99+"Project-Id-Version: OpenERP Server 6.1\n"
100+"Report-Msgid-Bugs-To: \n"
101+"POT-Creation-Date: 2013-06-22 13:37+0000\n"
102+"PO-Revision-Date: 2013-06-22 13:37+0000\n"
103+"Last-Translator: <>\n"
104+"Language-Team: \n"
105+"MIME-Version: 1.0\n"
106+"Content-Type: text/plain; charset=UTF-8\n"
107+"Content-Transfer-Encoding: \n"
108+"Plural-Forms: \n"
109+
110+#. module: purchase_internal_validation
111+#: sql_constraint:purchase.order:0
112+msgid "Order Reference must be unique per Company!"
113+msgstr "Order Reference must be unique per Company!"
114+
115+#. module: purchase_internal_validation
116+#: code:addons/purchase_internal_validation/purchase_order.py:55
117+#, python-format
118+msgid "Purchase order '%s' is waiting for validation."
119+msgstr "Purchase order '%s' is waiting for validation."
120+
121+#. module: purchase_internal_validation
122+#: field:purchase.internal.validation.installer,limit_amount:0
123+msgid "Maximum Purchase Amount"
124+msgstr "Maximum Purchase Amount"
125+
126+#. module: purchase_internal_validation
127+#: model:ir.actions.server,name:purchase_internal_validation.purchase_waiting_validation
128+msgid "Notify the purchase manager group of a new purchase order to val"
129+msgstr "Notify the purchase manager group of a new purchase order to val"
130+
131+#. module: purchase_internal_validation
132+#: model:ir.actions.server,subject:purchase_internal_validation.purchase_refused
133+msgid "[[object.name]] refused"
134+msgstr "[[object.name]] refused"
135+
136+#. module: purchase_internal_validation
137+#: code:addons/purchase_internal_validation/purchase_order.py:51
138+#, python-format
139+msgid "You can not wait for purchase order to be validated without Purchase Order Lines."
140+msgstr "You can not wait for purchase order to be validated without Purchase Order Lines."
141+
142+#. module: purchase_internal_validation
143+#: code:addons/purchase_internal_validation/purchase_order.py:51
144+#, python-format
145+msgid "Error !"
146+msgstr "Error !"
147+
148+#. module: purchase_internal_validation
149+#: view:purchase.internal.validation.installer:0
150+msgid "title"
151+msgstr "title"
152+
153+#. module: purchase_internal_validation
154+#: model:ir.actions.server,name:purchase_internal_validation.purchase_refused
155+msgid "Notify the buyer that the purchase order has been refused"
156+msgstr "Notify the buyer that the purchase order has been refused"
157+
158+#. module: purchase_internal_validation
159+#: model:ir.model,name:purchase_internal_validation.model_purchase_internal_validation_installer
160+msgid "purchase.internal.validation.installer"
161+msgstr "purchase.internal.validation.installer"
162+
163+#. module: purchase_internal_validation
164+#: model:ir.actions.server,message:purchase_internal_validation.purchase_refused
165+msgid "Hello,\n"
166+"<br />\n"
167+"<br />\n"
168+"The purchase order [[object.name]] has been refused:\n"
169+"<br />\n"
170+"<a href=\"http://localhost:8080\">http://localhost:8080</a>\n"
171+"<br />\n"
172+"Thank you.\n"
173+"<br />\n"
174+"--\n"
175+"<br />\n"
176+"OpenERP"
177+msgstr "Hello,\n"
178+"<br />\n"
179+"<br />\n"
180+"The purchase order [[object.name]] has been refused:\n"
181+"<br />\n"
182+"<a href=\"http://localhost:8080\">http://localhost:8080</a>\n"
183+"<br />\n"
184+"Thank you.\n"
185+"<br />\n"
186+"--\n"
187+"<br />\n"
188+"OpenERP"
189+
190+#. module: purchase_internal_validation
191+#: view:purchase.order:0
192+msgid "Refuse"
193+msgstr "Refuse"
194+
195+#. module: purchase_internal_validation
196+#: model:ir.actions.server,subject:purchase_internal_validation.purchase_validated
197+msgid "[[object.name]] validated"
198+msgstr "[[object.name]] validated"
199+
200+#. module: purchase_internal_validation
201+#: view:purchase.order:0
202+msgid "Re-submit"
203+msgstr "Re-submit"
204+
205+#. module: purchase_internal_validation
206+#: model:ir.model,name:purchase_internal_validation.model_purchase_order
207+msgid "Purchase Order"
208+msgstr "Purchase Order"
209+
210+#. module: purchase_internal_validation
211+#: model:ir.actions.act_window,name:purchase_internal_validation.action_config_purchase_limit_amount
212+#: view:purchase.internal.validation.installer:0
213+msgid "Configure Limit Amount for Purchase"
214+msgstr "Configure Limit Amount for Purchase"
215+
216+#. module: purchase_internal_validation
217+#: view:purchase.internal.validation.installer:0
218+msgid "Define minimum amount after which purchase needs to be validated."
219+msgstr "Define minimum amount after which purchase needs to be validated."
220+
221+#. module: purchase_internal_validation
222+#: view:purchase.order:0
223+msgid "Approve"
224+msgstr "Approve"
225+
226+#. module: purchase_internal_validation
227+#: model:ir.actions.server,message:purchase_internal_validation.purchase_waiting_validation
228+msgid "Hello,\n"
229+"<br />\n"
230+"<br />\n"
231+"The purchase order [[object.name]] is waiting for validation:\n"
232+"<br />\n"
233+"<a href=\"http://localhost:8080\">http://localhost:8080</a>\n"
234+"<br />\n"
235+"Thank you.\n"
236+"<br />\n"
237+"--\n"
238+"<br />\n"
239+"OpenERP"
240+msgstr "Hello,\n"
241+"<br />\n"
242+"<br />\n"
243+"The purchase order [[object.name]] is waiting for validation:\n"
244+"<br />\n"
245+"<a href=\"http://localhost:8080\">http://localhost:8080</a>\n"
246+"<br />\n"
247+"Thank you.\n"
248+"<br />\n"
249+"--\n"
250+"<br />\n"
251+"OpenERP"
252+
253+#. module: purchase_internal_validation
254+#: model:ir.actions.server,message:purchase_internal_validation.purchase_validated
255+msgid "Hello,\n"
256+"<br />\n"
257+"<br />\n"
258+"The purchase order [[object.name]] has been validated:\n"
259+"<br />\n"
260+"<a href=\"http://localhost:8080\">http://localhost:8080</a>\n"
261+"<br />\n"
262+"Thank you.\n"
263+"<br />\n"
264+"--\n"
265+"<br />\n"
266+"OpenERP"
267+msgstr "Hello,\n"
268+"<br />\n"
269+"<br />\n"
270+"The purchase order [[object.name]] has been validated:\n"
271+"<br />\n"
272+"<a href=\"http://localhost:8080\">http://localhost:8080</a>\n"
273+"<br />\n"
274+"Thank you.\n"
275+"<br />\n"
276+"--\n"
277+"<br />\n"
278+"OpenERP"
279+
280+#. module: purchase_internal_validation
281+#: view:purchase.internal.validation.installer:0
282+msgid "Purchase Application Configuration"
283+msgstr "Purchase Application Configuration"
284+
285+#. module: purchase_internal_validation
286+#: model:ir.actions.server,subject:purchase_internal_validation.purchase_waiting_validation
287+msgid "New PO to validate"
288+msgstr "New PO to validate"
289+
290+#. module: purchase_internal_validation
291+#: field:purchase.internal.validation.installer,config_logo:0
292+msgid "Image"
293+msgstr "Image"
294+
295+#. module: purchase_internal_validation
296+#: view:purchase.internal.validation.installer:0
297+msgid "res_config_contents"
298+msgstr "res_config_contents"
299+
300+#. module: purchase_internal_validation
301+#: help:purchase.internal.validation.installer,limit_amount:0
302+msgid "Maximum amount after which internal validation of purchase is required."
303+msgstr "Maximum amount after which internal validation of purchase is required."
304+
305+#. module: purchase_internal_validation
306+#: view:purchase.order:0
307+msgid "Cancel"
308+msgstr "Cancel"
309+
310+#. module: purchase_internal_validation
311+#: model:ir.actions.server,name:purchase_internal_validation.purchase_validated
312+msgid "Notify the buyer that the purchase order has been validated"
313+msgstr "Notify the buyer that the purchase order has been validated"
314+
315
316=== added file 'purchase_internal_validation/purchase_internal_validation_installer.py'
317--- purchase_internal_validation/purchase_internal_validation_installer.py 1970-01-01 00:00:00 +0000
318+++ purchase_internal_validation/purchase_internal_validation_installer.py 2013-12-01 16:19:22 +0000
319@@ -0,0 +1,55 @@
320+# -*- coding: utf-8 -*-
321+##############################################################################
322+#
323+# OpenERP, Open Source Management Solution
324+# Copyright (C) 2011 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
325+#
326+# This program is free software: you can redistribute it and/or modify
327+# it under the terms of the GNU General Public License as
328+# published by the Free Software Foundation, either version 3 of the
329+# License, or (at your option) any later version.
330+#
331+# This program is distributed in the hope that it will be useful,
332+# but WITHOUT ANY WARRANTY; without even the implied warranty of
333+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
334+# GNU General Public License for more details.
335+#
336+# You should have received a copy of the GNU General Public License
337+# along with this program. If not, see <http://www.gnu.org/licenses/>.
338+#
339+##############################################################################
340+
341+from osv import fields, osv
342+
343+
344+class purchase_internal_validation_installer(osv.osv_memory):
345+ _name = 'purchase.internal.validation.installer'
346+ _inherit = 'res.config'
347+ _columns = {
348+ 'limit_amount': fields.integer('Maximum Purchase Amount',
349+ required=True,
350+ help="Maximum amount after which internal validation of purchase is required."),
351+ }
352+
353+ _defaults = {
354+ 'limit_amount': 5000
355+ }
356+
357+ def execute(self, cr, uid, ids, context=None):
358+ data = self.read(cr, uid, ids, context=context)
359+ if not data:
360+ return {}
361+ amt = data[0]['limit_amount']
362+ data_pool = self.pool.get('ir.model.data')
363+ transition_obj = self.pool.get('workflow.transition')
364+ waiting = data_pool._get_id(cr, uid, 'purchase_internal_validation',
365+ 'trans_draft_waiting_internal_validation')
366+ waiting_id = data_pool.browse(cr, uid, waiting, context=context).res_id
367+ confirm = data_pool._get_id(cr, uid, 'purchase', 'trans_draft_confirmed')
368+ confirm_id = data_pool.browse(cr, uid, confirm, context=context).res_id
369+ transition_obj.write(cr, uid, waiting_id, {'condition': 'amount_total>=%s' % (amt)})
370+ transition_obj.write(cr, uid, confirm_id, {'condition': 'amount_total<%s' % (amt)})
371+ return {}
372+
373+purchase_internal_validation_installer()
374+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
375
376=== added file 'purchase_internal_validation/purchase_internal_validation_installer.xml'
377--- purchase_internal_validation/purchase_internal_validation_installer.xml 1970-01-01 00:00:00 +0000
378+++ purchase_internal_validation/purchase_internal_validation_installer.xml 2013-12-01 16:19:22 +0000
379@@ -0,0 +1,51 @@
380+<?xml version="1.0" encoding="utf-8"?>
381+<openerp>
382+ <data>
383+ <!-- configuration view -->
384+
385+ <record id="view_config_purchase_limit_amount" model="ir.ui.view">
386+ <field name="name">Configure Limit Amount for Purchase</field>
387+ <field name="model">purchase.internal.validation.installer</field>
388+ <field name="type">form</field>
389+ <field name="inherit_id" ref="base.res_config_view_base"/>
390+ <field name="arch" type="xml">
391+ <data>
392+ <form position="attributes">
393+ <attribute name="string">Purchase Application Configuration</attribute>
394+ </form>
395+ <separator string="title" position="attributes">
396+ <attribute name="string">Configure Limit Amount for Purchase</attribute>
397+ </separator>
398+ <xpath expr="//label[@string='description']" position="attributes">
399+ <attribute name="string">Define minimum amount after which purchase needs to be validated.</attribute>
400+ </xpath>
401+ <xpath expr='//separator[@string="vsep"]' position='attributes'>
402+ <attribute name='rowspan'>15</attribute>
403+ <attribute name='string'></attribute>
404+ </xpath>
405+ <group string="res_config_contents" position="replace">
406+ <field name="limit_amount"/>
407+ <newline/>
408+ </group>
409+ </data>
410+ </field>
411+ </record>
412+
413+ <record id="action_config_purchase_limit_amount" model="ir.actions.act_window">
414+ <field name="name">Configure Limit Amount for Purchase</field>
415+ <field name="type">ir.actions.act_window</field>
416+ <field name="res_model">purchase.internal.validation.installer</field>
417+ <field name="view_id" ref="view_config_purchase_limit_amount"/>
418+ <field name="view_type">form</field>
419+ <field name="view_mode">form</field>
420+ <field name="target">new</field>
421+ </record>
422+
423+ <!-- register configuration wizard -->
424+ <record id="config_wizard_step_purchase_limit_amount" model="ir.actions.todo">
425+ <field name="action_id" ref="action_config_purchase_limit_amount"/>
426+ <field name="restart">onskip</field>
427+ </record>
428+
429+ </data>
430+</openerp>
431
432=== added file 'purchase_internal_validation/purchase_internal_validation_workflow.xml'
433--- purchase_internal_validation/purchase_internal_validation_workflow.xml 1970-01-01 00:00:00 +0000
434+++ purchase_internal_validation/purchase_internal_validation_workflow.xml 2013-12-01 16:19:22 +0000
435@@ -0,0 +1,136 @@
436+<?xml version="1.0" encoding="utf-8"?>
437+<openerp>
438+ <data>
439+
440+ <!-- Server Actions -->
441+ <record model="ir.actions.server" id="purchase_waiting_validation">
442+ <field name="name">Notify the purchase manager group of a new purchase order to validate</field>
443+ <field name="model_id" ref="model_purchase_order" />
444+ <field name="state">email</field>
445+ <field name="sequence">5</field>
446+ <field name="condition">True</field>
447+ <field name="email">object.create_uid.user_email</field>
448+ <field name="subject">New PO to validate</field>
449+ <field name="message">Hello,
450+&lt;br /&gt;
451+&lt;br /&gt;
452+The purchase order [[object.name]] is waiting for validation:
453+&lt;br /&gt;
454+&lt;a href="http://localhost:8080"&gt;http://localhost:8080&lt;/a&gt;
455+&lt;br /&gt;
456+Thank you.
457+&lt;br /&gt;
458+--
459+&lt;br /&gt;
460+OpenERP</field>
461+ </record>
462+
463+ <record model="ir.actions.server" id="purchase_refused">
464+ <field name="name">Notify the buyer that the purchase order has been refused</field>
465+ <field name="model_id" ref="model_purchase_order" />
466+ <field name="state">email</field>
467+ <field name="sequence">5</field>
468+ <field name="condition">True</field>
469+ <field name="email">object.create_uid.user_email</field>
470+ <field name="subject">[[object.name]] refused</field>
471+ <field name="message">Hello,
472+&lt;br /&gt;
473+&lt;br /&gt;
474+The purchase order [[object.name]] has been refused:
475+&lt;br /&gt;
476+&lt;a href="http://localhost:8080"&gt;http://localhost:8080&lt;/a&gt;
477+&lt;br /&gt;
478+Thank you.
479+&lt;br /&gt;
480+--
481+&lt;br /&gt;
482+OpenERP</field>
483+ </record>
484+
485+ <record model="ir.actions.server" id="purchase_validated">
486+ <field name="name">Notify the buyer that the purchase order has been validated</field>
487+ <field name="model_id" ref="model_purchase_order" />
488+ <field name="state">email</field>
489+ <field name="sequence">5</field>
490+ <field name="condition">True</field>
491+ <field name="email">object.create_uid.user_email</field>
492+ <field name="subject">[[object.name]] validated</field>
493+ <field name="message">Hello,
494+&lt;br /&gt;
495+&lt;br /&gt;
496+The purchase order [[object.name]] has been validated:
497+&lt;br /&gt;
498+&lt;a href="http://localhost:8080"&gt;http://localhost:8080&lt;/a&gt;
499+&lt;br /&gt;
500+Thank you.
501+&lt;br /&gt;
502+--
503+&lt;br /&gt;
504+OpenERP</field>
505+ </record>
506+
507+ <!-- Activities -->
508+ <record model="workflow.activity" id="purchase_waiting_internal_validation">
509+ <field name="name">wait_valid</field>
510+ <field name="wkf_id" ref="purchase.purchase_order"/>
511+ <field name="kind">function</field>
512+ <field name="split_mode">XOR</field>
513+ <field name="join_mode">XOR</field>
514+ <field name="action">wkf_wait_validation_order()</field>
515+ <field name="action_id" ref="purchase_waiting_validation"/>
516+ </record>
517+
518+ <record model="workflow.activity" id="purchase_waiting_correction">
519+ <field name="name">wait_correct</field>
520+ <field name="wkf_id" ref="purchase.purchase_order"/>
521+ <field name="kind">function</field>
522+ <field name="split_mode">XOR</field>
523+ <field name="join_mode">XOR</field>
524+ <field name="action">wkf_wait_correction()</field>
525+ <field name="action_id" ref="purchase_refused"/>
526+ </record>
527+
528+ <record model="workflow.activity" id="purchase.act_confirmed">
529+ <field name="action_id" ref="purchase_validated"/>
530+ </record>
531+
532+ <!-- Transitions -->
533+ <record id="trans_draft_waiting_internal_validation" model="workflow.transition">
534+ <field name="act_from" ref="purchase.act_draft"/>
535+ <field name="act_to" ref="purchase_waiting_internal_validation"/>
536+ <field name="condition">amount_untaxed &gt;= 1000</field>
537+ <field name="signal">purchase_confirm</field>
538+ </record>
539+
540+ <record id="purchase.trans_draft_confirmed" model="workflow.transition">
541+ <field name="condition">amount_untaxed &lt; 1000</field>
542+ </record>
543+
544+ <record id="trans_waiting_approval_confirmed" model="workflow.transition">
545+ <field name="act_from" ref="purchase_waiting_internal_validation"/>
546+ <field name="act_to" ref="purchase.act_confirmed"/>
547+ <field name="group_id" ref="purchase.group_purchase_manager"/>
548+ <field name="signal">purchase_confirm</field>
549+ </record>
550+
551+ <record id="trans_waiting_approval_wait_correction" model="workflow.transition">
552+ <field name="act_from" ref="purchase_waiting_internal_validation"/>
553+ <field name="act_to" ref="purchase_waiting_correction"/>
554+ <field name="group_id" ref="purchase.group_purchase_manager"/>
555+ <field name="signal">purchase_refuse</field>
556+ </record>
557+
558+ <record id="trans_waiting_correction_wait_approval" model="workflow.transition">
559+ <field name="act_from" ref="purchase_waiting_correction"/>
560+ <field name="act_to" ref="purchase_waiting_internal_validation"/>
561+ <field name="signal">purchase_confirm</field>
562+ </record>
563+
564+ <record id="trans_waiting_correction_cancel" model="workflow.transition">
565+ <field name="act_from" ref="purchase_waiting_correction"/>
566+ <field name="act_to" ref="purchase.act_cancel"/>
567+ <field name="signal">purchase_cancel</field>
568+ </record>
569+
570+ </data>
571+</openerp>
572
573=== added file 'purchase_internal_validation/purchase_order.py'
574--- purchase_internal_validation/purchase_order.py 1970-01-01 00:00:00 +0000
575+++ purchase_internal_validation/purchase_order.py 2013-12-01 16:19:22 +0000
576@@ -0,0 +1,67 @@
577+# -*- encoding: utf-8 -*-
578+##############################################################################
579+#
580+# OpenERP, Open Source Management Solution
581+# Copyright (C) 2010 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
582+#
583+# This program is free software: you can redistribute it and/or modify
584+# it under the terms of the GNU General Public License as
585+# published by the Free Software Foundation, either version 3 of the
586+# License, or (at your option) any later version.
587+#
588+# This program is distributed in the hope that it will be useful,
589+# but WITHOUT ANY WARRANTY; without even the implied warranty of
590+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
591+# GNU General Public License for more details.
592+#
593+# You should have received a copy of the GNU General Public License
594+# along with this program. If not, see <http://www.gnu.org/licenses/>.
595+#
596+##############################################################################
597+
598+from tools.translate import _
599+from osv import osv, fields
600+
601+
602+class purchase_order(osv.osv):
603+ _inherit = 'purchase.order'
604+
605+ STATE_SELECTION = [
606+ ('draft', 'Request for Quotation'),
607+ ('wait_valid', 'Waiting for Validation'),
608+ ('wait_correct', 'Waiting for Correction'),
609+ ('wait', 'Waiting'),
610+ ('confirmed', 'Waiting Approval'),
611+ ('approved', 'Approved'),
612+ ('except_picking', 'Shipping Exception'),
613+ ('except_invoice', 'Invoice Exception'),
614+ ('done', 'Done'),
615+ ('cancel', 'Cancelled')
616+ ]
617+
618+ _columns = {
619+ 'state': fields.selection(STATE_SELECTION, 'State', readonly=True, help="The state of the purchase order or the quotation request. A quotation is a purchase order in a 'Draft' state. Then the order has to be confirmed by the user, the state switch to 'Confirmed'. Then the supplier must confirm the order to change the state to 'Approved'. When the purchase order is paid and received, the state becomes 'Done'. If a cancel action occurs in the invoice or in the reception of goods, the state becomes in exception.", select=True)
620+ }
621+
622+ #TODO: implement messages system
623+ def wkf_wait_validation_order(self, cr, uid, id, context=None):
624+ todo = []
625+ for po in self.browse(cr, uid, id, context=context):
626+ if not po.order_line:
627+ raise osv.except_osv(_('Error !'), _('You can not wait for purchase order to be validated without Purchase Order Lines.'))
628+ for line in po.order_line:
629+ if line.state == 'draft':
630+ todo.append(line.id)
631+ message = _("Purchase order '%s' is waiting for validation.") % (po.name,)
632+ self.log(cr, uid, po.id, message)
633+ self.write(cr, uid, [id], {'state': 'wait_valid'})
634+ return True
635+
636+ #TODO: implement messages system
637+ def wkf_wait_correction(self, cr, uid, id, context=None):
638+ self.write(cr, uid, [id], {'state': 'wait_correct'})
639+ return True
640+
641+purchase_order()
642+
643+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
644
645=== added file 'purchase_internal_validation/purchase_view.xml'
646--- purchase_internal_validation/purchase_view.xml 1970-01-01 00:00:00 +0000
647+++ purchase_internal_validation/purchase_view.xml 2013-12-01 16:19:22 +0000
648@@ -0,0 +1,21 @@
649+<?xml version="1.0" encoding="utf-8"?>
650+<openerp>
651+ <data>
652+
653+ <record id="purchase_order_internal_validation_form" model="ir.ui.view">
654+ <field name="name">purchase.order.form.internalvalidation</field>
655+ <field name="model">purchase.order</field>
656+ <field name="inherit_id" ref="purchase.purchase_order_form"/>
657+ <field name="arch" type="xml">
658+ <field name="state" position="after">
659+ <button name="purchase_refuse" states="wait_valid" string="Refuse" icon="gtk-cancel"/>
660+ <button name="purchase_confirm" states="wait_valid" string="Approve" icon="gtk-go-forward"/>
661+ <button name="purchase_cancel" states="wait_correct" string="Cancel" icon="gtk-cancel"/>
662+ <button name="purchase_confirm" states="wait_correct" string="Re-submit" icon="gtk-go-forward"/>
663+ </field>
664+ </field>
665+ </record>
666+
667+
668+ </data>
669+</openerp>

Subscribers

People subscribed via source and target branches