Merge lp:~vauxoo/addons-vauxoo/sale_uncommitted_product_hbto into lp:addons-vauxoo

Proposed by hbto [Vauxoo] http://www.vauxoo.com
Status: Merged
Approved by: hbto [Vauxoo] http://www.vauxoo.com
Approved revision: no longer in the source branch.
Merged at revision: 346
Proposed branch: lp:~vauxoo/addons-vauxoo/sale_uncommitted_product_hbto
Merge into: lp:addons-vauxoo
Diff against target: 638 lines (+573/-0)
12 files modified
.bzrignore (+1/-0)
sale_uncommitted_product/__init__.py (+28/-0)
sale_uncommitted_product/__openerp__.py (+67/-0)
sale_uncommitted_product/model/__init__.py (+27/-0)
sale_uncommitted_product/model/product.py (+85/-0)
sale_uncommitted_product/model/sale.py (+89/-0)
sale_uncommitted_product/security/groups.xml (+14/-0)
sale_uncommitted_product/view/product_view.xml (+24/-0)
sale_uncommitted_product/view/sale_double_validation_installer.xml (+57/-0)
sale_uncommitted_product/view/sale_view.xml (+58/-0)
sale_uncommitted_product/wizard/sale_double_validation_installer.py (+76/-0)
sale_uncommitted_product/workflow/sale_workflow.xml (+47/-0)
To merge this branch: bzr merge lp:~vauxoo/addons-vauxoo/sale_uncommitted_product_hbto
Reviewer Review Type Date Requested Status
hbto [Vauxoo] http://www.vauxoo.com Approve
Review via email: mp+116179@code.launchpad.net

Description of the change

This module:
*) Adds a new state to the sale order model, committed
*) Adds a new activity to the sale order workflow, commit
*) Adds two new transitions from draft to commit,
    -) One which could force commitment of sale order,
    -) The other will check if any product does not overflow the availability
*) Modifies the existing Transition from draft to router
and changes it from commit to router.

*) Adds a wizard so that it is possible to assign groups to the newly transitions.
*) Adds two fields to the product.product model:
    -) qty_committed: amounts the quantity of products in sale orders with state committed
    -) qty_uncommitted: amounts the quantity of available to commit
    this amount is, qty_available + outgoing - qty_committed

To post a comment you must log in.
Revision history for this message
hbto [Vauxoo] http://www.vauxoo.com (humbertoarocha) :
review: Approve
346. By hbto [Vauxoo] http://www.vauxoo.com

[MERGE]
This module:
*) Adds a new state to the sale order model, committed
*) Adds a new activity to the sale order workflow, commit
*) Adds two new transitions from draft to commit,
    -) One which could force commitment of sale order,
    -) The other will check if any product does not overflow the availability
*) Modifies the existing Transition from draft to router
and changes it from commit to router.

*) Adds a wizard so that it is possible to assign groups to the newly transitions.
*) Adds two fields to the product.product model:
    -) qty_committed: amounts the quantity of products in sale orders with state committed
    -) qty_uncommitted: amounts the quantity of available to commit
    this amount is, qty_available + outgoing - qty_committed

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '.bzrignore'
2--- .bzrignore 1970-01-01 00:00:00 +0000
3+++ .bzrignore 2012-07-23 01:29:21 +0000
4@@ -0,0 +1,1 @@
5+.directory
6
7=== added directory 'sale_uncommitted_product'
8=== added file 'sale_uncommitted_product/__init__.py'
9--- sale_uncommitted_product/__init__.py 1970-01-01 00:00:00 +0000
10+++ sale_uncommitted_product/__init__.py 2012-07-23 01:29:21 +0000
11@@ -0,0 +1,28 @@
12+#!/usr/bin/python
13+# -*- encoding: utf-8 -*-
14+###########################################################################
15+# Module Writen to OpenERP, Open Source Management Solution
16+# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
17+# All Rights Reserved
18+###############Credits######################################################
19+# Coded by: Humberto Arocha <hbto@vauxoo.com>
20+# Planified by: Rafael Silva <rsilvam@vauxoo.com>
21+# Audited by: Nhomar Hernandez <nhomar@vauxoo.com>
22+#############################################################################
23+# This program is free software: you can redistribute it and/or modify
24+# it under the terms of the GNU Affero General Public License as published by
25+# the Free Software Foundation, either version 3 of the License, or
26+# (at your option) any later version.
27+#
28+# This program is distributed in the hope that it will be useful,
29+# but WITHOUT ANY WARRANTY; without even the implied warranty of
30+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31+# GNU Affero General Public License for more details.
32+#
33+# You should have received a copy of the GNU Affero General Public License
34+# along with this program. If not, see <http://www.gnu.org/licenses/>.
35+################################################################################
36+
37+
38+import model
39+import wizard
40
41=== added file 'sale_uncommitted_product/__openerp__.py'
42--- sale_uncommitted_product/__openerp__.py 1970-01-01 00:00:00 +0000
43+++ sale_uncommitted_product/__openerp__.py 2012-07-23 01:29:21 +0000
44@@ -0,0 +1,67 @@
45+#!/usr/bin/python
46+# -*- encoding: utf-8 -*-
47+###########################################################################
48+# Module Writen to OpenERP, Open Source Management Solution
49+# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
50+# All Rights Reserved
51+###############Credits######################################################
52+# Coded by: Humberto Arocha <hbto@vauxoo.com>
53+# Planified by: Rafael Silva <rsilvam@vauxoo.com>
54+# Audited by: Nhomar Hernandez <nhomar@vauxoo.com>
55+#############################################################################
56+# This program is free software: you can redistribute it and/or modify
57+# it under the terms of the GNU Affero General Public License as published by
58+# the Free Software Foundation, either version 3 of the License, or
59+# (at your option) any later version.
60+#
61+# This program is distributed in the hope that it will be useful,
62+# but WITHOUT ANY WARRANTY; without even the implied warranty of
63+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
64+# GNU Affero General Public License for more details.
65+#
66+# You should have received a copy of the GNU Affero General Public License
67+# along with this program. If not, see <http://www.gnu.org/licenses/>.
68+################################################################################
69+
70+{
71+ "name" : "Sale of Uncommitted Products",
72+ "version" : "0.1",
73+ "author" : "Vauxoo",
74+ "category" : "Generic Modules",
75+ "website": "http://www.vauxoo.com",
76+ "description": '''
77+This module:
78+*) Adds a new state to the sale order model, committed
79+*) Adds a new activity to the sale order workflow, commit
80+*) Adds two new transitions from draft to commit,
81+ -) One which could force commitment of sale order,
82+ -) The other will check if any product does not overflow the availability
83+*) Modifies the existing Transition from draft to router
84+and changes it from commit to router.
85+
86+*) Adds a wizard so that it is possible to assign groups to the newly transitions.
87+*) Adds two fields to the product.product model:
88+ -) qty_committed: amounts the quantity of products in sale orders with state committed
89+ -) qty_uncommitted: amounts the quantity of available to commit
90+ this amount is, qty_available + outgoing - qty_committed
91+''',
92+ "depends" : [
93+ "base",
94+ "sale",
95+ "product",
96+ "stock",
97+ ],
98+ "init_xml" : [],
99+ "demo_xml" : [
100+
101+ ],
102+ "update_xml" : [
103+ 'view/product_view.xml',
104+ 'view/sale_view.xml',
105+ 'view/sale_double_validation_installer.xml',
106+ 'workflow/sale_workflow.xml',
107+ 'security/groups.xml',
108+ ],
109+ "active": False,
110+ "installable": True
111+}
112
113=== added directory 'sale_uncommitted_product/model'
114=== added file 'sale_uncommitted_product/model/__init__.py'
115--- sale_uncommitted_product/model/__init__.py 1970-01-01 00:00:00 +0000
116+++ sale_uncommitted_product/model/__init__.py 2012-07-23 01:29:21 +0000
117@@ -0,0 +1,27 @@
118+#!/usr/bin/python
119+# -*- encoding: utf-8 -*-
120+###########################################################################
121+# Module Writen to OpenERP, Open Source Management Solution
122+# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
123+# All Rights Reserved
124+###############Credits######################################################
125+# Coded by: Humberto Arocha <hbto@vauxoo.com>
126+# Planified by: Rafael Silva <rsilvam@vauxoo.com>
127+# Audited by: Nhomar Hernandez <nhomar@vauxoo.com>
128+#############################################################################
129+# This program is free software: you can redistribute it and/or modify
130+# it under the terms of the GNU Affero General Public License as published by
131+# the Free Software Foundation, either version 3 of the License, or
132+# (at your option) any later version.
133+#
134+# This program is distributed in the hope that it will be useful,
135+# but WITHOUT ANY WARRANTY; without even the implied warranty of
136+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
137+# GNU Affero General Public License for more details.
138+#
139+# You should have received a copy of the GNU Affero General Public License
140+# along with this program. If not, see <http://www.gnu.org/licenses/>.
141+################################################################################
142+
143+import product
144+import sale
145
146=== added file 'sale_uncommitted_product/model/product.py'
147--- sale_uncommitted_product/model/product.py 1970-01-01 00:00:00 +0000
148+++ sale_uncommitted_product/model/product.py 2012-07-23 01:29:21 +0000
149@@ -0,0 +1,85 @@
150+#!/usr/bin/python
151+# -*- encoding: utf-8 -*-
152+###########################################################################
153+# Module Writen to OpenERP, Open Source Management Solution
154+# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
155+# All Rights Reserved
156+###############Credits######################################################
157+# Coded by: Humberto Arocha <hbto@vauxoo.com>
158+# Planified by: Rafael Silva <rsilvam@vauxoo.com>
159+# Audited by: Nhomar Hernandez <nhomar@vauxoo.com>
160+#############################################################################
161+# This program is free software: you can redistribute it and/or modify
162+# it under the terms of the GNU Affero General Public License as published by
163+# the Free Software Foundation, either version 3 of the License, or
164+# (at your option) any later version.
165+#
166+# This program is distributed in the hope that it will be useful,
167+# but WITHOUT ANY WARRANTY; without even the implied warranty of
168+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
169+# GNU Affero General Public License for more details.
170+#
171+# You should have received a copy of the GNU Affero General Public License
172+# along with this program. If not, see <http://www.gnu.org/licenses/>.
173+################################################################################
174+
175+
176+from osv import fields, osv
177+from tools.translate import _
178+import decimal_precision as dp
179+
180+class product_product(osv.osv):
181+ _inherit = "product.product"
182+
183+ def _get_product_committed_amount(self, cr, uid, ids, context=None):
184+ amount = 0.0
185+ sol_obj = self.pool.get('sale.order.line')
186+ uom_obj = self.pool.get('product.uom')
187+ for sol_brw in sol_obj.browse(cr, uid, ids, context=context):
188+ from_uom_id = sol_brw.product_uom
189+ to_uom_id = sol_brw.product_id.uom_id
190+ qty = sol_brw.product_uom_qty
191+ amount += uom_obj._compute_qty_obj(cr, uid, from_uom_id, qty, to_uom_id, context=context)
192+ return amount
193+
194+ def _product_committed(self, cr, uid, ids, field_names=None, arg=False, context=None):
195+ """ Finds the committed products where are on
196+ committed sale orders.
197+ @return: Dictionary of values
198+ """
199+
200+ sol_obj = self.pool.get('sale.order.line')
201+
202+ if not field_names:
203+ field_names = []
204+ if context is None: context = {}
205+
206+ res = {}
207+
208+ for id in ids:
209+ res[id] = {}.fromkeys(field_names, 0.0)
210+
211+ for id in ids:
212+ #~ TODO: Cambiar por una sentencia sql para no tener que pasar el usuario 1
213+ sol_ids = sol_obj.search(cr, 1, [('order_id','!=',False),('order_id.state','=','committed'),('product_id','=',id)], context=context)
214+
215+ amount = 0.0
216+ if sol_ids and field_names:
217+ amount = self._get_product_committed_amount(cr, uid, sol_ids, context=context)
218+
219+ for f in field_names:
220+ if f == 'qty_committed':
221+ res[id][f] = amount
222+ elif f == 'qty_uncommitted':
223+ prd_brw = self.browse(cr, uid, id, context = context)
224+ res[id][f] = prd_brw.qty_available + prd_brw.outgoing_qty - amount
225+ return res
226+
227+ _columns = {
228+ 'qty_committed': fields.function(_product_committed, method=True, type='float', string='Sale Committed', multi='committed', help="Current quantities of committed products in Committe Sale Orders.", digits_compute=dp.get_precision('Product UoM')),
229+ 'qty_uncommitted': fields.function(_product_committed, method=True, type='float', string='Uncommitted', multi='committed', help="Current quantities of committed products in Committe Sale Orders.", digits_compute=dp.get_precision('Product UoM')),
230+ }
231+
232+product_product()
233+
234+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
235
236=== added file 'sale_uncommitted_product/model/sale.py'
237--- sale_uncommitted_product/model/sale.py 1970-01-01 00:00:00 +0000
238+++ sale_uncommitted_product/model/sale.py 2012-07-23 01:29:21 +0000
239@@ -0,0 +1,89 @@
240+#!/usr/bin/python
241+# -*- encoding: utf-8 -*-
242+###########################################################################
243+# Module Writen to OpenERP, Open Source Management Solution
244+# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
245+# All Rights Reserved
246+###############Credits######################################################
247+# Coded by: Humberto Arocha <hbto@vauxoo.com>
248+# Planified by: Rafael Silva <rsilvam@vauxoo.com>
249+# Audited by: Nhomar Hernandez <nhomar@vauxoo.com>
250+#############################################################################
251+# This program is free software: you can redistribute it and/or modify
252+# it under the terms of the GNU Affero General Public License as published by
253+# the Free Software Foundation, either version 3 of the License, or
254+# (at your option) any later version.
255+#
256+# This program is distributed in the hope that it will be useful,
257+# but WITHOUT ANY WARRANTY; without even the implied warranty of
258+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
259+# GNU Affero General Public License for more details.
260+#
261+# You should have received a copy of the GNU Affero General Public License
262+# along with this program. If not, see <http://www.gnu.org/licenses/>.
263+################################################################################
264+
265+from osv import fields, osv
266+from tools.translate import _
267+import time
268+
269+class sale_order(osv.osv):
270+ _inherit = "sale.order"
271+
272+ _columns = {
273+ 'date_committed':fields.datetime('Commitment Date', help='Date when Sale Order was committed to the Customer',readonly=True),
274+ 'state': fields.selection([
275+ ('draft', 'Quotation'),
276+ ('committed', 'Committed'),
277+ ('waiting_date', 'Waiting Schedule'),
278+ ('manual', 'Manual In Progress'),
279+ ('progress', 'In Progress'),
280+ ('shipping_except', 'Shipping Exception'),
281+ ('invoice_except', 'Invoice Exception'),
282+ ('done', 'Done'),
283+ ('cancel', 'Cancelled')
284+ ], 'Order State', readonly=True, help="Gives the state of the quotation or sales order. \nThe exception state is automatically set when a cancel operation occurs in the invoice validation (Invoice Exception) or in the picking list process (Shipping Exception). \nThe 'Waiting Schedule' state is set when the invoice is confirmed but waiting for the scheduler to run on the date 'Ordered Date'.", select=True),
285+ }
286+ def action_commit(self, cr, uid, ids, context=None):
287+ self.write(cr, uid, ids, {'state': 'committed', 'date_committed': time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)
288+ return True
289+
290+ def _check_so(self, cr, uid, id, context=None):
291+ if context is None: context = {}
292+
293+ uom_obj = self.pool.get('product.uom')
294+ pp_obj = self.pool.get('product.product')
295+
296+ note ='\n'
297+ check = True
298+ res = {}
299+ for sol_brw in self.browse(cr, uid, id, context=context).order_line:
300+ if sol_brw.product_id:
301+ from_uom_id = sol_brw.product_uom
302+ to_uom_id = sol_brw.product_id.uom_id
303+ qty = sol_brw.product_uom_qty
304+ amount = uom_obj._compute_qty_obj(cr, uid, from_uom_id, qty, to_uom_id, context=context)
305+ if res.get(sol_brw.product_id.id):
306+ res[sol_brw.product_id.id]+=amount
307+ else:
308+ res[sol_brw.product_id.id]=amount
309+ for p_id in res:
310+ pp_brw = pp_obj.browse(cr, uid, p_id, context=context)
311+ if res[p_id] > pp_brw.qty_uncommitted:
312+ check=False
313+ note += _('\n[%s] %s - requested: %s, available: %s')%(pp_brw.default_code or 'N/D', pp_brw.name, res[p_id], pp_brw.qty_uncommitted)
314+
315+ return {'note':note, 'check':check}
316+
317+
318+
319+ def check_committed(self, cr, uid, ids, context=None):
320+ if context is None: context = {}
321+ for id in ids:
322+ res = self._check_so(cr, uid, id, context=context)
323+ if not res['check']:
324+ note = _('Sale Order No.: %s\nHas exceeded the uncommited quantity for:\n')%(self.browse(cr,uid,id,context=context).name)
325+ raise osv.except_osv(_('Exceeded Committed Products in Sale Order'),note+res['note'])
326+ return True
327+
328+sale_order()
329
330=== added directory 'sale_uncommitted_product/security'
331=== added file 'sale_uncommitted_product/security/groups.xml'
332--- sale_uncommitted_product/security/groups.xml 1970-01-01 00:00:00 +0000
333+++ sale_uncommitted_product/security/groups.xml 2012-07-23 01:29:21 +0000
334@@ -0,0 +1,14 @@
335+<?xml version="1.0" encoding="utf-8"?>
336+<openerp>
337+<data noupdate="1">
338+
339+ <record id="group_sale_committer" model="res.groups">
340+ <field name="name">Sales / Commiter</field>
341+ </record>
342+
343+ <record id="group_sale_force_committer" model="res.groups">
344+ <field name="name">Sales / Force Commiter</field>
345+ </record>
346+
347+</data>
348+</openerp>
349
350=== added directory 'sale_uncommitted_product/view'
351=== added file 'sale_uncommitted_product/view/product_view.xml'
352--- sale_uncommitted_product/view/product_view.xml 1970-01-01 00:00:00 +0000
353+++ sale_uncommitted_product/view/product_view.xml 2012-07-23 01:29:21 +0000
354@@ -0,0 +1,24 @@
355+<?xml version="1.0" encoding="utf-8"?>
356+<openerp>
357+ <data>
358+
359+ <record id="tree_product_available_fields" model="ir.ui.view">
360+ <field name="name">product.available.fields.tree.inherit</field>
361+ <field name="model">product.product</field>
362+ <field name="type">tree</field>
363+ <field name="inherit_id" ref="product.product_product_tree_view"/>
364+ <field name="priority">26</field>
365+ <field name="arch" type="xml">
366+ <xpath expr="/tree/field[@name='virtual_available']" position="before">
367+ <field name="incoming_qty" groups="base.group_extended"/>
368+ <field name="outgoing_qty" groups="base.group_extended"/>
369+ </xpath>
370+ <xpath expr="/tree/field[@name='virtual_available']" position="after">
371+ <field name="qty_committed" groups="base.group_extended"/>
372+ <field name="qty_uncommitted" groups="base.group_extended"/>
373+ </xpath>
374+ </field>
375+ </record>
376+
377+ </data>
378+</openerp>
379
380=== added file 'sale_uncommitted_product/view/sale_double_validation_installer.xml'
381--- sale_uncommitted_product/view/sale_double_validation_installer.xml 1970-01-01 00:00:00 +0000
382+++ sale_uncommitted_product/view/sale_double_validation_installer.xml 2012-07-23 01:29:21 +0000
383@@ -0,0 +1,57 @@
384+<?xml version="1.0" encoding="utf-8"?>
385+<openerp>
386+ <data>
387+ <!-- configartion view -->
388+
389+ <record id="view_config_sale_approval_group" model="ir.ui.view">
390+ <field name="name">Configure Approval Group for Sale </field>
391+ <field name="model">sale.double.validation.installer</field>
392+ <field name="type">form</field>
393+ <field name="inherit_id" ref="base.res_config_view_base"/>
394+ <field name="arch" type="xml">
395+ <data>
396+ <form position="attributes">
397+ <attribute name="string">Sale Application Configuration</attribute>
398+ </form>
399+ <separator string="title" position="attributes">
400+ <attribute name="string">Configure Approval Group for Sale Orders</attribute>
401+ </separator>
402+ <xpath expr="//label[@string='description']" position="attributes">
403+ <attribute name="string">Define the group which will approve the Sale Orders.</attribute>
404+ </xpath>
405+ <xpath expr='//separator[@string="vsep"]' position='attributes'>
406+ <attribute name='rowspan'>15</attribute>
407+ <attribute name='string'></attribute>
408+ </xpath>
409+ <group string="res_config_contents" position="replace">
410+ <field name="group_id"/>
411+ <newline/>
412+ <field name="commit_group_id"/>
413+ <newline/>
414+ <field name="force_commit_group_id"/>
415+ <newline/>
416+ </group>
417+ </data>
418+ </field>
419+ </record>
420+
421+ <record id="action_config_sale_approval_group" model="ir.actions.act_window">
422+ <field name="name">Configure Approval Group for Sale </field>
423+ <field name="type">ir.actions.act_window</field>
424+ <field name="res_model">sale.double.validation.installer</field>
425+ <field name="view_id" ref="view_config_sale_approval_group"/>
426+ <field name="view_type">form</field>
427+ <field name="view_mode">form</field>
428+ <field name="target">new</field>
429+ </record>
430+
431+ <!-- register configuration wizard -->
432+ <record id="sale_approval_group_installer" model="ir.actions.todo">
433+ <field name="action_id" ref="action_config_sale_approval_group"/>
434+ <field name="sequence">1</field>
435+ <field name="restart">always</field>
436+ <field eval="[(6,0,[ref('base.group_extended')])]" name="groups_id"/>
437+ </record>
438+
439+ </data>
440+</openerp>
441
442=== added file 'sale_uncommitted_product/view/sale_view.xml'
443--- sale_uncommitted_product/view/sale_view.xml 1970-01-01 00:00:00 +0000
444+++ sale_uncommitted_product/view/sale_view.xml 2012-07-23 01:29:21 +0000
445@@ -0,0 +1,58 @@
446+<?xml version="1.0" encoding="utf-8"?>
447+<openerp>
448+ <data>
449+
450+ <record id="view_sale_uncommitted_product_form" model="ir.ui.view">
451+ <field name="name">sale.uncommitted.product.form</field>
452+ <field name="model">sale.order</field>
453+ <field name="type">form</field>
454+ <field name="inherit_id" ref="sale.view_order_form"/>
455+ <field name="priority">26</field>
456+ <field name="arch" type="xml">
457+ <xpath expr="/form/notebook/page[@string='Sales Order']/group/field[@name='state']" position="after">
458+ <button name="order_commit" states="draft" string="Commit Order" icon="gtk-go-forward"/>
459+ <button name="force_order_commit" states="draft" string="Force Commit Order" icon="gtk-go-forward"/>
460+ </xpath>
461+ <xpath expr="/form/notebook/page[@string='Sales Order']/group/button[@name='cancel']" position="replace">
462+ <button name="cancel" states="committed" string="Cancel Order" icon="gtk-cancel"/>
463+ </xpath>
464+ <xpath expr="/form/notebook/page[@string='Sales Order']/group/button[@name='order_confirm']" position="replace">
465+ <button name="order_confirm" states="committed" string="Confirm Order" icon="gtk-apply"/>
466+ </xpath>
467+ <field name='date_confirm' position='before'>
468+ <field name='date_committed'/>
469+ </field>
470+ </field>
471+ </record>
472+
473+ <record id="view_sale_uncommitted_product_search" model="ir.ui.view">
474+ <field name="name">sale.uncommitted.product.search</field>
475+ <field name="model">sale.order</field>
476+ <field name="type">search</field>
477+ <field name="inherit_id" ref="sale.view_sales_order_filter"/>
478+ <field name="priority">26</field>
479+ <field name="arch" type="xml">
480+ <xpath expr="/search/filter[@string='Quotations']" position="after">
481+ <filter icon="gtk-media-pause" string="Commitments" domain="[('state','=','committed')]" help="Sales Order that have been committed to the Customers"/>
482+ <filter icon="gtk-cancel" string="Cancel" domain="[('state','=','cancel')]" help="Sales Order that have been cancelled"/>
483+ </xpath>
484+ </field>
485+ </record>
486+
487+
488+
489+ <record id="view_sale_uncommitted_product_tree" model="ir.ui.view">
490+ <field name="name">sale.uncommitted.product.tree</field>
491+ <field name="model">sale.order</field>
492+ <field name="type">tree</field>
493+ <field name="inherit_id" ref="sale.view_order_tree"/>
494+ <field name="priority">26</field>
495+ <field name="arch" type="xml">
496+ <xpath expr="/tree/field[@name='date_order']" position="after">
497+ <field name="date_committed"/>
498+ </xpath>
499+ </field>
500+ </record>
501+
502+ </data>
503+</openerp>
504
505=== added directory 'sale_uncommitted_product/wizard'
506=== added file 'sale_uncommitted_product/wizard/sale_double_validation_installer.py'
507--- sale_uncommitted_product/wizard/sale_double_validation_installer.py 1970-01-01 00:00:00 +0000
508+++ sale_uncommitted_product/wizard/sale_double_validation_installer.py 2012-07-23 01:29:21 +0000
509@@ -0,0 +1,76 @@
510+#!/usr/bin/python
511+# -*- encoding: utf-8 -*-
512+###########################################################################
513+# Module Writen to OpenERP, Open Source Management Solution
514+# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
515+# All Rights Reserved
516+###############Credits######################################################
517+# Coded by: Humberto Arocha <hbto@vauxoo.com>
518+# Planified by: Rafael Silva <rsilvam@vauxoo.com>
519+# Audited by: Nhomar Hernandez <nhomar@vauxoo.com>
520+#############################################################################
521+# This program is free software: you can redistribute it and/or modify
522+# it under the terms of the GNU Affero General Public License as published by
523+# the Free Software Foundation, either version 3 of the License, or
524+# (at your option) any later version.
525+#
526+# This program is distributed in the hope that it will be useful,
527+# but WITHOUT ANY WARRANTY; without even the implied warranty of
528+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
529+# GNU Affero General Public License for more details.
530+#
531+# You should have received a copy of the GNU Affero General Public License
532+# along with this program. If not, see <http://www.gnu.org/licenses/>.
533+################################################################################
534+
535+
536+from osv import fields, osv
537+
538+class sale_double_validation_installer(osv.osv_memory):
539+ _name = 'sale.double.validation.installer'
540+ _inherit = 'res.config'
541+ _columns = {
542+ 'force_commit_group_id': fields.many2one('res.groups','Force Commit Group', required=False,
543+ help='''Setting this field to a group will only allow to that group to make Commitment Sale Orders without checking if complying with contraints.
544+ Leave blank to allow any group to force to'''),
545+ 'commit_group_id': fields.many2one('res.groups','Commit Group', required=False,
546+ help='''Setting this field to a group will only allow to that group to make Commitment Sale Orders checking if complying with contraints.
547+ Leave blank to allow any group to commit to'''),
548+ 'group_id': fields.many2one('res.groups','Approval Group', required=False,
549+ help='''Setting this field to a group will only allow to that group to approve Sale Orders.
550+ Leave blank to allow any group to approve to'''),
551+ }
552+
553+ _defaults = {
554+ 'group_id': False,
555+ }
556+
557+ def execute(self, cr, uid, ids, context=None):
558+ data = self.read(cr, uid, ids, context=context)
559+
560+ force_commit_group_id = data and data[0]['force_commit_group_id'] or False
561+ commit_group_id = data and data[0]['commit_group_id'] or False
562+ group_id = data and data[0]['group_id'] or False
563+
564+ data_pool = self.pool.get('ir.model.data')
565+ transition_obj = self.pool.get('workflow.transition')
566+
567+ force = data_pool._get_id(cr, uid, 'sale_uncommitted_product', 'trans_draft_force_commit')
568+ force_id = data_pool.browse(cr, uid, force, context=context).res_id
569+ transition_obj.write(cr, uid, force_id, {'group_id': force_commit_group_id})
570+
571+ commit = data_pool._get_id(cr, uid, 'sale_uncommitted_product', 'trans_draft_commit')
572+ commit_id = data_pool.browse(cr, uid, commit, context=context).res_id
573+ transition_obj.write(cr, uid, commit_id, {'group_id': commit_group_id})
574+
575+ approval = data_pool._get_id(cr, uid, 'sale', 'trans_draft_router')
576+ approval_id = data_pool.browse(cr, uid, approval, context=context).res_id
577+ transition_obj.write(cr, uid, approval_id, {'group_id': group_id})
578+
579+ return {}
580+
581+sale_double_validation_installer()
582+
583+
584+
585+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
586
587=== added directory 'sale_uncommitted_product/workflow'
588=== added file 'sale_uncommitted_product/workflow/sale_workflow.xml'
589--- sale_uncommitted_product/workflow/sale_workflow.xml 1970-01-01 00:00:00 +0000
590+++ sale_uncommitted_product/workflow/sale_workflow.xml 2012-07-23 01:29:21 +0000
591@@ -0,0 +1,47 @@
592+<?xml version="1.0" encoding="utf-8"?>
593+<openerp>
594+ <data>
595+
596+ <!-- Activity -->
597+
598+ <record id="act_commit" model="workflow.activity">
599+ <field name="wkf_id" ref="sale.wkf_sale"/>
600+ <field name="name">commit</field>
601+ <field name="kind">function</field>
602+ <field name="action">action_commit()</field>
603+ <field name="split_mode">OR</field>
604+ </record>
605+
606+
607+
608+ <!-- Transistion -->
609+
610+
611+ <record id="trans_draft_commit" model="workflow.transition">
612+ <field name="act_from" ref="sale.act_draft"/>
613+ <field name="act_to" ref="act_commit"/>
614+ <field name="signal">order_commit</field>
615+ <field name="condition">check_committed()</field>
616+ </record>
617+
618+ <record id="trans_draft_force_commit" model="workflow.transition">
619+ <field name="act_from" ref="sale.act_draft"/>
620+ <field name="act_to" ref="act_commit"/>
621+ <field name="signal">force_order_commit</field>
622+ <field name="condition">True</field>
623+ </record>
624+
625+ <record id="sale.trans_draft_router" model="workflow.transition">
626+ <field name="act_from" ref="act_commit"/>
627+ <field name="act_to" ref="sale.act_router"/>
628+ <field name="signal">order_confirm</field>
629+ </record>
630+
631+ <record id="sale.trans_draft_cancel" model="workflow.transition">
632+ <field name="act_from" ref="act_commit"/>
633+ <field name="act_to" ref="sale.act_cancel"/>
634+ <field name="signal">cancel</field>
635+ </record>
636+
637+ </data>
638+</openerp>