Merge lp:~domsense/domsense-agilebg-addons/adding_product_variant_selection into lp:domsense-agilebg-addons/6.1

Proposed by Lorenzo Battistini
Status: Merged
Merged at revision: 233
Proposed branch: lp:~domsense/domsense-agilebg-addons/adding_product_variant_selection
Merge into: lp:domsense-agilebg-addons/6.1
Diff against target: 2691 lines (+2354/-0)
61 files modified
product_variant_selection/AUTHORS.txt (+1/-0)
product_variant_selection/__init__.py (+22/-0)
product_variant_selection/__openerp__.py (+42/-0)
product_variant_selection/invoice_line.py (+77/-0)
product_variant_selection/invoice_line_view.xml (+27/-0)
product_variant_selection/security/ir.model.access.csv (+4/-0)
purchase_delivery_term/AUTHORS.txt (+1/-0)
purchase_delivery_term/__init__.py (+22/-0)
purchase_delivery_term/__openerp__.py (+43/-0)
purchase_delivery_term/purchase.py (+189/-0)
purchase_delivery_term/purchase_view.xml (+82/-0)
purchase_delivery_term/security/ir.model.access.csv (+10/-0)
purchase_delivery_term_variant_selection/AUTHORS.txt (+1/-0)
purchase_delivery_term_variant_selection/__init__.py (+22/-0)
purchase_delivery_term_variant_selection/__openerp__.py (+40/-0)
purchase_delivery_term_variant_selection/purchase.py (+65/-0)
purchase_delivery_term_variant_selection/purchase_view.xml (+27/-0)
purchase_multi_picking/AUTHORS.txt (+1/-0)
purchase_multi_picking/__init__.py (+22/-0)
purchase_multi_picking/__openerp__.py (+42/-0)
purchase_multi_picking/purchase.py (+71/-0)
purchase_multi_picking/purchase_view.xml (+24/-0)
purchase_multi_picking/security/ir.model.access.csv (+5/-0)
purchase_product_variant_selection/AUTHORS.txt (+1/-0)
purchase_product_variant_selection/__init__.py (+22/-0)
purchase_product_variant_selection/__openerp__.py (+40/-0)
purchase_product_variant_selection/order_line.py (+49/-0)
purchase_product_variant_selection/purchase_order_line_view.xml (+27/-0)
sale_delivery_term/AUTHORS.txt (+1/-0)
sale_delivery_term/__init__.py (+22/-0)
sale_delivery_term/__openerp__.py (+43/-0)
sale_delivery_term/sale.py (+203/-0)
sale_delivery_term/sale_view.xml (+87/-0)
sale_delivery_term/security/ir.model.access.csv (+10/-0)
sale_delivery_term_variant_selection/AUTHORS.txt (+1/-0)
sale_delivery_term_variant_selection/__init__.py (+22/-0)
sale_delivery_term_variant_selection/__openerp__.py (+40/-0)
sale_delivery_term_variant_selection/sale.py (+65/-0)
sale_delivery_term_variant_selection/sale_view.xml (+27/-0)
sale_multi_picking/AUTHORS.txt (+1/-0)
sale_multi_picking/__init__.py (+22/-0)
sale_multi_picking/__openerp__.py (+42/-0)
sale_multi_picking/sale.py (+70/-0)
sale_multi_picking/sale_view.xml (+24/-0)
sale_multi_picking/security/ir.model.access.csv (+4/-0)
sale_product_variant_selection/AUTHORS.txt (+1/-0)
sale_product_variant_selection/__init__.py (+22/-0)
sale_product_variant_selection/__openerp__.py (+40/-0)
sale_product_variant_selection/order_line.py (+49/-0)
sale_product_variant_selection/sale_order_line_view.xml (+27/-0)
sale_purchase_orders_super_list/AUTHORS.txt (+1/-0)
sale_purchase_orders_super_list/__init__.py (+22/-0)
sale_purchase_orders_super_list/__openerp__.py (+39/-0)
sale_purchase_orders_super_list/orders.py (+157/-0)
sale_purchase_orders_super_list/orders_view.xml (+81/-0)
sale_purchase_orders_super_list/security/ir.model.access.csv (+5/-0)
stock_picking_related/AUTHORS.txt (+1/-0)
stock_picking_related/__init__.py (+22/-0)
stock_picking_related/__openerp__.py (+39/-0)
stock_picking_related/stock.py (+84/-0)
stock_picking_related/stock_view.xml (+101/-0)
To merge this branch: bzr merge lp:~domsense/domsense-agilebg-addons/adding_product_variant_selection
Reviewer Review Type Date Requested Status
Agile Business Group Pending
Review via email: mp+102455@code.launchpad.net
To post a comment you must log in.
194. By Lorenzo Battistini

[FIx] when variants data not complete

195. By Lorenzo Battistini

[add] not working frame_contract

196. By Lorenzo Battistini

[DEL] frame_contract

197. By Lorenzo Battistini

[ADD] stock_picking_related - working draft

198. By Lorenzo Battistini

[fix] readonly fields

199. By Lorenzo Battistini

[imp] module description

200. By Lorenzo Battistini

[ADD] sale_multi_picking

201. By Lorenzo Battistini

[ADD] sale_delivery_term - first not working draft

202. By Lorenzo Battistini

[ADD] sale_delivery_term - working prototype

203. By Lorenzo Battistini

[ADD] sale_delivery_term_variant_selection

204. By Lorenzo Battistini

[ADD] order line groups registry

205. By Lorenzo Battistini

[ADD] purchase_multi_picking

206. By Lorenzo Battistini

[ADD] purchase_delivery_term

207. By Lorenzo Battistini

[FIX] purchase_delivery_term

208. By Lorenzo Battistini

[ADD] purchase_delivery_term_variant_selection

209. By Lorenzo Battistini

[ADD] delivery terms - percentage check

210. By Lorenzo Battistini

[ADD] picking tree view

211. By Lorenzo Battistini

[ADD] delivery_term_variant_selection - writing variant data to detailed order lines

212. By Lorenzo Battistini

[add] stock_picking_related - qty and total qty

213. By Lorenzo Battistini

[ADD] sale_purchase_orders_super_list first draft

214. By Lorenzo Battistini

[fix] state view

215. By Lorenzo Battistini

[IMP] superlist enhancements

216. By Lorenzo Battistini

[fix] triggering computation

217. By Lorenzo Battistini

[rem] comments

218. By Lorenzo Battistini

[IMP] delivery terms
allowing duplicating orders

219. By Lorenzo Battistini

[fix] typo

220. By Lorenzo Battistini

[FIX] stock_picking_related - using the correct view

221. By Lorenzo Battistini

[IMP] delivery terms - allowing more flexibility for derivated modules

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'product_variant_selection'
2=== added file 'product_variant_selection/AUTHORS.txt'
3--- product_variant_selection/AUTHORS.txt 1970-01-01 00:00:00 +0000
4+++ product_variant_selection/AUTHORS.txt 2012-06-14 14:09:20 +0000
5@@ -0,0 +1,1 @@
6+Lorenzo Battistini <lorenzo.battistini@agilebg.com>
7
8=== added file 'product_variant_selection/__init__.py'
9--- product_variant_selection/__init__.py 1970-01-01 00:00:00 +0000
10+++ product_variant_selection/__init__.py 2012-06-14 14:09:20 +0000
11@@ -0,0 +1,22 @@
12+# -*- coding: utf-8 -*-
13+##############################################################################
14+#
15+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
16+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
17+# All Rights Reserved
18+#
19+# This program is free software: you can redistribute it and/or modify
20+# it under the terms of the GNU Affero General Public License as published
21+# by the Free Software Foundation, either version 3 of the License, or
22+# (at your option) any later version.
23+#
24+# This program is distributed in the hope that it will be useful,
25+# but WITHOUT ANY WARRANTY; without even the implied warranty of
26+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27+# GNU General Public License for more details.
28+#
29+# You should have received a copy of the GNU Affero General Public License
30+# along with this program. If not, see <http://www.gnu.org/licenses/>.
31+#
32+##############################################################################
33+import invoice_line
34
35=== added file 'product_variant_selection/__openerp__.py'
36--- product_variant_selection/__openerp__.py 1970-01-01 00:00:00 +0000
37+++ product_variant_selection/__openerp__.py 2012-06-14 14:09:20 +0000
38@@ -0,0 +1,42 @@
39+# -*- coding: utf-8 -*-
40+##############################################################################
41+#
42+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
43+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
44+# All Rights Reserved
45+#
46+# This program is free software: you can redistribute it and/or modify
47+# it under the terms of the GNU Affero General Public License as published
48+# by the Free Software Foundation, either version 3 of the License, or
49+# (at your option) any later version.
50+#
51+# This program is distributed in the hope that it will be useful,
52+# but WITHOUT ANY WARRANTY; without even the implied warranty of
53+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
54+# GNU General Public License for more details.
55+#
56+# You should have received a copy of the GNU Affero General Public License
57+# along with this program. If not, see <http://www.gnu.org/licenses/>.
58+#
59+##############################################################################
60+{
61+ 'name': "Product Variants Selection for Invoices",
62+ 'version': '0.1',
63+ 'category': 'Sales Management',
64+ 'description': """
65+This module helps to select the product when many variants are available in the system.
66+It extends the invoice line form allowing the user to pre-select product template and its variants in order to load the desired product(s) only.
67+""",
68+ 'author': 'Agile Business Group & Domsense',
69+ 'website': 'http://www.agilebg.com',
70+ 'license': 'AGPL-3',
71+ "depends" : ['account', 'product_variant_multi'],
72+ "init_xml" : [],
73+ "update_xml" : [
74+ 'invoice_line_view.xml',
75+ 'security/ir.model.access.csv',
76+ ],
77+ "demo_xml" : [],
78+ "active": False,
79+ "installable": True
80+}
81
82=== added directory 'product_variant_selection/i18n'
83=== added file 'product_variant_selection/invoice_line.py'
84--- product_variant_selection/invoice_line.py 1970-01-01 00:00:00 +0000
85+++ product_variant_selection/invoice_line.py 2012-06-14 14:09:20 +0000
86@@ -0,0 +1,77 @@
87+# -*- coding: utf-8 -*-
88+##############################################################################
89+#
90+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
91+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
92+# All Rights Reserved
93+#
94+# This program is free software: you can redistribute it and/or modify
95+# it under the terms of the GNU Affero General Public License as published
96+# by the Free Software Foundation, either version 3 of the License, or
97+# (at your option) any later version.
98+#
99+# This program is distributed in the hope that it will be useful,
100+# but WITHOUT ANY WARRANTY; without even the implied warranty of
101+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
102+# GNU General Public License for more details.
103+#
104+# You should have received a copy of the GNU Affero General Public License
105+# along with this program. If not, see <http://www.gnu.org/licenses/>.
106+#
107+##############################################################################
108+
109+from osv import fields,osv
110+
111+class account_invoice_line(osv.osv):
112+
113+ _inherit = "account.invoice.line"
114+ _columns = {
115+ "product_tmpl_id": fields.many2one('product.template', "Product Template"),
116+ 'variant_line_ids': fields.one2many('product.select.variant.line', 'invoice_line_id', 'Variants'),
117+ }
118+
119+ def pre_selection_changed(self, cr, uid, ids, product_tmpl_id, variant_line_ids):
120+ prod_ids = self.search_products(cr, uid, product_tmpl_id, variant_line_ids=variant_line_ids)
121+ res = {'domain': {'product_id': [('id', 'in', prod_ids)]}}
122+ if len(prod_ids) == 1:
123+ res['value'] = {'product_id': prod_ids[0]}
124+ return res
125+
126+ def search_products(self, cr, uid, product_tmpl_id, variant_line_ids=[], context=None):
127+ if context is None:
128+ context = {}
129+ prod_pool = self.pool.get('product.product')
130+ option_ids = []
131+ product_ids = []
132+ # collect options
133+ for variant in variant_line_ids:
134+ if variant[2] and variant[2].get('option_id', False) and variant[2]['option_id'] not in option_ids:
135+ option_ids.append(variant[2]['option_id'])
136+ # search for all variants of that template
137+ prod_ids = prod_pool.search(cr, uid, [('product_tmpl_id', '=', product_tmpl_id)],
138+ context=context)
139+ if option_ids:
140+ for prod in prod_pool.browse(cr, uid, prod_ids, context=context):
141+ options_found = 0
142+ for option_id in option_ids:
143+ # find matching variants
144+ if option_id in [dim.option_id.id for dim in prod.dimension_value_ids]:
145+ options_found +=1
146+ # if product contains every selected option
147+ if options_found == len(option_ids):
148+ product_ids.append(prod.id)
149+ else:
150+ product_ids = prod_ids
151+ return product_ids
152+
153+account_invoice_line()
154+
155+class product_select_variant_line(osv.osv):
156+
157+ _name = "product.select.variant.line"
158+ _columns = {
159+ 'dimension_id' : fields.many2one('product.variant.dimension.type', 'Dimension Type', required=True),
160+ 'option_id' : fields.many2one('product.variant.dimension.option', 'Option', required=True),
161+ 'invoice_line_id': fields.many2one('account.invoice.line', 'Invoice line'),
162+ }
163+product_select_variant_line()
164
165=== added file 'product_variant_selection/invoice_line_view.xml'
166--- product_variant_selection/invoice_line_view.xml 1970-01-01 00:00:00 +0000
167+++ product_variant_selection/invoice_line_view.xml 2012-06-14 14:09:20 +0000
168@@ -0,0 +1,27 @@
169+<?xml version="1.0" encoding="utf-8"?>
170+<openerp>
171+ <data>
172+ <record id="view_invoice_line_form" model="ir.ui.view">
173+ <field name="name">account.invoice.line.form</field>
174+ <field name="model">account.invoice.line</field>
175+ <field name="type">form</field>
176+ <field name="inherit_id" ref="account.view_invoice_line_form"></field>
177+ <field name="arch" type="xml">
178+ <field name="product_id" position="before">
179+ <field name="product_tmpl_id" on_change="pre_selection_changed(product_tmpl_id, variant_line_ids)"/>
180+ <newline/>
181+ <field name="variant_line_ids" on_change="pre_selection_changed(product_tmpl_id, variant_line_ids)" nolabel="1" colspan="4" attrs="{'readonly': [('product_tmpl_id', '=', False)]}">
182+ <tree string="Variants" editable="bottom">
183+ <field name="dimension_id"></field>
184+ <field name="option_id" domain="[('dimension_id', '=', dimension_id)]"></field>
185+ </tree>
186+ <form string="Variants" >
187+ <field name="dimension_id"></field>
188+ <field name="option_id" domain="[('dimension_id', '=', dimension_id)]"></field>
189+ </form>
190+ </field>
191+ </field>
192+ </field>
193+ </record>
194+ </data>
195+</openerp>
196
197=== added directory 'product_variant_selection/security'
198=== added file 'product_variant_selection/security/ir.model.access.csv'
199--- product_variant_selection/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
200+++ product_variant_selection/security/ir.model.access.csv 2012-06-14 14:09:20 +0000
201@@ -0,0 +1,4 @@
202+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
203+product_select_variant_line,product_select_variant_line,model_product_select_variant_line,account.group_account_invoice,1,1,1,1
204+product_select_variant_line_user,product_select_variant_line user,model_product_select_variant_line,base.group_user,1,0,0,0
205+product_select_variant_line_accountant,product_select_variant_line accountant,model_product_select_variant_line,account.group_account_user,1,0,0,0
206
207=== added directory 'purchase_delivery_term'
208=== added file 'purchase_delivery_term/AUTHORS.txt'
209--- purchase_delivery_term/AUTHORS.txt 1970-01-01 00:00:00 +0000
210+++ purchase_delivery_term/AUTHORS.txt 2012-06-14 14:09:20 +0000
211@@ -0,0 +1,1 @@
212+Lorenzo Battistini <lorenzo.battistini@agilebg.com>
213
214=== added file 'purchase_delivery_term/__init__.py'
215--- purchase_delivery_term/__init__.py 1970-01-01 00:00:00 +0000
216+++ purchase_delivery_term/__init__.py 2012-06-14 14:09:20 +0000
217@@ -0,0 +1,22 @@
218+# -*- coding: utf-8 -*-
219+##############################################################################
220+#
221+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
222+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
223+# All Rights Reserved
224+#
225+# This program is free software: you can redistribute it and/or modify
226+# it under the terms of the GNU Affero General Public License as published
227+# by the Free Software Foundation, either version 3 of the License, or
228+# (at your option) any later version.
229+#
230+# This program is distributed in the hope that it will be useful,
231+# but WITHOUT ANY WARRANTY; without even the implied warranty of
232+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
233+# GNU General Public License for more details.
234+#
235+# You should have received a copy of the GNU Affero General Public License
236+# along with this program. If not, see <http://www.gnu.org/licenses/>.
237+#
238+##############################################################################
239+import purchase
240
241=== added file 'purchase_delivery_term/__openerp__.py'
242--- purchase_delivery_term/__openerp__.py 1970-01-01 00:00:00 +0000
243+++ purchase_delivery_term/__openerp__.py 2012-06-14 14:09:20 +0000
244@@ -0,0 +1,43 @@
245+# -*- coding: utf-8 -*-
246+##############################################################################
247+#
248+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
249+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
250+# All Rights Reserved
251+#
252+# This program is free software: you can redistribute it and/or modify
253+# it under the terms of the GNU Affero General Public License as published
254+# by the Free Software Foundation, either version 3 of the License, or
255+# (at your option) any later version.
256+#
257+# This program is distributed in the hope that it will be useful,
258+# but WITHOUT ANY WARRANTY; without even the implied warranty of
259+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
260+# GNU General Public License for more details.
261+#
262+# You should have received a copy of the GNU Affero General Public License
263+# along with this program. If not, see <http://www.gnu.org/licenses/>.
264+#
265+##############################################################################
266+{
267+ 'name': "Purchase delivery terms",
268+ 'version': '0.1',
269+ 'category': 'Purchase Management',
270+ 'description': """
271+Delivery term for purchase orders.
272+You can configure delivery terms specifying the quantity percentage and the delay for every term line.
273+You can then associate the term to the 'main' order line and generate the 'detailed' order lines which in turn will generate several pickings according to delivery term (thanks to 'purchase_multi_picking' module).
274+""",
275+ 'author': 'Agile Business Group & Domsense',
276+ 'website': 'http://www.agilebg.com',
277+ 'license': 'AGPL-3',
278+ "depends" : ['purchase_multi_picking'],
279+ "init_xml" : [],
280+ "update_xml" : [
281+ 'purchase_view.xml',
282+ 'security/ir.model.access.csv',
283+ ],
284+ "demo_xml" : [],
285+ "active": False,
286+ "installable": True
287+}
288
289=== added directory 'purchase_delivery_term/i18n'
290=== added file 'purchase_delivery_term/purchase.py'
291--- purchase_delivery_term/purchase.py 1970-01-01 00:00:00 +0000
292+++ purchase_delivery_term/purchase.py 2012-06-14 14:09:20 +0000
293@@ -0,0 +1,189 @@
294+# -*- coding: utf-8 -*-
295+##############################################################################
296+#
297+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
298+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
299+# All Rights Reserved
300+#
301+# This program is free software: you can redistribute it and/or modify
302+# it under the terms of the GNU Affero General Public License as published
303+# by the Free Software Foundation, either version 3 of the License, or
304+# (at your option) any later version.
305+#
306+# This program is distributed in the hope that it will be useful,
307+# but WITHOUT ANY WARRANTY; without even the implied warranty of
308+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
309+# GNU General Public License for more details.
310+#
311+# You should have received a copy of the GNU Affero General Public License
312+# along with this program. If not, see <http://www.gnu.org/licenses/>.
313+#
314+##############################################################################
315+
316+from osv import fields, osv
317+from tools.translate import _
318+import decimal_precision as dp
319+from datetime import datetime, timedelta
320+from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
321+
322+class purchase_delivery_term(osv.osv):
323+ _name = 'purchase.delivery.term'
324+ _columns = {
325+ 'name': fields.char('Name', size=64, required=True),
326+ 'line_ids': fields.one2many('purchase.delivery.term.line', 'term_id', 'Lines', required=True),
327+ 'company_id': fields.many2one('res.company','Company',required=True,select=1),
328+ }
329+ _defaults = {
330+ 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'purchase.delivery.term', context=c),
331+ }
332+
333+ def is_total_percentage_correct(self, cr, uid, term_ids, context=None):
334+ for term in self.browse(cr, uid, term_ids, context=context):
335+ total = 0.0
336+ for line in term.line_ids:
337+ total += line.quantity_perc
338+ if total != 1 :
339+ return False
340+ return True
341+
342+purchase_delivery_term()
343+
344+class purchase_delivery_term_line(osv.osv):
345+
346+ _name = 'purchase.delivery.term.line'
347+ _columns = {
348+ 'term_id': fields.many2one('purchase.delivery.term', 'Term'),
349+ 'quantity_perc': fields.float('Quantity percentage', required=True, help="For 20% set '0.2'"),
350+ 'delay': fields.float('Delivery Lead Time', required=True,
351+ help="Number of days between the order confirmation and the shipping of the products from the supplier"),
352+ }
353+purchase_delivery_term_line()
354+
355+class purchase_order_line_master(osv.osv):
356+
357+ def onchange_product_id(self, cr, uid, ids, pricelist_id, product_id, qty, uom_id,
358+ partner_id, date_order=False, fiscal_position_id=False, date_planned=False,
359+ name=False, price_unit=False, notes=False, context=None):
360+ return self.pool.get('purchase.order.line').onchange_product_id(
361+ cr, uid, ids, pricelist_id, product_id, qty, uom_id,
362+ partner_id, date_order=date_order, fiscal_position_id=fiscal_position_id, date_planned=date_planned,
363+ name=name, price_unit=price_unit, notes=notes, context=context)
364+
365+ def onchange_product_uom(self, cr, uid, ids, pricelist_id, product_id, qty, uom_id,
366+ partner_id, date_order=False, fiscal_position_id=False, date_planned=False,
367+ name=False, price_unit=False, notes=False, context=None):
368+ return self.pool.get('purchase.order.line').onchange_product_uom(cr, uid, ids, pricelist_id, product_id, qty, uom_id,
369+ partner_id, date_order=date_order, fiscal_position_id=fiscal_position_id, date_planned=date_planned,
370+ name=name, price_unit=price_unit, notes=notes, context=context)
371+
372+ def _amount_line(self, cr, uid, ids, prop, arg, context=None):
373+ res = {}
374+ cur_obj=self.pool.get('res.currency')
375+ tax_obj = self.pool.get('account.tax')
376+ for line in self.browse(cr, uid, ids, context=context):
377+ taxes = tax_obj.compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty)
378+ cur = line.order_id.pricelist_id.currency_id
379+ res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
380+ return res
381+
382+ def _get_uom_id(self, cr, uid, context=None):
383+ return self.pool.get('purchase.order.line')._get_uom_id(cr, uid, context=context)
384+
385+ _name = 'purchase.order.line.master'
386+ _columns = {
387+ 'order_id': fields.many2one('purchase.order', 'Order Reference', select=True, required=True, ondelete='cascade'),
388+ 'delivery_term_id': fields.many2one('purchase.delivery.term', 'Delivery term', required=True),
389+ 'name': fields.char('Description', size=256, required=True),
390+ 'product_id': fields.many2one('product.product', 'Product', domain=[('purchase_ok','=',True)], change_default=True),
391+ 'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Purchase Price')),
392+ 'price_subtotal': fields.function(_amount_line, string='Subtotal', digits_compute= dp.get_precision('Purchase Price')),
393+ 'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product UoM'), required=True),
394+ 'product_uom': fields.many2one('product.uom', 'Product UOM', required=True),
395+ 'order_line_ids': fields.one2many('purchase.order.line', 'master_line_id', 'Detailed lines'),
396+ 'taxes_id': fields.many2many('account.tax', 'purchase_master_order_line_tax', 'ord_line_id', 'tax_id', 'Taxes'),
397+ 'date_planned': fields.date('Scheduled Date', required=True, select=True),
398+ }
399+ _defaults = {
400+ 'product_uom' : _get_uom_id,
401+ 'product_qty': lambda *a: 1.0,
402+ }
403+
404+ def generate_detailed_lines(self, cr, uid, ids, context=None):
405+ group_pool = self.pool.get('purchase.order.line.group')
406+ order_line_pool = self.pool.get('purchase.order.line')
407+ group_ids = group_pool.search(cr, uid, [])
408+ for master_line in self.browse(cr, uid, ids):
409+ if master_line.order_line_ids:
410+ raise osv.except_osv(_('Error'),
411+ _("Detailed lines generated yet (for master line '%s'). Remove them first") % master_line.name)
412+ if len(master_line.delivery_term_id.line_ids) > len(group_ids):
413+ raise osv.except_osv(_('Error'),
414+ _("Delivery term lines are %s. Order line groups are %s. Please create more groups")
415+ % (str(len(master_line.delivery_term_id.line_ids)), str(len(group_ids))))
416+ if not master_line.delivery_term_id.is_total_percentage_correct():
417+ raise osv.except_osv(_('Error'),
418+ _("Total percentage of delivery term %s is not equal to 1") % master_line.delivery_term_id.name)
419+ group_index = 0
420+ for term_line in master_line.delivery_term_id.line_ids:
421+ product_qty = master_line.product_qty * term_line.quantity_perc
422+ order_line_vals = {}
423+ on_change_res = order_line_pool.onchange_product_id(cr, uid, ids,
424+ master_line.order_id.pricelist_id.id, master_line.product_id.id, master_line.product_qty, master_line.product_uom.id,
425+ master_line.order_id.partner_id.id, date_order=master_line.order_id.date_order, fiscal_position_id=master_line.order_id.fiscal_position.id, date_planned=master_line.date_planned,
426+ name=master_line.name, price_unit=master_line.price_unit, notes=False, context=context)
427+ order_line_vals.update(on_change_res['value'])
428+ date_planned = datetime.strptime(master_line.date_planned,
429+ DEFAULT_SERVER_DATE_FORMAT) + timedelta(term_line.delay)
430+ order_line_vals.update({
431+ 'order_id': master_line.order_id.id,
432+ 'name': master_line.name,
433+ 'price_unit': master_line.price_unit,
434+ 'product_qty': product_qty,
435+ 'product_uom': master_line.product_uom.id,
436+ 'product_id': master_line.product_id and master_line.product_id.id or False,
437+ 'master_line_id': master_line.id,
438+ 'date_planned': date_planned,
439+ 'picking_group_id': group_ids[group_index],
440+ 'taxes_id': [(6,0, [tax.id for tax in master_line.taxes_id])],
441+ })
442+ group_index += 1
443+ order_line_pool.create(cr, uid, order_line_vals, context=context)
444+ return True
445+
446+ def copy_data(self, cr, uid, id, default=None, context=None):
447+ if not default:
448+ default = {}
449+ default.update({
450+ 'order_line_ids': [],
451+ })
452+ return super(purchase_order_line_master, self).copy_data(cr, uid, id, default, context=context)
453+
454+purchase_order_line_master()
455+
456+class purchase_order_line(osv.osv):
457+ _inherit = 'purchase.order.line'
458+ _columns = {
459+ 'master_line_id': fields.many2one('purchase.order.line.master', 'Master Line'),
460+ }
461+
462+ def copy_data(self, cr, uid, id, default=None, context=None):
463+ if not default:
464+ default = {}
465+ default.update({'master_line_id': False})
466+ return super(purchase_order_line, self).copy_data(cr, uid, id, default, context=context)
467+purchase_order_line()
468+
469+class purchase_order(osv.osv):
470+ _inherit = 'purchase.order'
471+ _columns = {
472+ 'master_order_line': fields.one2many('purchase.order.line.master', 'order_id', 'Master Order Lines', readonly=True, states={'draft': [('readonly', False)]}),
473+ }
474+
475+ def copy(self, cr, uid, id, default=None, context=None):
476+ if not default:
477+ default = {}
478+ default.update({
479+ 'order_line': [],
480+ })
481+ return super(purchase_order, self).copy(cr, uid, id, default, context=context)
482+purchase_order()
483
484=== added file 'purchase_delivery_term/purchase_view.xml'
485--- purchase_delivery_term/purchase_view.xml 1970-01-01 00:00:00 +0000
486+++ purchase_delivery_term/purchase_view.xml 2012-06-14 14:09:20 +0000
487@@ -0,0 +1,82 @@
488+<openerp>
489+ <data>
490+ <record id="purchase_delivery_term_form" model="ir.ui.view">
491+ <field name="name">purchase.delivery.term.form</field>
492+ <field name="model">purchase.delivery.term</field>
493+ <field name="type">form</field>
494+ <field name="arch" type="xml">
495+ <form string="Delivery term">
496+ <field name="name" select="1"/>
497+ <field name="line_ids" string="Term Lines" colspan="4" nolabel="1">
498+ <form>
499+ <field name="quantity_perc"></field>
500+ <field name="delay"></field>
501+ </form>
502+ <tree editable="bottom">
503+ <field name="quantity_perc"></field>
504+ <field name="delay"></field>
505+ </tree>
506+ </field>
507+ </form>
508+ </field>
509+ </record>
510+ <record id="action_delivery_term_form" model="ir.actions.act_window">
511+ <field name="name">Delivery Terms</field>
512+ <field name="type">ir.actions.act_window</field>
513+ <field name="res_model">purchase.delivery.term</field>
514+ <field name="view_type">form</field>
515+ <field name="view_mode">tree,form</field>
516+ </record>
517+
518+ <menuitem action="action_delivery_term_form" id="menu_action_delivery_term_form" parent="purchase.menu_configuration_misc" />
519+
520+ <record id="purchase_order_line_master_form" model="ir.ui.view">
521+ <field name="name">purchase_order_line_master_form</field>
522+ <field name="model">purchase.order.line.master</field>
523+ <field name="type">form</field>
524+ <field name="arch" type="xml">
525+ <form string="Master order line">
526+ <field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,False,context)" required="1"/>
527+ <field name="product_qty" on_change="onchange_product_id(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,price_unit,False,context)"/>
528+ <field name="product_uom" on_change="onchange_product_uom(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,False,context)"/>
529+ <field name="name" colspan="4"/>
530+ <field name="date_planned" widget="date"/>
531+ <field name="price_unit" />
532+ <field name="delivery_term_id" />
533+ <separator colspan="4" string="Taxes"/>
534+ <field colspan="4" nolabel="1" name="taxes_id"
535+ domain="[('parent_id','=',False),('type_tax_use','!=','sale')]"/>
536+ </form>
537+ </field>
538+ </record>
539+ <record id="purchase_order_line_master_tree" model="ir.ui.view">
540+ <field name="name">purchase_order_line_master_tree</field>
541+ <field name="model">purchase.order.line.master</field>
542+ <field name="type">tree</field>
543+ <field name="arch" type="xml">
544+ <tree string="Master order lines">
545+ <field name="date_planned" />
546+ <field name="name" />
547+ <field name="price_unit" />
548+ <field name="product_qty" />
549+ <field name="product_uom" />
550+ <field name="price_subtotal" />
551+ <field name="delivery_term_id" />
552+ <button name="generate_detailed_lines" string="Generate detailed lines" icon="gtk-go-forward" type="object"/>
553+ </tree>
554+ </field>
555+ </record>
556+
557+ <record id="purchase_order_form" model="ir.ui.view">
558+ <field name="name">purchase.order.form</field>
559+ <field name="model">purchase.order</field>
560+ <field name="type">form</field>
561+ <field name="inherit_id" ref="purchase.purchase_order_form"></field>
562+ <field name="arch" type="xml">
563+ <field name="order_line" position="before">
564+ <field colspan="4" name="master_order_line" nolabel="1"></field>
565+ </field>
566+ </field>
567+ </record>
568+ </data>
569+</openerp>
570
571=== added directory 'purchase_delivery_term/security'
572=== added file 'purchase_delivery_term/security/ir.model.access.csv'
573--- purchase_delivery_term/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
574+++ purchase_delivery_term/security/ir.model.access.csv 2012-06-14 14:09:20 +0000
575@@ -0,0 +1,10 @@
576+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
577+access_purchase_order_line_master,purchase.order.line_master user,model_purchase_order_line_master,purchase.group_purchase_user,1,1,1,1
578+access_purchase_order_line_master_stock_worker,purchase.order.line_master stock,model_purchase_order_line_master,stock.group_stock_user,1,0,0,0
579+access_purchase_order_line_master_manager,purchase.order.line_master manager,model_purchase_order_line_master,purchase.group_purchase_manager,1,1,1,1
580+access_purchase_delivery_term,purchase_delivery_term user,model_purchase_delivery_term,purchase.group_purchase_user,1,0,0,0
581+access_purchase_delivery_term_stock_worker,purchase_delivery_term stock,model_purchase_delivery_term,stock.group_stock_user,1,0,0,0
582+access_purchase_delivery_term_manager,purchase_delivery_term manager,model_purchase_delivery_term,purchase.group_purchase_manager,1,1,1,1
583+access_purchase_delivery_term_line,purchase_delivery_term_line user,model_purchase_delivery_term_line,purchase.group_purchase_user,1,0,0,0
584+access_purchase_delivery_term_line_stock_worker,purchase_delivery_term_line stock,model_purchase_delivery_term_line,stock.group_stock_user,1,0,0,0
585+access_purchase_delivery_term_line_manager,purchase_delivery_term_line manager,model_purchase_delivery_term_line,purchase.group_purchase_manager,1,1,1,1
586
587=== added directory 'purchase_delivery_term_variant_selection'
588=== added file 'purchase_delivery_term_variant_selection/AUTHORS.txt'
589--- purchase_delivery_term_variant_selection/AUTHORS.txt 1970-01-01 00:00:00 +0000
590+++ purchase_delivery_term_variant_selection/AUTHORS.txt 2012-06-14 14:09:20 +0000
591@@ -0,0 +1,1 @@
592+Lorenzo Battistini <lorenzo.battistini@agilebg.com>
593
594=== added file 'purchase_delivery_term_variant_selection/__init__.py'
595--- purchase_delivery_term_variant_selection/__init__.py 1970-01-01 00:00:00 +0000
596+++ purchase_delivery_term_variant_selection/__init__.py 2012-06-14 14:09:20 +0000
597@@ -0,0 +1,22 @@
598+# -*- coding: utf-8 -*-
599+##############################################################################
600+#
601+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
602+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
603+# All Rights Reserved
604+#
605+# This program is free software: you can redistribute it and/or modify
606+# it under the terms of the GNU Affero General Public License as published
607+# by the Free Software Foundation, either version 3 of the License, or
608+# (at your option) any later version.
609+#
610+# This program is distributed in the hope that it will be useful,
611+# but WITHOUT ANY WARRANTY; without even the implied warranty of
612+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
613+# GNU General Public License for more details.
614+#
615+# You should have received a copy of the GNU Affero General Public License
616+# along with this program. If not, see <http://www.gnu.org/licenses/>.
617+#
618+##############################################################################
619+import purchase
620
621=== added file 'purchase_delivery_term_variant_selection/__openerp__.py'
622--- purchase_delivery_term_variant_selection/__openerp__.py 1970-01-01 00:00:00 +0000
623+++ purchase_delivery_term_variant_selection/__openerp__.py 2012-06-14 14:09:20 +0000
624@@ -0,0 +1,40 @@
625+# -*- coding: utf-8 -*-
626+##############################################################################
627+#
628+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
629+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
630+# All Rights Reserved
631+#
632+# This program is free software: you can redistribute it and/or modify
633+# it under the terms of the GNU Affero General Public License as published
634+# by the Free Software Foundation, either version 3 of the License, or
635+# (at your option) any later version.
636+#
637+# This program is distributed in the hope that it will be useful,
638+# but WITHOUT ANY WARRANTY; without even the implied warranty of
639+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
640+# GNU General Public License for more details.
641+#
642+# You should have received a copy of the GNU Affero General Public License
643+# along with this program. If not, see <http://www.gnu.org/licenses/>.
644+#
645+##############################################################################
646+{
647+ 'name': "Purchase delivery term with variant selection",
648+ 'version': '0.1',
649+ 'category': 'Purchase Management',
650+ 'description': """
651+Product Variants Selection for Purchase Orders with delivery terms - See 'product_variant_selection' and 'purchase_delivery_term' modules
652+""",
653+ 'author': 'Agile Business Group & Domsense',
654+ 'website': 'http://www.agilebg.com',
655+ 'license': 'AGPL-3',
656+ "depends" : ['purchase_product_variant_selection', 'purchase_delivery_term'],
657+ "init_xml" : [],
658+ "update_xml" : [
659+ 'purchase_view.xml',
660+ ],
661+ "demo_xml" : [],
662+ "active": False,
663+ "installable": True
664+}
665
666=== added directory 'purchase_delivery_term_variant_selection/i18n'
667=== added file 'purchase_delivery_term_variant_selection/purchase.py'
668--- purchase_delivery_term_variant_selection/purchase.py 1970-01-01 00:00:00 +0000
669+++ purchase_delivery_term_variant_selection/purchase.py 2012-06-14 14:09:20 +0000
670@@ -0,0 +1,65 @@
671+# -*- coding: utf-8 -*-
672+##############################################################################
673+#
674+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
675+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
676+# All Rights Reserved
677+#
678+# This program is free software: you can redistribute it and/or modify
679+# it under the terms of the GNU Affero General Public License as published
680+# by the Free Software Foundation, either version 3 of the License, or
681+# (at your option) any later version.
682+#
683+# This program is distributed in the hope that it will be useful,
684+# but WITHOUT ANY WARRANTY; without even the implied warranty of
685+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
686+# GNU General Public License for more details.
687+#
688+# You should have received a copy of the GNU Affero General Public License
689+# along with this program. If not, see <http://www.gnu.org/licenses/>.
690+#
691+##############################################################################
692+
693+from osv import fields,osv
694+
695+class purchase_order_line_master(osv.osv):
696+
697+ _inherit = "purchase.order.line.master"
698+ _columns = {
699+ "product_tmpl_id": fields.many2one('product.template', "Product Template"),
700+ 'variant_line_ids': fields.one2many('product.select.variant.line', 'master_po_line_id', 'Variants'),
701+ }
702+
703+ def pre_selection_changed(self, cr, uid, ids, product_tmpl_id, variant_line_ids):
704+ prod_ids = self.pool.get('account.invoice.line').search_products(
705+ cr, uid, product_tmpl_id, variant_line_ids=variant_line_ids)
706+ res = {'domain': {'product_id': [('id', 'in', prod_ids)]}}
707+ if len(prod_ids) == 1:
708+ res['value'] = {'product_id': prod_ids[0]}
709+ return res
710+
711+ def generate_detailed_lines(self, cr, uid, ids, context=None):
712+ res = super(purchase_order_line_master, self).generate_detailed_lines(
713+ cr, uid, ids, context=context)
714+ var_line_pool = self.pool.get('product.select.variant.line')
715+ for master_line in self.browse(cr, uid, ids, context=context):
716+ for order_line in master_line.order_line_ids:
717+ if master_line.product_tmpl_id:
718+ order_line.write({'product_tmpl_id': master_line.product_tmpl_id.id})
719+ for variant_line in master_line.variant_line_ids:
720+ var_line_pool.create(cr, uid, {
721+ 'dimension_id': variant_line.dimension_id.id,
722+ 'option_id': variant_line.option_id.id,
723+ 'po_line_id': order_line.id,
724+ }, context=context)
725+ return res
726+
727+purchase_order_line_master()
728+
729+class product_select_variant_line(osv.osv):
730+
731+ _inherit = "product.select.variant.line"
732+ _columns = {
733+ 'master_po_line_id': fields.many2one('purchase.order.line.master', 'Master PO line'),
734+ }
735+product_select_variant_line()
736
737=== added file 'purchase_delivery_term_variant_selection/purchase_view.xml'
738--- purchase_delivery_term_variant_selection/purchase_view.xml 1970-01-01 00:00:00 +0000
739+++ purchase_delivery_term_variant_selection/purchase_view.xml 2012-06-14 14:09:20 +0000
740@@ -0,0 +1,27 @@
741+<?xml version="1.0" encoding="utf-8"?>
742+<openerp>
743+ <data>
744+ <record id="view_purchase_order_line_master_form" model="ir.ui.view">
745+ <field name="name">purchase.order.line.master.form</field>
746+ <field name="model">purchase.order.line.master</field>
747+ <field name="type">form</field>
748+ <field name="inherit_id" ref="purchase_delivery_term.purchase_order_line_master_form"></field>
749+ <field name="arch" type="xml">
750+ <field name="product_id" position="before">
751+ <field name="product_tmpl_id" on_change="pre_selection_changed(product_tmpl_id, variant_line_ids)"/>
752+ <newline/>
753+ <field name="variant_line_ids" on_change="pre_selection_changed(product_tmpl_id, variant_line_ids)" nolabel="1" colspan="5" attrs="{'readonly': [('product_tmpl_id', '=', False)]}">
754+ <tree string="Variants" editable="bottom">
755+ <field name="dimension_id"></field>
756+ <field name="option_id" domain="[('dimension_id', '=', dimension_id)]"></field>
757+ </tree>
758+ <form string="Variants" >
759+ <field name="dimension_id"></field>
760+ <field name="option_id" domain="[('dimension_id', '=', dimension_id)]"></field>
761+ </form>
762+ </field>
763+ </field>
764+ </field>
765+ </record>
766+ </data>
767+</openerp>
768
769=== added directory 'purchase_delivery_term_variant_selection/security'
770=== added directory 'purchase_multi_picking'
771=== added file 'purchase_multi_picking/AUTHORS.txt'
772--- purchase_multi_picking/AUTHORS.txt 1970-01-01 00:00:00 +0000
773+++ purchase_multi_picking/AUTHORS.txt 2012-06-14 14:09:20 +0000
774@@ -0,0 +1,1 @@
775+Lorenzo Battistini <lorenzo.battistini@agilebg.com>
776
777=== added file 'purchase_multi_picking/__init__.py'
778--- purchase_multi_picking/__init__.py 1970-01-01 00:00:00 +0000
779+++ purchase_multi_picking/__init__.py 2012-06-14 14:09:20 +0000
780@@ -0,0 +1,22 @@
781+# -*- coding: utf-8 -*-
782+##############################################################################
783+#
784+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
785+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
786+# All Rights Reserved
787+#
788+# This program is free software: you can redistribute it and/or modify
789+# it under the terms of the GNU Affero General Public License as published
790+# by the Free Software Foundation, either version 3 of the License, or
791+# (at your option) any later version.
792+#
793+# This program is distributed in the hope that it will be useful,
794+# but WITHOUT ANY WARRANTY; without even the implied warranty of
795+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
796+# GNU General Public License for more details.
797+#
798+# You should have received a copy of the GNU Affero General Public License
799+# along with this program. If not, see <http://www.gnu.org/licenses/>.
800+#
801+##############################################################################
802+import purchase
803
804=== added file 'purchase_multi_picking/__openerp__.py'
805--- purchase_multi_picking/__openerp__.py 1970-01-01 00:00:00 +0000
806+++ purchase_multi_picking/__openerp__.py 2012-06-14 14:09:20 +0000
807@@ -0,0 +1,42 @@
808+# -*- coding: utf-8 -*-
809+##############################################################################
810+#
811+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
812+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
813+# All Rights Reserved
814+#
815+# This program is free software: you can redistribute it and/or modify
816+# it under the terms of the GNU Affero General Public License as published
817+# by the Free Software Foundation, either version 3 of the License, or
818+# (at your option) any later version.
819+#
820+# This program is distributed in the hope that it will be useful,
821+# but WITHOUT ANY WARRANTY; without even the implied warranty of
822+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
823+# GNU General Public License for more details.
824+#
825+# You should have received a copy of the GNU Affero General Public License
826+# along with this program. If not, see <http://www.gnu.org/licenses/>.
827+#
828+##############################################################################
829+{
830+ 'name': "Multi Pickings from Purchase Orders",
831+ 'version': '0.1',
832+ 'category': 'Purchase Management',
833+ 'description': """
834+This module allows to generate several pickings from the same purchase order.
835+You just have to indicate which order lines have to be grouped in the same picking. When confirming the order, for each group a picking is generated.
836+""",
837+ 'author': 'Agile Business Group & Domsense',
838+ 'website': 'http://www.agilebg.com',
839+ 'license': 'AGPL-3',
840+ "depends" : ['purchase'],
841+ "init_xml" : [],
842+ "update_xml" : [
843+ 'purchase_view.xml',
844+ 'security/ir.model.access.csv',
845+ ],
846+ "demo_xml" : [],
847+ "active": False,
848+ "installable": True
849+}
850
851=== added directory 'purchase_multi_picking/i18n'
852=== added file 'purchase_multi_picking/purchase.py'
853--- purchase_multi_picking/purchase.py 1970-01-01 00:00:00 +0000
854+++ purchase_multi_picking/purchase.py 2012-06-14 14:09:20 +0000
855@@ -0,0 +1,71 @@
856+# -*- coding: utf-8 -*-
857+##############################################################################
858+#
859+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
860+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
861+# All Rights Reserved
862+#
863+# This program is free software: you can redistribute it and/or modify
864+# it under the terms of the GNU Affero General Public License as published
865+# by the Free Software Foundation, either version 3 of the License, or
866+# (at your option) any later version.
867+#
868+# This program is distributed in the hope that it will be useful,
869+# but WITHOUT ANY WARRANTY; without even the implied warranty of
870+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
871+# GNU General Public License for more details.
872+#
873+# You should have received a copy of the GNU Affero General Public License
874+# along with this program. If not, see <http://www.gnu.org/licenses/>.
875+#
876+##############################################################################
877+
878+from osv import fields, osv
879+
880+class purchase_order_line_group(osv.osv):
881+ _name = 'purchase.order.line.group'
882+ _columns = {
883+ 'name': fields.char('Group', size=64, required=True),
884+ 'company_id': fields.many2one('res.company','Company',required=True,select=1),
885+ }
886+ _defaults = {
887+ 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'purchase.order.line.group', context=c),
888+ }
889+purchase_order_line_group()
890+
891+class purchase_order_line(osv.osv):
892+ _inherit = 'purchase.order.line'
893+ _columns = {
894+ 'picking_group_id': fields.many2one('purchase.order.line.group', 'Group'),
895+ }
896+purchase_order_line()
897+
898+class purchase_order(osv.osv):
899+ _inherit = 'purchase.order'
900+
901+ def action_picking_create(self, cr, uid, ids, context=None):
902+ picking_pool = self.pool.get('stock.picking')
903+ picking_ids = []
904+ for order in self.browse(cr, uid, ids, context=context):
905+ lines_by_group = {}
906+ for line in order.order_line:
907+ if line.picking_group_id:
908+ if not lines_by_group.get(line.picking_group_id.id, False):
909+ lines_by_group[line.picking_group_id.id] = []
910+ lines_by_group[line.picking_group_id.id].append(line)
911+ else:
912+ if not lines_by_group.get(0, False):
913+ lines_by_group[0] = []
914+ lines_by_group[0].append(line)
915+ for group in lines_by_group:
916+ if not group:
917+ picking_ids.extend(super(purchase_order, self)._create_pickings(
918+ cr, uid, order, lines_by_group[group], None, context=context))
919+ else:
920+ picking_vals = super(purchase_order, self)._prepare_order_picking(cr, uid, order, context=context)
921+ picking_id = picking_pool.create(cr, uid, picking_vals, context=context)
922+ picking_ids.extend(super(purchase_order, self)._create_pickings(
923+ cr, uid, order, lines_by_group[group], picking_id, context=context))
924+ return picking_ids[0] if picking_ids else False # ?
925+
926+purchase_order()
927
928=== added file 'purchase_multi_picking/purchase_view.xml'
929--- purchase_multi_picking/purchase_view.xml 1970-01-01 00:00:00 +0000
930+++ purchase_multi_picking/purchase_view.xml 2012-06-14 14:09:20 +0000
931@@ -0,0 +1,24 @@
932+<openerp>
933+ <data>
934+ <record id="purchase_order_line_form" model="ir.ui.view">
935+ <field name="name">purchase.order.line.form</field>
936+ <field name="model">purchase.order.line</field>
937+ <field name="type">form</field>
938+ <field name="inherit_id" ref="purchase.purchase_order_line_form"></field>
939+ <field name="arch" type="xml">
940+ <field name="account_analytic_id" position="after">
941+ <field name="picking_group_id"/>
942+ </field>
943+ </field>
944+ </record>
945+ <record id="action_purchase_order_line_group_form" model="ir.actions.act_window">
946+ <field name="name">Purchase order line Groups</field>
947+ <field name="type">ir.actions.act_window</field>
948+ <field name="res_model">purchase.order.line.group</field>
949+ <field name="view_type">form</field>
950+ <field name="view_mode">tree,form</field>
951+ </record>
952+
953+ <menuitem action="action_purchase_order_line_group_form" id="menu_action_purchase_order_line_group_form" parent="purchase.menu_configuration_misc" />
954+ </data>
955+</openerp>
956
957=== added directory 'purchase_multi_picking/security'
958=== added file 'purchase_multi_picking/security/ir.model.access.csv'
959--- purchase_multi_picking/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
960+++ purchase_multi_picking/security/ir.model.access.csv 2012-06-14 14:09:20 +0000
961@@ -0,0 +1,5 @@
962+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
963+access_purchase_order_line_group,purchase.order.line_group user,model_purchase_order_line_group,purchase.group_purchase_user,1,1,1,1
964+access_purchase_order_line_group_manager,purchase.order.line_group manager,model_purchase_order_line_group,purchase.group_purchase_manager,1,0,0,0
965+access_purchase_order_line_group_stock_worker,purchase.order.line_group manager,model_purchase_order_line_group,stock.group_stock_user,1,0,0,0
966+access_purchase_order_line_group_manager,purchase.order.line_group manager,model_purchase_order_line_group,purchase.group_purchase_manager,1,1,1,1
967
968=== added directory 'purchase_product_variant_selection'
969=== added file 'purchase_product_variant_selection/AUTHORS.txt'
970--- purchase_product_variant_selection/AUTHORS.txt 1970-01-01 00:00:00 +0000
971+++ purchase_product_variant_selection/AUTHORS.txt 2012-06-14 14:09:20 +0000
972@@ -0,0 +1,1 @@
973+Lorenzo Battistini <lorenzo.battistini@agilebg.com>
974
975=== added file 'purchase_product_variant_selection/__init__.py'
976--- purchase_product_variant_selection/__init__.py 1970-01-01 00:00:00 +0000
977+++ purchase_product_variant_selection/__init__.py 2012-06-14 14:09:20 +0000
978@@ -0,0 +1,22 @@
979+# -*- coding: utf-8 -*-
980+##############################################################################
981+#
982+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
983+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
984+# All Rights Reserved
985+#
986+# This program is free software: you can redistribute it and/or modify
987+# it under the terms of the GNU Affero General Public License as published
988+# by the Free Software Foundation, either version 3 of the License, or
989+# (at your option) any later version.
990+#
991+# This program is distributed in the hope that it will be useful,
992+# but WITHOUT ANY WARRANTY; without even the implied warranty of
993+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
994+# GNU General Public License for more details.
995+#
996+# You should have received a copy of the GNU Affero General Public License
997+# along with this program. If not, see <http://www.gnu.org/licenses/>.
998+#
999+##############################################################################
1000+import order_line
1001
1002=== added file 'purchase_product_variant_selection/__openerp__.py'
1003--- purchase_product_variant_selection/__openerp__.py 1970-01-01 00:00:00 +0000
1004+++ purchase_product_variant_selection/__openerp__.py 2012-06-14 14:09:20 +0000
1005@@ -0,0 +1,40 @@
1006+# -*- coding: utf-8 -*-
1007+##############################################################################
1008+#
1009+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
1010+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
1011+# All Rights Reserved
1012+#
1013+# This program is free software: you can redistribute it and/or modify
1014+# it under the terms of the GNU Affero General Public License as published
1015+# by the Free Software Foundation, either version 3 of the License, or
1016+# (at your option) any later version.
1017+#
1018+# This program is distributed in the hope that it will be useful,
1019+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1020+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1021+# GNU General Public License for more details.
1022+#
1023+# You should have received a copy of the GNU Affero General Public License
1024+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1025+#
1026+##############################################################################
1027+{
1028+ 'name': "Product Variants Selection for Purchase Orders",
1029+ 'version': '0.1',
1030+ 'category': 'Sales Management',
1031+ 'description': """
1032+Product Variants Selection for Purchase Orders - See 'product_variant_selection' module
1033+""",
1034+ 'author': 'Agile Business Group & Domsense',
1035+ 'website': 'http://www.agilebg.com',
1036+ 'license': 'AGPL-3',
1037+ "depends" : ['product_variant_selection', 'purchase'],
1038+ "init_xml" : [],
1039+ "update_xml" : [
1040+ 'purchase_order_line_view.xml',
1041+ ],
1042+ "demo_xml" : [],
1043+ "active": False,
1044+ "installable": True
1045+}
1046
1047=== added directory 'purchase_product_variant_selection/i18n'
1048=== added file 'purchase_product_variant_selection/order_line.py'
1049--- purchase_product_variant_selection/order_line.py 1970-01-01 00:00:00 +0000
1050+++ purchase_product_variant_selection/order_line.py 2012-06-14 14:09:20 +0000
1051@@ -0,0 +1,49 @@
1052+# -*- coding: utf-8 -*-
1053+##############################################################################
1054+#
1055+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
1056+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
1057+# All Rights Reserved
1058+#
1059+# This program is free software: you can redistribute it and/or modify
1060+# it under the terms of the GNU Affero General Public License as published
1061+# by the Free Software Foundation, either version 3 of the License, or
1062+# (at your option) any later version.
1063+#
1064+# This program is distributed in the hope that it will be useful,
1065+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1066+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1067+# GNU General Public License for more details.
1068+#
1069+# You should have received a copy of the GNU Affero General Public License
1070+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1071+#
1072+##############################################################################
1073+
1074+from osv import fields,osv
1075+
1076+class purchase_order_line(osv.osv):
1077+
1078+ _inherit = "purchase.order.line"
1079+ _columns = {
1080+ "product_tmpl_id": fields.many2one('product.template', "Product Template"),
1081+ 'variant_line_ids': fields.one2many('product.select.variant.line', 'po_line_id', 'Variants'),
1082+ }
1083+
1084+ def pre_selection_changed(self, cr, uid, ids, product_tmpl_id, variant_line_ids):
1085+ prod_ids = self.pool.get('account.invoice.line').search_products(
1086+ cr, uid, product_tmpl_id, variant_line_ids=variant_line_ids)
1087+ res = {'domain': {'product_id': [('id', 'in', prod_ids)]}}
1088+ if len(prod_ids) == 1:
1089+ res['value'] = {'product_id': prod_ids[0]}
1090+ return res
1091+
1092+purchase_order_line()
1093+
1094+class product_select_variant_line(osv.osv):
1095+
1096+ _inherit = "product.select.variant.line"
1097+ _columns = {
1098+ 'po_line_id': fields.many2one('purchase.order.line', 'PO line'),
1099+ }
1100+product_select_variant_line()
1101
1102=== added file 'purchase_product_variant_selection/purchase_order_line_view.xml'
1103--- purchase_product_variant_selection/purchase_order_line_view.xml 1970-01-01 00:00:00 +0000
1104+++ purchase_product_variant_selection/purchase_order_line_view.xml 2012-06-14 14:09:20 +0000
1105@@ -0,0 +1,27 @@
1106+<?xml version="1.0" encoding="utf-8"?>
1107+<openerp>
1108+ <data>
1109+ <record id="purchase_order_line_form" model="ir.ui.view">
1110+ <field name="name">purchase.order.line.form</field>
1111+ <field name="model">purchase.order.line</field>
1112+ <field name="type">form</field>
1113+ <field name="inherit_id" ref="purchase.purchase_order_line_form"></field>
1114+ <field name="arch" type="xml">
1115+ <field name="product_id" position="before">
1116+ <field name="product_tmpl_id" on_change="pre_selection_changed(product_tmpl_id, variant_line_ids)"/>
1117+ <newline/>
1118+ <field name="variant_line_ids" on_change="pre_selection_changed(product_tmpl_id, variant_line_ids)" nolabel="1" colspan="4" attrs="{'readonly': [('product_tmpl_id', '=', False)]}">
1119+ <tree string="Variants" editable="bottom">
1120+ <field name="dimension_id"></field>
1121+ <field name="option_id" domain="[('dimension_id', '=', dimension_id)]"></field>
1122+ </tree>
1123+ <form string="Variants" >
1124+ <field name="dimension_id"></field>
1125+ <field name="option_id" domain="[('dimension_id', '=', dimension_id)]"></field>
1126+ </form>
1127+ </field>
1128+ </field>
1129+ </field>
1130+ </record>
1131+ </data>
1132+</openerp>
1133
1134=== added directory 'purchase_product_variant_selection/security'
1135=== added directory 'sale_delivery_term'
1136=== added file 'sale_delivery_term/AUTHORS.txt'
1137--- sale_delivery_term/AUTHORS.txt 1970-01-01 00:00:00 +0000
1138+++ sale_delivery_term/AUTHORS.txt 2012-06-14 14:09:20 +0000
1139@@ -0,0 +1,1 @@
1140+Lorenzo Battistini <lorenzo.battistini@agilebg.com>
1141
1142=== added file 'sale_delivery_term/__init__.py'
1143--- sale_delivery_term/__init__.py 1970-01-01 00:00:00 +0000
1144+++ sale_delivery_term/__init__.py 2012-06-14 14:09:20 +0000
1145@@ -0,0 +1,22 @@
1146+# -*- coding: utf-8 -*-
1147+##############################################################################
1148+#
1149+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
1150+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
1151+# All Rights Reserved
1152+#
1153+# This program is free software: you can redistribute it and/or modify
1154+# it under the terms of the GNU Affero General Public License as published
1155+# by the Free Software Foundation, either version 3 of the License, or
1156+# (at your option) any later version.
1157+#
1158+# This program is distributed in the hope that it will be useful,
1159+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1160+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1161+# GNU General Public License for more details.
1162+#
1163+# You should have received a copy of the GNU Affero General Public License
1164+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1165+#
1166+##############################################################################
1167+import sale
1168
1169=== added file 'sale_delivery_term/__openerp__.py'
1170--- sale_delivery_term/__openerp__.py 1970-01-01 00:00:00 +0000
1171+++ sale_delivery_term/__openerp__.py 2012-06-14 14:09:20 +0000
1172@@ -0,0 +1,43 @@
1173+# -*- coding: utf-8 -*-
1174+##############################################################################
1175+#
1176+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
1177+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
1178+# All Rights Reserved
1179+#
1180+# This program is free software: you can redistribute it and/or modify
1181+# it under the terms of the GNU Affero General Public License as published
1182+# by the Free Software Foundation, either version 3 of the License, or
1183+# (at your option) any later version.
1184+#
1185+# This program is distributed in the hope that it will be useful,
1186+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1187+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1188+# GNU General Public License for more details.
1189+#
1190+# You should have received a copy of the GNU Affero General Public License
1191+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1192+#
1193+##############################################################################
1194+{
1195+ 'name': "Sale delivery terms",
1196+ 'version': '0.1',
1197+ 'category': 'Sales Management',
1198+ 'description': """
1199+Delivery term for sale orders.
1200+You can configure delivery terms specifying the quantity percentage and the delay for every term line.
1201+You can then associate the term to the 'main' order line and generate the 'detailed' order lines which in turn will generate several pickings according to delivery term (thanks to 'sale_multi_picking' module).
1202+""",
1203+ 'author': 'Agile Business Group & Domsense',
1204+ 'website': 'http://www.agilebg.com',
1205+ 'license': 'AGPL-3',
1206+ "depends" : ['sale_multi_picking'],
1207+ "init_xml" : [],
1208+ "update_xml" : [
1209+ 'sale_view.xml',
1210+ 'security/ir.model.access.csv',
1211+ ],
1212+ "demo_xml" : [],
1213+ "active": False,
1214+ "installable": True
1215+}
1216
1217=== added directory 'sale_delivery_term/i18n'
1218=== added file 'sale_delivery_term/sale.py'
1219--- sale_delivery_term/sale.py 1970-01-01 00:00:00 +0000
1220+++ sale_delivery_term/sale.py 2012-06-14 14:09:20 +0000
1221@@ -0,0 +1,203 @@
1222+# -*- coding: utf-8 -*-
1223+##############################################################################
1224+#
1225+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
1226+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
1227+# All Rights Reserved
1228+#
1229+# This program is free software: you can redistribute it and/or modify
1230+# it under the terms of the GNU Affero General Public License as published
1231+# by the Free Software Foundation, either version 3 of the License, or
1232+# (at your option) any later version.
1233+#
1234+# This program is distributed in the hope that it will be useful,
1235+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1236+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1237+# GNU General Public License for more details.
1238+#
1239+# You should have received a copy of the GNU Affero General Public License
1240+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1241+#
1242+##############################################################################
1243+
1244+from osv import fields, osv
1245+from tools.translate import _
1246+import decimal_precision as dp
1247+
1248+class sale_delivery_term(osv.osv):
1249+ _name = 'sale.delivery.term'
1250+ _columns = {
1251+ 'name': fields.char('Name', size=64, required=True),
1252+ 'line_ids': fields.one2many('sale.delivery.term.line', 'term_id', 'Lines', required=True),
1253+ 'company_id': fields.many2one('res.company','Company',required=True,select=1),
1254+ }
1255+ _defaults = {
1256+ 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'sale.delivery.term', context=c),
1257+ }
1258+
1259+ def is_total_percentage_correct(self, cr, uid, term_ids, context=None):
1260+ for term in self.browse(cr, uid, term_ids, context=context):
1261+ total = 0.0
1262+ for line in term.line_ids:
1263+ total += line.quantity_perc
1264+ if total != 1 :
1265+ return False
1266+ return True
1267+
1268+sale_delivery_term()
1269+
1270+class sale_delivery_term_line(osv.osv):
1271+
1272+ _name = 'sale.delivery.term.line'
1273+ _columns = {
1274+ 'term_id': fields.many2one('sale.delivery.term', 'Term'),
1275+ 'quantity_perc': fields.float('Quantity percentage', required=True, help="For 20% set '0.2'"),
1276+ 'delay': fields.float('Delivery Lead Time', required=True,
1277+ help="Number of days between the order confirmation and the shipping of the products to the customer"),
1278+ }
1279+sale_delivery_term_line()
1280+
1281+class sale_order_line_master(osv.osv):
1282+
1283+ def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
1284+ uom=False, qty_uos=0, uos=False, name='', partner_id=False,
1285+ lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None):
1286+ return self.pool.get('sale.order.line').product_id_change(cr, uid, ids, pricelist, product, qty=qty,
1287+ uom=uom, qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id,
1288+ lang=lang, update_tax=update_tax, date_order=date_order, packaging=packaging, fiscal_position=fiscal_position, flag=flag, context=context)
1289+
1290+ def product_uom_change(self, cursor, user, ids, pricelist, product, qty=0,
1291+ uom=False, qty_uos=0, uos=False, name='', partner_id=False,
1292+ lang=False, update_tax=True, date_order=False, context=None):
1293+ return self.pool.get('sale.order.line').product_uom_change(cursor, user, ids, pricelist, product, qty=qty,
1294+ uom=uom, qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id,
1295+ lang=lang, update_tax=update_tax, date_order=date_order, context=context)
1296+
1297+ def product_packaging_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False,
1298+ partner_id=False, packaging=False, flag=False, context=None):
1299+ return self.pool.get('sale.order.line').product_packaging_change(cr, uid, ids, pricelist, product, qty=qty, uom=uom, partner_id=partner_id, packaging=packaging, flag=flag, context=context)
1300+
1301+ def _amount_line(self, cr, uid, ids, field_name, arg, context=None):
1302+ tax_obj = self.pool.get('account.tax')
1303+ cur_obj = self.pool.get('res.currency')
1304+ res = {}
1305+ if context is None:
1306+ context = {}
1307+ for line in self.browse(cr, uid, ids, context=context):
1308+ price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
1309+ taxes = tax_obj.compute_all(cr, uid, line.tax_ids, price, line.product_uom_qty, line.order_id.partner_invoice_id.id, line.product_id, line.order_id.partner_id)
1310+ cur = line.order_id.pricelist_id.currency_id
1311+ res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
1312+ return res
1313+
1314+ def _get_uom_id(self, cr, uid, *args):
1315+ return self.pool.get('sale.order.line')._get_uom_id(cr, uid, args)
1316+
1317+ _name = 'sale.order.line.master'
1318+ _columns = {
1319+ 'order_id': fields.many2one('sale.order', 'Order Reference', required=True, ondelete='cascade'),
1320+ 'delivery_term_id': fields.many2one('sale.delivery.term', 'Delivery term', required=True),
1321+ 'name': fields.char('Description', size=256, required=True),
1322+ 'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True)]),
1323+ 'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Sale Price')),
1324+ 'price_subtotal': fields.function(_amount_line, string='Subtotal',
1325+ digits_compute= dp.get_precision('Sale Price')),
1326+ 'product_uom_qty': fields.float('Quantity (UoM)', digits_compute= dp.get_precision('Product UoS'), required=True),
1327+ 'product_uom': fields.many2one('product.uom', 'Unit of Measure ', required=True),
1328+ 'product_uos_qty': fields.float('Quantity (UoS)' ,digits_compute= dp.get_precision('Product UoS')),
1329+ 'product_uos': fields.many2one('product.uom', 'Product UoS'),
1330+ 'product_packaging': fields.many2one('product.packaging', 'Packaging'),
1331+ 'order_line_ids': fields.one2many('sale.order.line', 'master_line_id', 'Detailed lines'),
1332+ 'discount': fields.float('Discount (%)', digits=(16, 2)),
1333+ 'tax_ids': fields.many2many('account.tax', 'sale_master_order_line_tax', 'order_line_id', 'tax_id', 'Taxes'),
1334+ }
1335+ _defaults = {
1336+ 'product_uom' : _get_uom_id,
1337+ 'product_uom_qty': 1,
1338+ 'product_uos_qty': 1,
1339+ 'product_packaging': False,
1340+ 'price_unit': 0.0,
1341+ }
1342+
1343+ def generate_detailed_lines(self, cr, uid, ids, context=None):
1344+ group_pool = self.pool.get('sale.order.line.group')
1345+ order_line_pool = self.pool.get('sale.order.line')
1346+ group_ids = group_pool.search(cr, uid, [])
1347+ for master_line in self.browse(cr, uid, ids):
1348+ if master_line.order_line_ids:
1349+ raise osv.except_osv(_('Error'),
1350+ _("Detailed lines generated yet (for master line '%s'). Remove them first") % master_line.name)
1351+ if len(master_line.delivery_term_id.line_ids) > len(group_ids):
1352+ raise osv.except_osv(_('Error'),
1353+ _("Delivery term lines are %s. Order line groups are %s. Please create more groups")
1354+ % (str(len(master_line.delivery_term_id.line_ids)), str(len(group_ids))))
1355+ if not master_line.delivery_term_id.is_total_percentage_correct():
1356+ raise osv.except_osv(_('Error'),
1357+ _("Total percentage of delivery term %s is not equal to 1") % master_line.delivery_term_id.name)
1358+ group_index = 0
1359+ for term_line in master_line.delivery_term_id.line_ids:
1360+ product_uom_qty = master_line.product_uom_qty * term_line.quantity_perc
1361+ product_uos_qty = master_line.product_uos_qty * term_line.quantity_perc
1362+ order_line_vals = {}
1363+ on_change_res = order_line_pool.product_id_change(cr, uid, ids, master_line.order_id.pricelist_id.id,
1364+ master_line.product_id.id, qty=product_uom_qty,
1365+ uom=master_line.product_uom.id, qty_uos=product_uos_qty, uos=master_line.product_uos.id, name=master_line.name, partner_id=master_line.order_id.partner_id.id,
1366+ lang=False, update_tax=True, date_order=master_line.order_id.date_order, packaging=master_line.product_packaging.id, fiscal_position=master_line.order_id.fiscal_position.id,
1367+ flag=False, context=context)
1368+ order_line_vals.update(on_change_res['value'])
1369+ order_line_vals.update({
1370+ 'order_id': master_line.order_id.id,
1371+ 'name': master_line.name,
1372+ 'price_unit': master_line.price_unit,
1373+ 'product_uom_qty': product_uom_qty,
1374+ 'product_uom': master_line.product_uom.id,
1375+ 'product_id': master_line.product_id and master_line.product_id.id or False,
1376+ 'product_uos_qty': product_uos_qty,
1377+ 'product_uos': master_line.product_uos and master_line.product_uos.id or False,
1378+ 'product_packaging': master_line.product_packaging.id,
1379+ 'master_line_id': master_line.id,
1380+ 'delay': term_line.delay,
1381+ 'picking_group_id': group_ids[group_index],
1382+ 'tax_id': [(6,0, [tax.id for tax in master_line.tax_ids])],
1383+ })
1384+ group_index += 1
1385+ order_line_pool.create(cr, uid, order_line_vals, context=context)
1386+ return True
1387+
1388+ def copy_data(self, cr, uid, id, default=None, context=None):
1389+ if not default:
1390+ default = {}
1391+ default.update({
1392+ 'order_line_ids': [],
1393+ })
1394+ return super(sale_order_line_master, self).copy_data(cr, uid, id, default, context=context)
1395+
1396+sale_order_line_master()
1397+
1398+class sale_order_line(osv.osv):
1399+ _inherit = 'sale.order.line'
1400+ _columns = {
1401+ 'master_line_id': fields.many2one('sale.order.line.master', 'Master Line'),
1402+ }
1403+
1404+ def copy_data(self, cr, uid, id, default=None, context=None):
1405+ if not default:
1406+ default = {}
1407+ default.update({'master_line_id': False})
1408+ return super(sale_order_line, self).copy_data(cr, uid, id, default, context=context)
1409+sale_order_line()
1410+
1411+class sale_order(osv.osv):
1412+ _inherit = 'sale.order'
1413+ _columns = {
1414+ 'master_order_line': fields.one2many('sale.order.line.master', 'order_id', 'Master Order Lines', readonly=True, states={'draft': [('readonly', False)]}),
1415+ }
1416+
1417+ def copy(self, cr, uid, id, default=None, context=None):
1418+ if not default:
1419+ default = {}
1420+ default.update({
1421+ 'order_line': [],
1422+ })
1423+ return super(sale_order, self).copy(cr, uid, id, default, context=context)
1424+sale_order()
1425
1426=== added file 'sale_delivery_term/sale_view.xml'
1427--- sale_delivery_term/sale_view.xml 1970-01-01 00:00:00 +0000
1428+++ sale_delivery_term/sale_view.xml 2012-06-14 14:09:20 +0000
1429@@ -0,0 +1,87 @@
1430+<openerp>
1431+ <data>
1432+ <record id="sale_delivery_term_form" model="ir.ui.view">
1433+ <field name="name">sale.delivery.term.form</field>
1434+ <field name="model">sale.delivery.term</field>
1435+ <field name="type">form</field>
1436+ <field name="arch" type="xml">
1437+ <form string="Delivery term">
1438+ <field name="name" select="1"/>
1439+ <field name="line_ids" string="Term Lines" colspan="4" nolabel="1">
1440+ <form>
1441+ <field name="quantity_perc"></field>
1442+ <field name="delay"></field>
1443+ </form>
1444+ <tree editable="bottom">
1445+ <field name="quantity_perc"></field>
1446+ <field name="delay"></field>
1447+ </tree>
1448+ </field>
1449+ </form>
1450+ </field>
1451+ </record>
1452+ <record id="action_delivery_term_form" model="ir.actions.act_window">
1453+ <field name="name">Delivery Terms</field>
1454+ <field name="type">ir.actions.act_window</field>
1455+ <field name="res_model">sale.delivery.term</field>
1456+ <field name="view_type">form</field>
1457+ <field name="view_mode">tree,form</field>
1458+ </record>
1459+
1460+ <menuitem action="action_delivery_term_form" id="menu_action_delivery_term_form" parent="base.menu_sale_config_sales" />
1461+
1462+ <record id="sale_order_line_master_form" model="ir.ui.view">
1463+ <field name="name">sale_order_line_master_form</field>
1464+ <field name="model">sale.order.line.master</field>
1465+ <field name="type">form</field>
1466+ <field name="arch" type="xml">
1467+ <form string="Master order line">
1468+ <field name="product_id"
1469+ on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, False, True, parent.date_order, product_packaging, parent.fiscal_position, False, context)"/>
1470+ <field name="name" />
1471+ <field name="product_uom_qty"
1472+ on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, False, False, parent.date_order, product_packaging, parent.fiscal_position, True, context)"/>
1473+ <field name="product_uom"
1474+ on_change="product_uom_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, False, False, parent.date_order, context)"/>
1475+ <field name="price_unit" />
1476+ <field name="discount"/>
1477+ <field name="product_uos_qty" />
1478+ <field name="product_uos" />
1479+ <field name="product_packaging" on_change="product_packaging_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, parent.partner_id, product_packaging, True, context)"/>
1480+ <field name="delivery_term_id" />
1481+ <separator colspan="4" string="Taxes"/>
1482+ <field colspan="4" name="tax_ids" nolabel="1" domain="[('parent_id','=',False),('type_tax_use','&lt;&gt;','purchase')]"/>
1483+ </form>
1484+ </field>
1485+ </record>
1486+ <record id="sale_order_line_master_tree" model="ir.ui.view">
1487+ <field name="name">sale_order_line_master_tree</field>
1488+ <field name="model">sale.order.line.master</field>
1489+ <field name="type">tree</field>
1490+ <field name="arch" type="xml">
1491+ <tree string="Master order lines">
1492+ <field name="name" />
1493+ <field name="price_unit" />
1494+ <field name="product_uom_qty" />
1495+ <field name="product_uom" />
1496+ <field name="discount"/>
1497+ <field name="price_subtotal" />
1498+ <field name="delivery_term_id" />
1499+ <button name="generate_detailed_lines" string="Generate detailed lines" icon="gtk-go-forward" type="object"/>
1500+ </tree>
1501+ </field>
1502+ </record>
1503+
1504+ <record id="view_order_form" model="ir.ui.view">
1505+ <field name="name">sale.order.form</field>
1506+ <field name="model">sale.order</field>
1507+ <field name="type">form</field>
1508+ <field name="inherit_id" ref="sale.view_order_form"></field>
1509+ <field name="arch" type="xml">
1510+ <field name="order_line" position="before">
1511+ <field colspan="4" name="master_order_line" nolabel="1" ></field>
1512+ </field>
1513+ </field>
1514+ </record>
1515+ </data>
1516+</openerp>
1517
1518=== added directory 'sale_delivery_term/security'
1519=== added file 'sale_delivery_term/security/ir.model.access.csv'
1520--- sale_delivery_term/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
1521+++ sale_delivery_term/security/ir.model.access.csv 2012-06-14 14:09:20 +0000
1522@@ -0,0 +1,10 @@
1523+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
1524+access_sale_order_line_master,sale_order_line_master,model_sale_order_line_master,base.group_sale_salesman,1,1,1,1
1525+access_sale_order_line_master_accountant,sale_order_line_master accountant,model_sale_order_line_master,account.group_account_user,1,1,0,0
1526+access_sale_order_line_master_stock_worker,sale_order_line_master stock worker,model_sale_order_line_master,stock.group_stock_user,1,1,0,0
1527+access_sale_delivery_term_sale_user,sale_delivery_term.sale.user,model_sale_delivery_term,base.group_sale_salesman,1,0,0,0
1528+access_sale_delivery_term_sale_manager,sale_delivery_term.sale.manager,model_sale_delivery_term,base.group_sale_manager,1,1,1,1
1529+access_sale_delivery_term,sale_delivery_term,model_sale_delivery_term,base.group_user,1,0,0,0
1530+access_sale_delivery_term_line_sale_user,sale_delivery_term_line.sale.user,model_sale_delivery_term_line,base.group_sale_salesman,1,0,0,0
1531+access_sale_delivery_term_line_sale_manager,sale_delivery_term_line.sale.manager,model_sale_delivery_term_line,base.group_sale_manager,1,1,1,1
1532+access_sale_delivery_term_line_sale_manager,sale_delivery_term_line.sale.manager,model_sale_delivery_term_line,base.group_user,1,0,0,0
1533
1534=== added directory 'sale_delivery_term_variant_selection'
1535=== added file 'sale_delivery_term_variant_selection/AUTHORS.txt'
1536--- sale_delivery_term_variant_selection/AUTHORS.txt 1970-01-01 00:00:00 +0000
1537+++ sale_delivery_term_variant_selection/AUTHORS.txt 2012-06-14 14:09:20 +0000
1538@@ -0,0 +1,1 @@
1539+Lorenzo Battistini <lorenzo.battistini@agilebg.com>
1540
1541=== added file 'sale_delivery_term_variant_selection/__init__.py'
1542--- sale_delivery_term_variant_selection/__init__.py 1970-01-01 00:00:00 +0000
1543+++ sale_delivery_term_variant_selection/__init__.py 2012-06-14 14:09:20 +0000
1544@@ -0,0 +1,22 @@
1545+# -*- coding: utf-8 -*-
1546+##############################################################################
1547+#
1548+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
1549+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
1550+# All Rights Reserved
1551+#
1552+# This program is free software: you can redistribute it and/or modify
1553+# it under the terms of the GNU Affero General Public License as published
1554+# by the Free Software Foundation, either version 3 of the License, or
1555+# (at your option) any later version.
1556+#
1557+# This program is distributed in the hope that it will be useful,
1558+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1559+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1560+# GNU General Public License for more details.
1561+#
1562+# You should have received a copy of the GNU Affero General Public License
1563+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1564+#
1565+##############################################################################
1566+import sale
1567
1568=== added file 'sale_delivery_term_variant_selection/__openerp__.py'
1569--- sale_delivery_term_variant_selection/__openerp__.py 1970-01-01 00:00:00 +0000
1570+++ sale_delivery_term_variant_selection/__openerp__.py 2012-06-14 14:09:20 +0000
1571@@ -0,0 +1,40 @@
1572+# -*- coding: utf-8 -*-
1573+##############################################################################
1574+#
1575+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
1576+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
1577+# All Rights Reserved
1578+#
1579+# This program is free software: you can redistribute it and/or modify
1580+# it under the terms of the GNU Affero General Public License as published
1581+# by the Free Software Foundation, either version 3 of the License, or
1582+# (at your option) any later version.
1583+#
1584+# This program is distributed in the hope that it will be useful,
1585+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1586+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1587+# GNU General Public License for more details.
1588+#
1589+# You should have received a copy of the GNU Affero General Public License
1590+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1591+#
1592+##############################################################################
1593+{
1594+ 'name': "Sale delivery term with variant selection",
1595+ 'version': '0.1',
1596+ 'category': 'Sales Management',
1597+ 'description': """
1598+Product Variants Selection for Sale Orders with delivery terms - See 'product_variant_selection' and 'sale_delivery_term' modules
1599+""",
1600+ 'author': 'Agile Business Group & Domsense',
1601+ 'website': 'http://www.agilebg.com',
1602+ 'license': 'AGPL-3',
1603+ "depends" : ['sale_product_variant_selection', 'sale_delivery_term'],
1604+ "init_xml" : [],
1605+ "update_xml" : [
1606+ 'sale_view.xml',
1607+ ],
1608+ "demo_xml" : [],
1609+ "active": False,
1610+ "installable": True
1611+}
1612
1613=== added directory 'sale_delivery_term_variant_selection/i18n'
1614=== added file 'sale_delivery_term_variant_selection/sale.py'
1615--- sale_delivery_term_variant_selection/sale.py 1970-01-01 00:00:00 +0000
1616+++ sale_delivery_term_variant_selection/sale.py 2012-06-14 14:09:20 +0000
1617@@ -0,0 +1,65 @@
1618+# -*- coding: utf-8 -*-
1619+##############################################################################
1620+#
1621+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
1622+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
1623+# All Rights Reserved
1624+#
1625+# This program is free software: you can redistribute it and/or modify
1626+# it under the terms of the GNU Affero General Public License as published
1627+# by the Free Software Foundation, either version 3 of the License, or
1628+# (at your option) any later version.
1629+#
1630+# This program is distributed in the hope that it will be useful,
1631+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1632+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1633+# GNU General Public License for more details.
1634+#
1635+# You should have received a copy of the GNU Affero General Public License
1636+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1637+#
1638+##############################################################################
1639+
1640+from osv import fields,osv
1641+
1642+class sale_order_line_master(osv.osv):
1643+
1644+ _inherit = "sale.order.line.master"
1645+ _columns = {
1646+ "product_tmpl_id": fields.many2one('product.template', "Product Template"),
1647+ 'variant_line_ids': fields.one2many('product.select.variant.line', 'master_so_line_id', 'Variants'),
1648+ }
1649+
1650+ def pre_selection_changed(self, cr, uid, ids, product_tmpl_id, variant_line_ids):
1651+ prod_ids = self.pool.get('account.invoice.line').search_products(
1652+ cr, uid, product_tmpl_id, variant_line_ids=variant_line_ids)
1653+ res = {'domain': {'product_id': [('id', 'in', prod_ids)]}}
1654+ if len(prod_ids) == 1:
1655+ res['value'] = {'product_id': prod_ids[0]}
1656+ return res
1657+
1658+ def generate_detailed_lines(self, cr, uid, ids, context=None):
1659+ res = super(sale_order_line_master, self).generate_detailed_lines(
1660+ cr, uid, ids, context=context)
1661+ var_line_pool = self.pool.get('product.select.variant.line')
1662+ for master_line in self.browse(cr, uid, ids, context=context):
1663+ for order_line in master_line.order_line_ids:
1664+ if master_line.product_tmpl_id:
1665+ order_line.write({'product_tmpl_id': master_line.product_tmpl_id.id})
1666+ for variant_line in master_line.variant_line_ids:
1667+ var_line_pool.create(cr, uid, {
1668+ 'dimension_id': variant_line.dimension_id.id,
1669+ 'option_id': variant_line.option_id.id,
1670+ 'so_line_id': order_line.id,
1671+ }, context=context)
1672+ return res
1673+
1674+sale_order_line_master()
1675+
1676+class product_select_variant_line(osv.osv):
1677+
1678+ _inherit = "product.select.variant.line"
1679+ _columns = {
1680+ 'master_so_line_id': fields.many2one('sale.order.line.master', 'Master SO line'),
1681+ }
1682+product_select_variant_line()
1683
1684=== added file 'sale_delivery_term_variant_selection/sale_view.xml'
1685--- sale_delivery_term_variant_selection/sale_view.xml 1970-01-01 00:00:00 +0000
1686+++ sale_delivery_term_variant_selection/sale_view.xml 2012-06-14 14:09:20 +0000
1687@@ -0,0 +1,27 @@
1688+<?xml version="1.0" encoding="utf-8"?>
1689+<openerp>
1690+ <data>
1691+ <record id="view_sale_order_line_master_form" model="ir.ui.view">
1692+ <field name="name">sale.order.line.master.form</field>
1693+ <field name="model">sale.order.line.master</field>
1694+ <field name="type">form</field>
1695+ <field name="inherit_id" ref="sale_delivery_term.sale_order_line_master_form"></field>
1696+ <field name="arch" type="xml">
1697+ <field name="product_id" position="before">
1698+ <field name="product_tmpl_id" on_change="pre_selection_changed(product_tmpl_id, variant_line_ids)"/>
1699+ <newline/>
1700+ <field name="variant_line_ids" on_change="pre_selection_changed(product_tmpl_id, variant_line_ids)" nolabel="1" colspan="5" attrs="{'readonly': [('product_tmpl_id', '=', False)]}">
1701+ <tree string="Variants" editable="bottom">
1702+ <field name="dimension_id"></field>
1703+ <field name="option_id" domain="[('dimension_id', '=', dimension_id)]"></field>
1704+ </tree>
1705+ <form string="Variants" >
1706+ <field name="dimension_id"></field>
1707+ <field name="option_id" domain="[('dimension_id', '=', dimension_id)]"></field>
1708+ </form>
1709+ </field>
1710+ </field>
1711+ </field>
1712+ </record>
1713+ </data>
1714+</openerp>
1715
1716=== added directory 'sale_delivery_term_variant_selection/security'
1717=== added directory 'sale_multi_picking'
1718=== added file 'sale_multi_picking/AUTHORS.txt'
1719--- sale_multi_picking/AUTHORS.txt 1970-01-01 00:00:00 +0000
1720+++ sale_multi_picking/AUTHORS.txt 2012-06-14 14:09:20 +0000
1721@@ -0,0 +1,1 @@
1722+Lorenzo Battistini <lorenzo.battistini@agilebg.com>
1723
1724=== added file 'sale_multi_picking/__init__.py'
1725--- sale_multi_picking/__init__.py 1970-01-01 00:00:00 +0000
1726+++ sale_multi_picking/__init__.py 2012-06-14 14:09:20 +0000
1727@@ -0,0 +1,22 @@
1728+# -*- coding: utf-8 -*-
1729+##############################################################################
1730+#
1731+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
1732+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
1733+# All Rights Reserved
1734+#
1735+# This program is free software: you can redistribute it and/or modify
1736+# it under the terms of the GNU Affero General Public License as published
1737+# by the Free Software Foundation, either version 3 of the License, or
1738+# (at your option) any later version.
1739+#
1740+# This program is distributed in the hope that it will be useful,
1741+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1742+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1743+# GNU General Public License for more details.
1744+#
1745+# You should have received a copy of the GNU Affero General Public License
1746+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1747+#
1748+##############################################################################
1749+import sale
1750
1751=== added file 'sale_multi_picking/__openerp__.py'
1752--- sale_multi_picking/__openerp__.py 1970-01-01 00:00:00 +0000
1753+++ sale_multi_picking/__openerp__.py 2012-06-14 14:09:20 +0000
1754@@ -0,0 +1,42 @@
1755+# -*- coding: utf-8 -*-
1756+##############################################################################
1757+#
1758+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
1759+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
1760+# All Rights Reserved
1761+#
1762+# This program is free software: you can redistribute it and/or modify
1763+# it under the terms of the GNU Affero General Public License as published
1764+# by the Free Software Foundation, either version 3 of the License, or
1765+# (at your option) any later version.
1766+#
1767+# This program is distributed in the hope that it will be useful,
1768+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1769+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1770+# GNU General Public License for more details.
1771+#
1772+# You should have received a copy of the GNU Affero General Public License
1773+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1774+#
1775+##############################################################################
1776+{
1777+ 'name': "Multi Pickings from Sale Orders",
1778+ 'version': '0.1',
1779+ 'category': 'Sales Management',
1780+ 'description': """
1781+This module allows to generate several pickings from the same sale order.
1782+You just have to indicate which order lines have to be grouped in the same picking. When confirming the order, for each group a picking is generated.
1783+""",
1784+ 'author': 'Agile Business Group & Domsense',
1785+ 'website': 'http://www.agilebg.com',
1786+ 'license': 'AGPL-3',
1787+ "depends" : ['sale'],
1788+ "init_xml" : [],
1789+ "update_xml" : [
1790+ 'sale_view.xml',
1791+ 'security/ir.model.access.csv',
1792+ ],
1793+ "demo_xml" : [],
1794+ "active": False,
1795+ "installable": True
1796+}
1797
1798=== added directory 'sale_multi_picking/i18n'
1799=== added file 'sale_multi_picking/sale.py'
1800--- sale_multi_picking/sale.py 1970-01-01 00:00:00 +0000
1801+++ sale_multi_picking/sale.py 2012-06-14 14:09:20 +0000
1802@@ -0,0 +1,70 @@
1803+# -*- coding: utf-8 -*-
1804+##############################################################################
1805+#
1806+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
1807+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
1808+# All Rights Reserved
1809+#
1810+# This program is free software: you can redistribute it and/or modify
1811+# it under the terms of the GNU Affero General Public License as published
1812+# by the Free Software Foundation, either version 3 of the License, or
1813+# (at your option) any later version.
1814+#
1815+# This program is distributed in the hope that it will be useful,
1816+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1817+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1818+# GNU General Public License for more details.
1819+#
1820+# You should have received a copy of the GNU Affero General Public License
1821+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1822+#
1823+##############################################################################
1824+
1825+from osv import fields, osv
1826+
1827+class sale_order_line_group(osv.osv):
1828+ _name = 'sale.order.line.group'
1829+ _columns = {
1830+ 'name': fields.char('Group', size=64, required=True),
1831+ 'company_id': fields.many2one('res.company','Company',required=True,select=1),
1832+ }
1833+ _defaults = {
1834+ 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'sale.order.line.group', context=c),
1835+ }
1836+sale_order_line_group()
1837+
1838+class sale_order_line(osv.osv):
1839+ _inherit = 'sale.order.line'
1840+ _columns = {
1841+ 'picking_group_id': fields.many2one('sale.order.line.group', 'Group'),
1842+ }
1843+sale_order_line()
1844+
1845+class sale_order(osv.osv):
1846+ _inherit = 'sale.order'
1847+
1848+ def action_ship_create(self, cr, uid, ids, context=None):
1849+ picking_pool = self.pool.get('stock.picking')
1850+ for order in self.browse(cr, uid, ids, context=context):
1851+ lines_by_group = {}
1852+ for line in order.order_line:
1853+ if line.picking_group_id:
1854+ if not lines_by_group.get(line.picking_group_id.id, False):
1855+ lines_by_group[line.picking_group_id.id] = []
1856+ lines_by_group[line.picking_group_id.id].append(line)
1857+ else:
1858+ if not lines_by_group.get(0, False):
1859+ lines_by_group[0] = []
1860+ lines_by_group[0].append(line)
1861+ for group in lines_by_group:
1862+ if not group:
1863+ super(sale_order, self)._create_pickings_and_procurements(
1864+ cr, uid, order, lines_by_group[group], None, context=context)
1865+ else:
1866+ picking_vals = super(sale_order, self)._prepare_order_picking(cr, uid, order, context=context)
1867+ picking_id = picking_pool.create(cr, uid, picking_vals, context=context)
1868+ super(sale_order, self)._create_pickings_and_procurements(
1869+ cr, uid, order, lines_by_group[group], picking_id, context=context)
1870+ return True
1871+
1872+sale_order()
1873
1874=== added file 'sale_multi_picking/sale_view.xml'
1875--- sale_multi_picking/sale_view.xml 1970-01-01 00:00:00 +0000
1876+++ sale_multi_picking/sale_view.xml 2012-06-14 14:09:20 +0000
1877@@ -0,0 +1,24 @@
1878+<openerp>
1879+ <data>
1880+ <record id="view_order_form" model="ir.ui.view">
1881+ <field name="name">sale.order.form</field>
1882+ <field name="model">sale.order</field>
1883+ <field name="type">form</field>
1884+ <field name="inherit_id" ref="sale.view_order_form"></field>
1885+ <field name="arch" type="xml">
1886+ <field name="address_allotment_id" position="after">
1887+ <field name="picking_group_id"/>
1888+ </field>
1889+ </field>
1890+ </record>
1891+ <record id="action_sale_order_line_group_form" model="ir.actions.act_window">
1892+ <field name="name">Sale order line Groups</field>
1893+ <field name="type">ir.actions.act_window</field>
1894+ <field name="res_model">sale.order.line.group</field>
1895+ <field name="view_type">form</field>
1896+ <field name="view_mode">tree,form</field>
1897+ </record>
1898+
1899+ <menuitem action="action_sale_order_line_group_form" id="menu_action_sale_order_line_group_form" parent="base.menu_sale_config_sales" />
1900+ </data>
1901+</openerp>
1902
1903=== added directory 'sale_multi_picking/security'
1904=== added file 'sale_multi_picking/security/ir.model.access.csv'
1905--- sale_multi_picking/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
1906+++ sale_multi_picking/security/ir.model.access.csv 2012-06-14 14:09:20 +0000
1907@@ -0,0 +1,4 @@
1908+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
1909+access_sale_order_line_group,sale.order.line.group,model_sale_order_line_group,base.group_sale_salesman,1,1,1,1
1910+access_sale_order_line_group_accountant,sale.order.line.group accountant,model_sale_order_line_group,account.group_account_user,1,1,0,0
1911+access_sale_order_line_group_stock_worker,sale.order.line.group stock worker,model_sale_order_line_group,stock.group_stock_user,1,1,0,0
1912
1913=== added directory 'sale_product_variant_selection'
1914=== added file 'sale_product_variant_selection/AUTHORS.txt'
1915--- sale_product_variant_selection/AUTHORS.txt 1970-01-01 00:00:00 +0000
1916+++ sale_product_variant_selection/AUTHORS.txt 2012-06-14 14:09:20 +0000
1917@@ -0,0 +1,1 @@
1918+Lorenzo Battistini <lorenzo.battistini@agilebg.com>
1919
1920=== added file 'sale_product_variant_selection/__init__.py'
1921--- sale_product_variant_selection/__init__.py 1970-01-01 00:00:00 +0000
1922+++ sale_product_variant_selection/__init__.py 2012-06-14 14:09:20 +0000
1923@@ -0,0 +1,22 @@
1924+# -*- coding: utf-8 -*-
1925+##############################################################################
1926+#
1927+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
1928+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
1929+# All Rights Reserved
1930+#
1931+# This program is free software: you can redistribute it and/or modify
1932+# it under the terms of the GNU Affero General Public License as published
1933+# by the Free Software Foundation, either version 3 of the License, or
1934+# (at your option) any later version.
1935+#
1936+# This program is distributed in the hope that it will be useful,
1937+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1938+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1939+# GNU General Public License for more details.
1940+#
1941+# You should have received a copy of the GNU Affero General Public License
1942+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1943+#
1944+##############################################################################
1945+import order_line
1946
1947=== added file 'sale_product_variant_selection/__openerp__.py'
1948--- sale_product_variant_selection/__openerp__.py 1970-01-01 00:00:00 +0000
1949+++ sale_product_variant_selection/__openerp__.py 2012-06-14 14:09:20 +0000
1950@@ -0,0 +1,40 @@
1951+# -*- coding: utf-8 -*-
1952+##############################################################################
1953+#
1954+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
1955+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
1956+# All Rights Reserved
1957+#
1958+# This program is free software: you can redistribute it and/or modify
1959+# it under the terms of the GNU Affero General Public License as published
1960+# by the Free Software Foundation, either version 3 of the License, or
1961+# (at your option) any later version.
1962+#
1963+# This program is distributed in the hope that it will be useful,
1964+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1965+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1966+# GNU General Public License for more details.
1967+#
1968+# You should have received a copy of the GNU Affero General Public License
1969+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1970+#
1971+##############################################################################
1972+{
1973+ 'name': "Product Variants Selection for Sale Orders",
1974+ 'version': '0.1',
1975+ 'category': 'Sales Management',
1976+ 'description': """
1977+Product Variants Selection for Sale Orders - See 'product_variant_selection' module
1978+""",
1979+ 'author': 'Agile Business Group & Domsense',
1980+ 'website': 'http://www.agilebg.com',
1981+ 'license': 'AGPL-3',
1982+ "depends" : ['product_variant_selection', 'sale'],
1983+ "init_xml" : [],
1984+ "update_xml" : [
1985+ 'sale_order_line_view.xml',
1986+ ],
1987+ "demo_xml" : [],
1988+ "active": False,
1989+ "installable": True
1990+}
1991
1992=== added directory 'sale_product_variant_selection/i18n'
1993=== added file 'sale_product_variant_selection/order_line.py'
1994--- sale_product_variant_selection/order_line.py 1970-01-01 00:00:00 +0000
1995+++ sale_product_variant_selection/order_line.py 2012-06-14 14:09:20 +0000
1996@@ -0,0 +1,49 @@
1997+# -*- coding: utf-8 -*-
1998+##############################################################################
1999+#
2000+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
2001+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
2002+# All Rights Reserved
2003+#
2004+# This program is free software: you can redistribute it and/or modify
2005+# it under the terms of the GNU Affero General Public License as published
2006+# by the Free Software Foundation, either version 3 of the License, or
2007+# (at your option) any later version.
2008+#
2009+# This program is distributed in the hope that it will be useful,
2010+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2011+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2012+# GNU General Public License for more details.
2013+#
2014+# You should have received a copy of the GNU Affero General Public License
2015+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2016+#
2017+##############################################################################
2018+
2019+from osv import fields,osv
2020+
2021+class sale_order_line(osv.osv):
2022+
2023+ _inherit = "sale.order.line"
2024+ _columns = {
2025+ "product_tmpl_id": fields.many2one('product.template', "Product Template"),
2026+ 'variant_line_ids': fields.one2many('product.select.variant.line', 'so_line_id', 'Variants'),
2027+ }
2028+
2029+ def pre_selection_changed(self, cr, uid, ids, product_tmpl_id, variant_line_ids):
2030+ prod_ids = self.pool.get('account.invoice.line').search_products(
2031+ cr, uid, product_tmpl_id, variant_line_ids=variant_line_ids)
2032+ res = {'domain': {'product_id': [('id', 'in', prod_ids)]}}
2033+ if len(prod_ids) == 1:
2034+ res['value'] = {'product_id': prod_ids[0]}
2035+ return res
2036+
2037+sale_order_line()
2038+
2039+class product_select_variant_line(osv.osv):
2040+
2041+ _inherit = "product.select.variant.line"
2042+ _columns = {
2043+ 'so_line_id': fields.many2one('sale.order.line', 'SO line'),
2044+ }
2045+product_select_variant_line()
2046
2047=== added file 'sale_product_variant_selection/sale_order_line_view.xml'
2048--- sale_product_variant_selection/sale_order_line_view.xml 1970-01-01 00:00:00 +0000
2049+++ sale_product_variant_selection/sale_order_line_view.xml 2012-06-14 14:09:20 +0000
2050@@ -0,0 +1,27 @@
2051+<?xml version="1.0" encoding="utf-8"?>
2052+<openerp>
2053+ <data>
2054+ <record id="view_order_form" model="ir.ui.view">
2055+ <field name="name">sale.order.form</field>
2056+ <field name="model">sale.order</field>
2057+ <field name="type">form</field>
2058+ <field name="inherit_id" ref="sale.view_order_form"></field>
2059+ <field name="arch" type="xml">
2060+ <field name="product_id" position="before">
2061+ <field name="product_tmpl_id" on_change="pre_selection_changed(product_tmpl_id, variant_line_ids)"/>
2062+ <newline/>
2063+ <field name="variant_line_ids" on_change="pre_selection_changed(product_tmpl_id, variant_line_ids)" nolabel="1" colspan="5" attrs="{'readonly': [('product_tmpl_id', '=', False)]}">
2064+ <tree string="Variants" editable="bottom">
2065+ <field name="dimension_id"></field>
2066+ <field name="option_id" domain="[('dimension_id', '=', dimension_id)]"></field>
2067+ </tree>
2068+ <form string="Variants" >
2069+ <field name="dimension_id"></field>
2070+ <field name="option_id" domain="[('dimension_id', '=', dimension_id)]"></field>
2071+ </form>
2072+ </field>
2073+ </field>
2074+ </field>
2075+ </record>
2076+ </data>
2077+</openerp>
2078
2079=== added directory 'sale_product_variant_selection/security'
2080=== added directory 'sale_purchase_orders_super_list'
2081=== added file 'sale_purchase_orders_super_list/AUTHORS.txt'
2082--- sale_purchase_orders_super_list/AUTHORS.txt 1970-01-01 00:00:00 +0000
2083+++ sale_purchase_orders_super_list/AUTHORS.txt 2012-06-14 14:09:20 +0000
2084@@ -0,0 +1,1 @@
2085+Lorenzo Battistini <lorenzo.battistini@agilebg.com>
2086
2087=== added file 'sale_purchase_orders_super_list/__init__.py'
2088--- sale_purchase_orders_super_list/__init__.py 1970-01-01 00:00:00 +0000
2089+++ sale_purchase_orders_super_list/__init__.py 2012-06-14 14:09:20 +0000
2090@@ -0,0 +1,22 @@
2091+# -*- coding: utf-8 -*-
2092+##############################################################################
2093+#
2094+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
2095+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
2096+# All Rights Reserved
2097+#
2098+# This program is free software: you can redistribute it and/or modify
2099+# it under the terms of the GNU Affero General Public License as published
2100+# by the Free Software Foundation, either version 3 of the License, or
2101+# (at your option) any later version.
2102+#
2103+# This program is distributed in the hope that it will be useful,
2104+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2105+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2106+# GNU General Public License for more details.
2107+#
2108+# You should have received a copy of the GNU Affero General Public License
2109+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2110+#
2111+##############################################################################
2112+import orders
2113
2114=== added file 'sale_purchase_orders_super_list/__openerp__.py'
2115--- sale_purchase_orders_super_list/__openerp__.py 1970-01-01 00:00:00 +0000
2116+++ sale_purchase_orders_super_list/__openerp__.py 2012-06-14 14:09:20 +0000
2117@@ -0,0 +1,39 @@
2118+# -*- coding: utf-8 -*-
2119+##############################################################################
2120+#
2121+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
2122+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
2123+# All Rights Reserved
2124+#
2125+# This program is free software: you can redistribute it and/or modify
2126+# it under the terms of the GNU Affero General Public License as published
2127+# by the Free Software Foundation, either version 3 of the License, or
2128+# (at your option) any later version.
2129+#
2130+# This program is distributed in the hope that it will be useful,
2131+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2132+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2133+# GNU General Public License for more details.
2134+#
2135+# You should have received a copy of the GNU Affero General Public License
2136+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2137+#
2138+##############################################################################
2139+{
2140+ 'name': "Super order list",
2141+ 'version': '0.1',
2142+ 'category': 'Sales Management',
2143+ 'description': """A unified list view for sale and purchase orders""",
2144+ 'author': 'Agile Business Group & Domsense',
2145+ 'website': 'http://www.agilebg.com',
2146+ 'license': 'AGPL-3',
2147+ "depends" : ['sale', 'purchase'],
2148+ "init_xml" : [],
2149+ "update_xml" : [
2150+ 'orders_view.xml',
2151+ 'security/ir.model.access.csv',
2152+ ],
2153+ "demo_xml" : [],
2154+ "active": False,
2155+ "installable": True
2156+}
2157
2158=== added directory 'sale_purchase_orders_super_list/i18n'
2159=== added file 'sale_purchase_orders_super_list/orders.py'
2160--- sale_purchase_orders_super_list/orders.py 1970-01-01 00:00:00 +0000
2161+++ sale_purchase_orders_super_list/orders.py 2012-06-14 14:09:20 +0000
2162@@ -0,0 +1,157 @@
2163+# -*- coding: utf-8 -*-
2164+##############################################################################
2165+#
2166+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
2167+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
2168+# All Rights Reserved
2169+#
2170+# This program is free software: you can redistribute it and/or modify
2171+# it under the terms of the GNU Affero General Public License as published
2172+# by the Free Software Foundation, either version 3 of the License, or
2173+# (at your option) any later version.
2174+#
2175+# This program is distributed in the hope that it will be useful,
2176+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2177+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2178+# GNU General Public License for more details.
2179+#
2180+# You should have received a copy of the GNU Affero General Public License
2181+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2182+#
2183+##############################################################################
2184+
2185+from osv import fields, osv
2186+
2187+class super_order(osv.osv):
2188+
2189+ def _get_fields_values(self, cr, uid, ids, field_name, arg, context=None):
2190+ res = {}
2191+ sale_pool = self.pool.get('sale.order')
2192+ purchase_pool = self.pool.get('purchase.order')
2193+ for super_order in self.browse(cr, uid, ids, context=context):
2194+ res[super_order.id] = {}
2195+ res[super_order.id]['company_id'] = eval(
2196+ 'super_order.'+super_order.type+'_order_id.company_id.id')
2197+ res[super_order.id]['name'] = eval(
2198+ 'super_order.'+super_order.type+'_order_id.name')
2199+ res[super_order.id]['date'] = eval(
2200+ 'super_order.'+super_order.type+'_order_id.date_order')
2201+ res[super_order.id]['partner_id'] = eval(
2202+ 'super_order.'+super_order.type+'_order_id.partner_id.id')
2203+ res[super_order.id]['invoiced_rate'] = eval(
2204+ 'super_order.'+super_order.type+'_order_id.invoiced_rate')
2205+ res[super_order.id]['amount_untaxed'] = eval(
2206+ 'super_order.'+super_order.type+'_order_id.amount_untaxed')
2207+ res[super_order.id]['amount_total'] = eval(
2208+ 'super_order.'+super_order.type+'_order_id.amount_total')
2209+ state = eval(
2210+ 'super_order.'+super_order.type+'_order_id.state')
2211+ res[super_order.id]['state'] = dict(eval(super_order.type+'_pool').fields_get(cr, uid, allfields=['state'], context=context)['state']['selection'])[state]
2212+ res[super_order.id]['state_key'] = state
2213+ if super_order.type == 'sale':
2214+ res[super_order.id]['delivered_rate'] = super_order.sale_order_id.picked_rate
2215+ elif super_order.type == 'purchase':
2216+ res[super_order.id]['delivered_rate'] = super_order.purchase_order_id.shipped_rate
2217+ return res
2218+
2219+ def _get_super_order_by_sale(self, cr, uid, ids, context=None):
2220+ result = []
2221+ order_pool = self.pool.get('sale.order')
2222+ super_order_pool= self.pool.get('super.order')
2223+ for order in order_pool.browse(cr, uid, ids, context=context):
2224+ super_order_ids = super_order_pool.search(cr, uid, [
2225+ ('sale_order_id', '=', order.id),
2226+ ], context=context)
2227+ for super_order_id in super_order_ids:
2228+ if super_order_id not in result:
2229+ result.append(super_order_id)
2230+ return result
2231+
2232+ def _get_super_order_by_purchase(self, cr, uid, ids, context=None):
2233+ result = []
2234+ order_pool= self.pool.get('purchase.order')
2235+ super_order_pool= self.pool.get('super.order')
2236+ for order in order_pool.browse(cr, uid, ids, context=context):
2237+ super_order_ids = super_order_pool.search(cr, uid, [
2238+ ('purchase_order_id', '=', order.id),
2239+ ], context=context)
2240+ for super_order_id in super_order_ids:
2241+ if super_order_id not in result:
2242+ result.append(super_order_id)
2243+ return result
2244+
2245+ _name = 'super.order'
2246+ _rec_name = 'type'
2247+ _columns = {
2248+ 'type': fields.selection([
2249+ ('sale', 'Sale'),
2250+ ('purchase', 'Purchase'),
2251+ ], 'Type', required=True, readonly=True),
2252+ 'sale_order_id': fields.many2one('sale.order', 'Sale Order', readonly=True, ondelete='cascade'),
2253+ 'purchase_order_id': fields.many2one('purchase.order', 'Purchase Order', readonly=True, ondelete='cascade'),
2254+ 'company_id': fields.function(_get_fields_values, string="Company", type="many2one", relation="res.company", multi="super",
2255+ store = {
2256+ 'super.order': (lambda self, cr, uid, ids, c={}: ids, None, 10),
2257+ 'sale.order': (_get_super_order_by_sale, ['company_id'], 10),
2258+ 'purchase.order': (_get_super_order_by_purchase, ['company_id'], 10),
2259+ }),
2260+ 'name': fields.function(_get_fields_values, string="Reference", type="char", size=64, multi="super",
2261+ store = {
2262+ 'super.order': (lambda self, cr, uid, ids, c={}: ids, None, 10),
2263+ 'sale.order': (_get_super_order_by_sale, ['name'], 10),
2264+ 'purchase.order': (_get_super_order_by_purchase, ['name'], 10),
2265+ }),
2266+ 'date': fields.function(_get_fields_values, string="Date", type="date", multi="super",
2267+ store = {
2268+ 'super.order': (lambda self, cr, uid, ids, c={}: ids, None, 10),
2269+ 'sale.order': (_get_super_order_by_sale, ['date_order'], 10),
2270+ 'purchase.order': (_get_super_order_by_purchase, ['date_order'], 10),
2271+ }),
2272+ 'partner_id': fields.function(_get_fields_values, string="Partner", type="many2one", relation="res.partner", multi="super",
2273+ store = {
2274+ 'super.order': (lambda self, cr, uid, ids, c={}: ids, None, 10),
2275+ 'sale.order': (_get_super_order_by_sale, ['partner_id'], 10),
2276+ 'purchase.order': (_get_super_order_by_purchase, ['partner_id'], 10),
2277+ }),
2278+ 'delivered_rate': fields.function(_get_fields_values, string="Delivered", type="float", multi="super"),
2279+ 'invoiced_rate': fields.function(_get_fields_values, string="Invoiced", type="float", multi="super"),
2280+ 'amount_untaxed': fields.function(_get_fields_values, string="Untaxed Amount", type="float", multi="super",
2281+ store = {
2282+ 'super.order': (lambda self, cr, uid, ids, c={}: ids, None, 10),
2283+ 'sale.order': (_get_super_order_by_sale, ['amount_untaxed'], 10),
2284+ 'purchase.order': (_get_super_order_by_purchase, ['amount_untaxed'], 10),
2285+ }),
2286+ 'amount_total': fields.function(_get_fields_values, string="Total", type="float", multi="super",
2287+ store = {
2288+ 'super.order': (lambda self, cr, uid, ids, c={}: ids, None, 10),
2289+ 'sale.order': (_get_super_order_by_sale, ['amount_total'], 10),
2290+ 'purchase.order': (_get_super_order_by_purchase, ['amount_total'], 10),
2291+ }),
2292+ 'state': fields.function(_get_fields_values, string="State", type="char", size=64, multi="super"),
2293+ 'state_key': fields.function(_get_fields_values, string="State", type="char", size=64, multi="super",
2294+ store = {
2295+ 'super.order': (lambda self, cr, uid, ids, c={}: ids, None, 10),
2296+ 'sale.order': (_get_super_order_by_sale, ['state'], 10),
2297+ 'purchase.order': (_get_super_order_by_purchase, ['state'], 10),
2298+ }),
2299+ }
2300+
2301+class sale_order(osv.osv):
2302+ _inherit = 'sale.order'
2303+ def create(self, cr, uid, vals, context=None):
2304+ res = super(sale_order, self).create(cr, uid, vals, context=context)
2305+ self.pool.get('super.order').create(cr, uid, {
2306+ 'type': 'sale',
2307+ 'sale_order_id': res,
2308+ }, context=context)
2309+ return res
2310+
2311+class purchase_order(osv.osv):
2312+ _inherit = 'purchase.order'
2313+ def create(self, cr, uid, vals, context=None):
2314+ res = super(purchase_order, self).create(cr, uid, vals, context=context)
2315+ self.pool.get('super.order').create(cr, uid, {
2316+ 'type': 'purchase',
2317+ 'purchase_order_id': res,
2318+ }, context=context)
2319+ return res
2320
2321=== added file 'sale_purchase_orders_super_list/orders_view.xml'
2322--- sale_purchase_orders_super_list/orders_view.xml 1970-01-01 00:00:00 +0000
2323+++ sale_purchase_orders_super_list/orders_view.xml 2012-06-14 14:09:20 +0000
2324@@ -0,0 +1,81 @@
2325+<openerp>
2326+ <data>
2327+ <record id="super_order_tree" model="ir.ui.view">
2328+ <field name="name">super_order_tree</field>
2329+ <field name="model">super.order</field>
2330+ <field name="type">tree</field>
2331+ <field name="arch" type="xml">
2332+ <tree string="Orders">
2333+ <field name="type"/>
2334+ <field name="name"/>
2335+ <field name="date"/>
2336+ <field name="partner_id"/>
2337+ <field name="delivered_rate" widget="progressbar"/>
2338+ <field name="invoiced_rate" widget="progressbar"/>
2339+ <field name="amount_untaxed" sum="Total Tax Excluded"/>
2340+ <field name="amount_total" sum="Total Tax Included"/>
2341+ <field name="state"/>
2342+ <field name="state_key" invisible="1"/>
2343+ <field name="company_id" groups="base.group_multi_company" />
2344+ </tree>
2345+ </field>
2346+ </record>
2347+ <record id="super_order_form" model="ir.ui.view">
2348+ <field name="name">super_order_form</field>
2349+ <field name="model">super.order</field>
2350+ <field name="type">form</field>
2351+ <field name="arch" type="xml">
2352+ <form string="Order">
2353+ <field name="type"/>
2354+ <field name="name"/>
2355+ <field name="date"/>
2356+ <field name="partner_id"/>
2357+ <field name="amount_untaxed" />
2358+ <field name="amount_total" />
2359+ <field name="sale_order_id"/>
2360+ <field name="purchase_order_id"/>
2361+ <field name="company_id" groups="base.group_multi_company" />
2362+ <field name="state"/>
2363+ </form>
2364+ </field>
2365+ </record>
2366+ <record id="super_order_filter" model="ir.ui.view">
2367+ <field name="name">super_order.select</field>
2368+ <field name="model">super.order</field>
2369+ <field name="type">search</field>
2370+ <field name="arch" type="xml">
2371+ <search string="Search Contracts">
2372+ <filter icon="terp-partner" string="Sales" domain="[('type','=','sale')]" help="Sale Orders" name="sale"/>
2373+ <filter icon="terp-purchase" string="Purchases" domain="[('type','=','purchase')]" name="purchase"/>
2374+ <separator orientation="vertical"/>
2375+ <field name="name"
2376+ filter_domain="[('name','ilike',self)]"/>
2377+ <field name="partner_id"/>
2378+ <field name="date"/>
2379+ <newline/>
2380+ <group expand="1" string="Group By..." groups="base.group_extended">
2381+ <filter string="Partner" icon="terp-personal" domain="[]" context="{'group_by':'partner_id'}"/>
2382+ <separator orientation="vertical"/>
2383+ <filter string="State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state_key'}"/>
2384+ <separator orientation="vertical"/>
2385+ <filter string="Order Date" icon="terp-go-month" domain="[]" context="{'group_by':'date'}"/>
2386+ </group>
2387+ </search>
2388+ </field>
2389+ </record>
2390+
2391+ <record id="action_super_order_tree" model="ir.actions.act_window">
2392+ <field name="name">Contracts</field>
2393+ <field name="type">ir.actions.act_window</field>
2394+ <field name="res_model">super.order</field>
2395+ <field name="view_type">form</field>
2396+ <field name="view_mode">tree,form</field>
2397+ </record>
2398+
2399+ <menuitem
2400+ name="Contracts"
2401+ action="action_super_order_tree"
2402+ id="menu_action_super_order_tree"
2403+ icon="STOCK_INDENT"/>
2404+ </data>
2405+</openerp>
2406
2407=== added directory 'sale_purchase_orders_super_list/security'
2408=== added file 'sale_purchase_orders_super_list/security/ir.model.access.csv'
2409--- sale_purchase_orders_super_list/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
2410+++ sale_purchase_orders_super_list/security/ir.model.access.csv 2012-06-14 14:09:20 +0000
2411@@ -0,0 +1,5 @@
2412+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
2413+access_sale_super_order,sale.super_order,model_super_order,base.group_sale_salesman,1,1,1,0
2414+access_sale_super_order_stock_worker,sale.order super_order worker,model_super_order,stock.group_stock_user,1,1,0,0
2415+access_sale_super_order_manager,sale.super_order.manager,model_super_order,base.group_sale_manager,1,1,1,1
2416+access_sale_super_order_accountant,sale.super_order.accountant,model_super_order,account.group_account_user,1,1,0,0
2417
2418=== added directory 'stock_picking_related'
2419=== added file 'stock_picking_related/AUTHORS.txt'
2420--- stock_picking_related/AUTHORS.txt 1970-01-01 00:00:00 +0000
2421+++ stock_picking_related/AUTHORS.txt 2012-06-14 14:09:20 +0000
2422@@ -0,0 +1,1 @@
2423+Lorenzo Battistini <lorenzo.battistini@agilebg.com>
2424
2425=== added file 'stock_picking_related/__init__.py'
2426--- stock_picking_related/__init__.py 1970-01-01 00:00:00 +0000
2427+++ stock_picking_related/__init__.py 2012-06-14 14:09:20 +0000
2428@@ -0,0 +1,22 @@
2429+# -*- coding: utf-8 -*-
2430+##############################################################################
2431+#
2432+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
2433+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
2434+# All Rights Reserved
2435+#
2436+# This program is free software: you can redistribute it and/or modify
2437+# it under the terms of the GNU Affero General Public License as published
2438+# by the Free Software Foundation, either version 3 of the License, or
2439+# (at your option) any later version.
2440+#
2441+# This program is distributed in the hope that it will be useful,
2442+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2443+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2444+# GNU General Public License for more details.
2445+#
2446+# You should have received a copy of the GNU Affero General Public License
2447+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2448+#
2449+##############################################################################
2450+import stock
2451
2452=== added file 'stock_picking_related/__openerp__.py'
2453--- stock_picking_related/__openerp__.py 1970-01-01 00:00:00 +0000
2454+++ stock_picking_related/__openerp__.py 2012-06-14 14:09:20 +0000
2455@@ -0,0 +1,39 @@
2456+# -*- coding: utf-8 -*-
2457+##############################################################################
2458+#
2459+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
2460+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
2461+# All Rights Reserved
2462+#
2463+# This program is free software: you can redistribute it and/or modify
2464+# it under the terms of the GNU Affero General Public License as published
2465+# by the Free Software Foundation, either version 3 of the License, or
2466+# (at your option) any later version.
2467+#
2468+# This program is distributed in the hope that it will be useful,
2469+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2470+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2471+# GNU General Public License for more details.
2472+#
2473+# You should have received a copy of the GNU Affero General Public License
2474+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2475+#
2476+##############################################################################
2477+{
2478+ 'name': "Hierarchic View for pickings",
2479+ 'version': '0.1',
2480+ 'category': 'Warehouse Management',
2481+ 'description': """This module helps to understand the relations between pickings.
2482+ When a picking is partially delivered, it tracks every generated "child" picking. Equally, the generated picking refers to its "parent" picking.""",
2483+ 'author': 'Agile Business Group & Domsense',
2484+ 'website': 'http://www.agilebg.com',
2485+ 'license': 'AGPL-3',
2486+ "depends" : ['stock'],
2487+ "init_xml" : [],
2488+ "update_xml" : [
2489+ 'stock_view.xml',
2490+ ],
2491+ "demo_xml" : [],
2492+ "active": False,
2493+ "installable": True
2494+}
2495
2496=== added directory 'stock_picking_related/i18n'
2497=== added directory 'stock_picking_related/security'
2498=== added file 'stock_picking_related/stock.py'
2499--- stock_picking_related/stock.py 1970-01-01 00:00:00 +0000
2500+++ stock_picking_related/stock.py 2012-06-14 14:09:20 +0000
2501@@ -0,0 +1,84 @@
2502+# -*- coding: utf-8 -*-
2503+##############################################################################
2504+#
2505+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
2506+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
2507+# All Rights Reserved
2508+#
2509+# This program is free software: you can redistribute it and/or modify
2510+# it under the terms of the GNU Affero General Public License as published
2511+# by the Free Software Foundation, either version 3 of the License, or
2512+# (at your option) any later version.
2513+#
2514+# This program is distributed in the hope that it will be useful,
2515+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2516+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2517+# GNU General Public License for more details.
2518+#
2519+# You should have received a copy of the GNU Affero General Public License
2520+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2521+#
2522+##############################################################################
2523+
2524+from osv import fields, osv
2525+from tools.translate import _
2526+
2527+class stock_picking(osv.osv):
2528+ def _compute_qty(self, cr, uid, ids, field_names, arg=None, context=None):
2529+ res = {}
2530+ for picking in self.browse(cr, uid, ids, context=context):
2531+ total = 0.0
2532+ for move in picking.move_lines:
2533+ total += move.product_qty
2534+ res[picking.id] = total
2535+ return res
2536+
2537+ def _compute_total_qty(self, cr, uid, ids, field_names, arg=None, context=None):
2538+ res = {}
2539+ for picking in self.browse(cr, uid, ids, context=context):
2540+ total = picking.qty
2541+ for child in picking.child_ids:
2542+ total += child.qty
2543+ res[picking.id] = total
2544+ return res
2545+
2546+ def _compute_uom(self, cr, uid, ids, field_names, arg=None, context=None):
2547+ res = {}
2548+ for picking in self.browse(cr, uid, ids, context=context):
2549+ uom = ''
2550+ for move in picking.move_lines:
2551+ if uom and move.product_uom.name != uom:
2552+ uom = _('Various')
2553+ else:
2554+ uom = _(move.product_uom.name)
2555+ res[picking.id] = uom
2556+ return res
2557+
2558+ _inherit = "stock.picking"
2559+ _columns = {
2560+ 'parent_id': fields.many2one('stock.picking', 'Parent Picking', readonly=True),
2561+ 'child_ids': fields.one2many('stock.picking', 'parent_id', 'Children Pickings', readonly=True),
2562+ 'qty': fields.function(_compute_qty, string="Quantity"),
2563+ 'total_qty': fields.function(_compute_total_qty, string="Total Quantity"),
2564+ 'uom': fields.function(_compute_uom, string="UoM", type='char',
2565+ size=64),
2566+ }
2567+
2568+ def do_partial(self, cr, uid, ids, partial_datas, context=None):
2569+ res = super(stock_picking, self).do_partial(cr, uid, ids, partial_datas, context=context)
2570+ for pick_id in res:
2571+ if res[pick_id].get('delivered_picking', False):
2572+ if res[pick_id]['delivered_picking'] != pick_id:
2573+ self.write(cr, uid, res[pick_id]['delivered_picking'], {'parent_id': pick_id})
2574+
2575+ return res
2576+
2577+ def copy(self, cr, uid, id, default=None, context=None):
2578+ if default is None:
2579+ default = {}
2580+ default = default.copy()
2581+ default['parent_id'] = False
2582+ default['child_ids'] = False
2583+ return super(stock_picking, self).copy(cr, uid, id, default, context)
2584+
2585+stock_picking()
2586
2587=== added file 'stock_picking_related/stock_view.xml'
2588--- stock_picking_related/stock_view.xml 1970-01-01 00:00:00 +0000
2589+++ stock_picking_related/stock_view.xml 2012-06-14 14:09:20 +0000
2590@@ -0,0 +1,101 @@
2591+<?xml version="1.0" encoding="utf-8"?>
2592+<openerp>
2593+ <data>
2594+ <record id="view_picking_out_form" model="ir.ui.view">
2595+ <field name="name">stock.picking.out.form</field>
2596+ <field name="model">stock.picking</field>
2597+ <field name="type">form</field>
2598+ <field name="inherit_id" ref="stock.view_picking_out_form"></field>
2599+ <field name="arch" type="xml">
2600+ <page string="Notes" position="after">
2601+ <page string="Related">
2602+ <field colspan="4" name="parent_id" />
2603+ <field colspan="4" name="child_ids" nolabel="1" string="Children"/>
2604+ </page>
2605+ </page>
2606+ </field>
2607+ </record>
2608+ <record id="view_picking_in_form" model="ir.ui.view">
2609+ <field name="name">stock.picking.in.form</field>
2610+ <field name="model">stock.picking</field>
2611+ <field name="type">form</field>
2612+ <field name="inherit_id" ref="stock.view_picking_in_form"></field>
2613+ <field name="arch" type="xml">
2614+ <page string="Notes" position="after">
2615+ <page string="Related">
2616+ <field colspan="4" name="parent_id" />
2617+ <field colspan="4" name="child_ids" nolabel="1" string="Children"/>
2618+ </page>
2619+ </page>
2620+ </field>
2621+ </record>
2622+ <record id="view_picking_form" model="ir.ui.view">
2623+ <field name="name">stock.picking.form</field>
2624+ <field name="model">stock.picking</field>
2625+ <field name="type">form</field>
2626+ <field name="inherit_id" ref="stock.view_picking_form"></field>
2627+ <field name="arch" type="xml">
2628+ <page string="Notes" position="after">
2629+ <page string="Related">
2630+ <field colspan="4" name="parent_id" />
2631+ <field colspan="4" name="child_ids" nolabel="1" string="Children"/>
2632+ </page>
2633+ </page>
2634+ </field>
2635+ </record>
2636+
2637+ <!-- tree -->
2638+
2639+ <record id="view_picking_tree" model="ir.ui.view">
2640+ <field name="name">view_picking_tree</field>
2641+ <field name="model">stock.picking</field>
2642+ <field name="type">tree</field>
2643+ <field name="field_parent">child_ids</field>
2644+ <field name="arch" type="xml">
2645+ <tree colors="blue:state == 'draft';grey:state == 'cancel';red:state not in ('cancel', 'done') and date &lt; current_date" string="Picking list">
2646+ <field name="name"/>
2647+ <field name="partner_id" />
2648+ <field name="origin"/>
2649+ <field name="date"/>
2650+ <field name="min_date"/>
2651+ <field name="invoice_state"/>
2652+ <field name="total_qty" />
2653+ <field name="qty" />
2654+ <field name="uom" />
2655+ <field name="state"/>
2656+ </tree>
2657+ </field>
2658+ </record>
2659+ <record id="action_view_out_picking_tree" model="ir.actions.act_window">
2660+ <field name="name">Out Delivery Tree</field>
2661+ <field name="res_model">stock.picking</field>
2662+ <field name="view_type">tree</field>
2663+ <field name="view_id" ref="view_picking_tree"/>
2664+ <field name="domain">[('type','=','out'), ('parent_id','=',False)]</field>
2665+ </record>
2666+ <record id="action_view_in_picking_tree" model="ir.actions.act_window">
2667+ <field name="name">In Delivery Tree</field>
2668+ <field name="res_model">stock.picking</field>
2669+ <field name="view_type">tree</field>
2670+ <field name="view_id" ref="view_picking_tree"/>
2671+ <field name="domain">[('type','=','in'), ('parent_id','=',False)]</field>
2672+ </record>
2673+ <menuitem action="action_view_out_picking_tree" id="menu_action_view_out_picking_tree" parent="stock.menu_stock_warehouse_mgmt" />
2674+ <menuitem action="action_view_in_picking_tree" id="menu_action_view_in_picking_tree" parent="stock.menu_stock_warehouse_mgmt" />
2675+
2676+ <record id="action_picking_move_open" model="ir.actions.act_window">
2677+ <field name="name">Moves</field>
2678+ <field name="res_model">stock.move</field>
2679+ <field name="view_type">form</field>
2680+ <field name="view_mode">tree,form</field>
2681+ <field name="view_id" ref="stock.view_move_tree_reception_picking"/>
2682+ <field name="domain">[('picking_id','=',active_id)]</field>
2683+ </record>
2684+ <record id="ir_open_picking_move" model="ir.values">
2685+ <field name="key2">tree_but_open</field>
2686+ <field name="model">stock.picking</field>
2687+ <field name="name">Picking moves</field>
2688+ <field eval="'ir.actions.act_window,%d'%action_picking_move_open" name="value"/>
2689+ </record>
2690+ </data>
2691+</openerp>

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: