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

Proposed by Lorenzo Battistini
Status: Needs review
Proposed branch: lp:~domsense/domsense-agilebg-addons/adding_invoice_contract
Merge into: lp:domsense-agilebg-addons/6.1
Diff against target: 409 lines (+341/-0)
13 files modified
sale_hour_package/AUTHORS.txt (+1/-0)
sale_hour_package/__init__.py (+24/-0)
sale_hour_package/__openerp__.py (+47/-0)
sale_hour_package/analytic.py (+31/-0)
sale_hour_package/analytic_view.xml (+17/-0)
sale_hour_package/product.py (+31/-0)
sale_hour_package/product_view.xml (+17/-0)
sale_hour_package/sale.py (+68/-0)
sale_hour_package/sale_view.xml (+21/-0)
sale_layout_hour_package/AUTHORS.txt (+1/-0)
sale_layout_hour_package/__init__.py (+21/-0)
sale_layout_hour_package/__openerp__.py (+41/-0)
sale_layout_hour_package/sale_view.xml (+21/-0)
To merge this branch: bzr merge lp:~domsense/domsense-agilebg-addons/adding_invoice_contract
Reviewer Review Type Date Requested Status
Lorenzo Battistini Needs Fixing
Review via email: mp+121779@code.launchpad.net
To post a comment you must log in.
243. By Lorenzo Battistini

[imp] description

244. By Lorenzo Battistini

[imp] faccio sparire il bottone dopo la generazione

245. By Lorenzo Battistini

[add] pass the analytic account to invoice

246. By Lorenzo Battistini

[add] sale_layout_hour_package

Revision history for this message
Lorenzo Battistini (elbati) wrote :

Before merging, we need to analyse analytic_hours_block

review: Needs Fixing

Unmerged revisions

246. By Lorenzo Battistini

[add] sale_layout_hour_package

245. By Lorenzo Battistini

[add] pass the analytic account to invoice

244. By Lorenzo Battistini

[imp] faccio sparire il bottone dopo la generazione

243. By Lorenzo Battistini

[imp] description

242. By Lorenzo Battistini

[ADD] sale_hour_package
working prototype

241. By Lorenzo Battistini

not working changes

240. By Lorenzo Battistini

[add] sale_hour_package
not working draft

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'sale_hour_package'
2=== added file 'sale_hour_package/AUTHORS.txt'
3--- sale_hour_package/AUTHORS.txt 1970-01-01 00:00:00 +0000
4+++ sale_hour_package/AUTHORS.txt 2012-10-09 10:00:45 +0000
5@@ -0,0 +1,1 @@
6+Lorenzo Battistini <lorenzo.battistini@domsense.com>
7
8=== added file 'sale_hour_package/__init__.py'
9--- sale_hour_package/__init__.py 1970-01-01 00:00:00 +0000
10+++ sale_hour_package/__init__.py 2012-10-09 10:00:45 +0000
11@@ -0,0 +1,24 @@
12+# -*- coding: utf-8 -*-
13+##############################################################################
14+#
15+# OpenERP, Open Source Management Solution
16+# Copyright (C) 2012 Domsense s.r.l. (<http://www.domsense.com>).
17+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
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
21+# published by the Free Software Foundation, either version 3 of the
22+# License, or (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 Affero 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 product
34+import sale
35+import analytic
36
37=== added file 'sale_hour_package/__openerp__.py'
38--- sale_hour_package/__openerp__.py 1970-01-01 00:00:00 +0000
39+++ sale_hour_package/__openerp__.py 2012-10-09 10:00:45 +0000
40@@ -0,0 +1,47 @@
41+# -*- coding: utf-8 -*-
42+##############################################################################
43+#
44+# OpenERP, Open Source Management Solution
45+# Copyright (C) 2011-2012 Domsense s.r.l. (<http://www.domsense.com>).
46+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
47+#
48+# This program is free software: you can redistribute it and/or modify
49+# it under the terms of the GNU Affero General Public License as
50+# published by the Free Software Foundation, either version 3 of the
51+# License, or (at your option) any later version.
52+#
53+# This program is distributed in the hope that it will be useful,
54+# but WITHOUT ANY WARRANTY; without even the implied warranty of
55+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
56+# GNU Affero General Public License for more details.
57+#
58+# You should have received a copy of the GNU Affero General Public License
59+# along with this program. If not, see <http://www.gnu.org/licenses/>.
60+#
61+##############################################################################
62+
63+
64+{
65+ "name": "Sale hour package",
66+ "version": "1.0",
67+ 'category': 'Generic Modules/Accounting',
68+ "depends": ["sale"],
69+ "author": "Agile Business Group & Domsense",
70+ "description": """
71+ Generate hour package contracts from sale orders.
72+
73+ If you are selling a product configured as 'hour package', you can generate the 'hour package' analytic account directly from sale order line.
74+ In order to do this, you first have to define a 'hour package container' analytic account for the partner you are selling to.
75+
76+ """,
77+ 'website': 'http://www.agilebg.com',
78+ 'init_xml': [],
79+ 'update_xml': [
80+ 'product_view.xml',
81+ 'analytic_view.xml',
82+ 'sale_view.xml',
83+ ],
84+ 'demo_xml': [],
85+ 'installable': True,
86+ 'active': False,
87+}
88
89=== added file 'sale_hour_package/analytic.py'
90--- sale_hour_package/analytic.py 1970-01-01 00:00:00 +0000
91+++ sale_hour_package/analytic.py 2012-10-09 10:00:45 +0000
92@@ -0,0 +1,31 @@
93+# -*- coding: utf-8 -*-
94+##############################################################################
95+#
96+# OpenERP, Open Source Management Solution
97+# Copyright (C) 2012 Domsense s.r.l. (<http://www.domsense.com>).
98+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
99+#
100+# This program is free software: you can redistribute it and/or modify
101+# it under the terms of the GNU Affero General Public License as
102+# published by the Free Software Foundation, either version 3 of the
103+# License, or (at your option) any later version.
104+#
105+# This program is distributed in the hope that it will be useful,
106+# but WITHOUT ANY WARRANTY; without even the implied warranty of
107+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
108+# GNU Affero General Public License for more details.
109+#
110+# You should have received a copy of the GNU Affero General Public License
111+# along with this program. If not, see <http://www.gnu.org/licenses/>.
112+#
113+##############################################################################
114+
115+from osv import fields, osv
116+
117+class analytic_account(osv.osv):
118+
119+ _inherit = "account.analytic.account"
120+
121+ _columns = {
122+ 'hour_pack_container': fields.boolean('Is hour package container'),
123+ }
124
125=== added file 'sale_hour_package/analytic_view.xml'
126--- sale_hour_package/analytic_view.xml 1970-01-01 00:00:00 +0000
127+++ sale_hour_package/analytic_view.xml 2012-10-09 10:00:45 +0000
128@@ -0,0 +1,17 @@
129+<?xml version="1.0"?>
130+<openerp>
131+ <data>
132+
133+ <record model="ir.ui.view" id="view_account_analytic_account_form">
134+ <field name="name">account.analytic.account.form</field>
135+ <field name="model">account.analytic.account</field>
136+ <field name="type">form</field>
137+ <field name="inherit_id" ref="account.view_account_analytic_account_form"/>
138+ <field name="arch" type="xml">
139+ <field name="type" position="after">
140+ <field name="hour_pack_container"></field>
141+ </field>
142+ </field>
143+ </record>
144+ </data>
145+</openerp>
146
147=== added directory 'sale_hour_package/i18n'
148=== added file 'sale_hour_package/product.py'
149--- sale_hour_package/product.py 1970-01-01 00:00:00 +0000
150+++ sale_hour_package/product.py 2012-10-09 10:00:45 +0000
151@@ -0,0 +1,31 @@
152+# -*- coding: utf-8 -*-
153+##############################################################################
154+#
155+# OpenERP, Open Source Management Solution
156+# Copyright (C) 2012 Domsense s.r.l. (<http://www.domsense.com>).
157+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
158+#
159+# This program is free software: you can redistribute it and/or modify
160+# it under the terms of the GNU Affero General Public License as
161+# published by the Free Software Foundation, either version 3 of the
162+# License, or (at your option) any later version.
163+#
164+# This program is distributed in the hope that it will be useful,
165+# but WITHOUT ANY WARRANTY; without even the implied warranty of
166+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
167+# GNU Affero General Public License for more details.
168+#
169+# You should have received a copy of the GNU Affero General Public License
170+# along with this program. If not, see <http://www.gnu.org/licenses/>.
171+#
172+##############################################################################
173+
174+from osv import fields, osv
175+
176+class product_product(osv.osv):
177+
178+ _inherit = "product.product"
179+
180+ _columns = {
181+ 'hour_pack': fields.boolean('Is hour package'),
182+ }
183
184=== added file 'sale_hour_package/product_view.xml'
185--- sale_hour_package/product_view.xml 1970-01-01 00:00:00 +0000
186+++ sale_hour_package/product_view.xml 2012-10-09 10:00:45 +0000
187@@ -0,0 +1,17 @@
188+<?xml version="1.0"?>
189+<openerp>
190+ <data>
191+
192+ <record model="ir.ui.view" id="product_normal_form_view">
193+ <field name="name">product.normal.form</field>
194+ <field name="model">product.product</field>
195+ <field name="type">form</field>
196+ <field name="inherit_id" ref="product.product_normal_form_view"/>
197+ <field name="arch" type="xml">
198+ <field name="type" position="after">
199+ <field name="hour_pack" attrs="{'invisible': [('type', '!=', 'service')]}"></field>
200+ </field>
201+ </field>
202+ </record>
203+ </data>
204+</openerp>
205
206=== added file 'sale_hour_package/sale.py'
207--- sale_hour_package/sale.py 1970-01-01 00:00:00 +0000
208+++ sale_hour_package/sale.py 2012-10-09 10:00:45 +0000
209@@ -0,0 +1,68 @@
210+# -*- coding: utf-8 -*-
211+##############################################################################
212+#
213+# OpenERP, Open Source Management Solution
214+# Copyright (C) 2012 Domsense s.r.l. (<http://www.domsense.com>).
215+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
216+#
217+# This program is free software: you can redistribute it and/or modify
218+# it under the terms of the GNU Affero General Public License as
219+# published by the Free Software Foundation, either version 3 of the
220+# License, or (at your option) any later version.
221+#
222+# This program is distributed in the hope that it will be useful,
223+# but WITHOUT ANY WARRANTY; without even the implied warranty of
224+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
225+# GNU Affero General Public License for more details.
226+#
227+# You should have received a copy of the GNU Affero General Public License
228+# along with this program. If not, see <http://www.gnu.org/licenses/>.
229+#
230+##############################################################################
231+
232+from osv import fields, osv
233+from tools.translate import _
234+
235+class sale_order_line(osv.osv):
236+
237+ _inherit = "sale.order.line"
238+
239+ _columns = {
240+ 'hour_pack_id': fields.many2one('account.analytic.account','Hour package', readonly=True),
241+ 'is_hour_pack': fields.related('product_id', 'hour_pack', type='boolean', string='Is hour package', store=True),
242+ 'order_state': fields.related('order_id', 'state', type='char', size=64, string='Order state', store=True),
243+ }
244+
245+ def invoice_line_create(self, cr, uid, ids, context=None):
246+ if context is None:
247+ context = {}
248+ line_obj = self.pool.get('account.invoice.line')
249+ create_ids = super(sale_order_line, self).invoice_line_create(cr, uid, ids, context=context)
250+ i = 0
251+ for line in self.browse(cr, uid, ids, context=context):
252+ if line.hour_pack_id:
253+ line_obj.write(cr, uid, [create_ids[i]], {'account_analytic_id': line.hour_pack_id.id})
254+ i = i + 1
255+ return create_ids
256+
257+ def generate_hour_pack(self, cr, uid, ids, context=None):
258+ anal_acc_pool = self.pool.get('account.analytic.account')
259+ for so_line in self.browse(cr, uid, ids, context):
260+ parent_ids = anal_acc_pool.search(cr, uid, [
261+ ('partner_id','=', so_line.order_id.partner_id.id),
262+ ('hour_pack_container', '=', True),
263+ ])
264+ if not parent_ids:
265+ raise osv.except_osv(_('Error'), _('No hour package container (analytic account) defined for partner %s') % so_line.order_id.partner_id.name)
266+ if so_line.product_id and so_line.product_id.hour_pack:
267+ if so_line.hour_pack_id:
268+ raise osv.except_osv(_('Error'), _('Order line %s has hour package yet. Remove it first') % so_line.name)
269+ acc_vals = {
270+ 'name': so_line.name + ' ['+so_line.order_id.name+'] '+ str(so_line.product_uom_qty) + ' '+ so_line.product_uom.name,
271+ 'partner_id': so_line.order_id.partner_id.id,
272+ 'quantity_max': so_line.product_uom_qty,
273+ 'parent_id': parent_ids[0],
274+ }
275+ acc_id = anal_acc_pool.create(cr, uid, acc_vals, context)
276+ so_line.write({'hour_pack_id': acc_id})
277+ return True
278
279=== added file 'sale_hour_package/sale_view.xml'
280--- sale_hour_package/sale_view.xml 1970-01-01 00:00:00 +0000
281+++ sale_hour_package/sale_view.xml 2012-10-09 10:00:45 +0000
282@@ -0,0 +1,21 @@
283+<?xml version="1.0"?>
284+<openerp>
285+ <data>
286+
287+ <record model="ir.ui.view" id="view_order_form">
288+ <field name="name">sale.order.form</field>
289+ <field name="model">sale.order</field>
290+ <field name="type">form</field>
291+ <field name="inherit_id" ref="sale.view_order_form"/>
292+ <field name="arch" type="xml">
293+ <field name="address_allotment_id" position="after">
294+ <newline/>
295+ <field name="is_hour_pack" readonly="1"/>
296+ <field name="order_state" invisible="1"/>
297+ <button type="object" name="generate_hour_pack" string="Generate hour package" icon="gtk-go-forward" attrs="{'invisible': ['|','|',('is_hour_pack', '=', False),('order_state','in', ['draft', 'cancel']),('hour_pack_id', '!=', False)]}" colspan="2"></button>
298+ <field name="hour_pack_id" />
299+ </field>
300+ </field>
301+ </record>
302+ </data>
303+</openerp>
304
305=== added directory 'sale_layout_hour_package'
306=== added file 'sale_layout_hour_package/AUTHORS.txt'
307--- sale_layout_hour_package/AUTHORS.txt 1970-01-01 00:00:00 +0000
308+++ sale_layout_hour_package/AUTHORS.txt 2012-10-09 10:00:45 +0000
309@@ -0,0 +1,1 @@
310+Lorenzo Battistini <lorenzo.battistini@domsense.com>
311
312=== added file 'sale_layout_hour_package/__init__.py'
313--- sale_layout_hour_package/__init__.py 1970-01-01 00:00:00 +0000
314+++ sale_layout_hour_package/__init__.py 2012-10-09 10:00:45 +0000
315@@ -0,0 +1,21 @@
316+# -*- coding: utf-8 -*-
317+##############################################################################
318+#
319+# OpenERP, Open Source Management Solution
320+# Copyright (C) 2012 Domsense s.r.l. (<http://www.domsense.com>).
321+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
322+#
323+# This program is free software: you can redistribute it and/or modify
324+# it under the terms of the GNU Affero General Public License as
325+# published by the Free Software Foundation, either version 3 of the
326+# License, or (at your option) any later version.
327+#
328+# This program is distributed in the hope that it will be useful,
329+# but WITHOUT ANY WARRANTY; without even the implied warranty of
330+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
331+# GNU Affero General Public License for more details.
332+#
333+# You should have received a copy of the GNU Affero General Public License
334+# along with this program. If not, see <http://www.gnu.org/licenses/>.
335+#
336+##############################################################################
337
338=== added file 'sale_layout_hour_package/__openerp__.py'
339--- sale_layout_hour_package/__openerp__.py 1970-01-01 00:00:00 +0000
340+++ sale_layout_hour_package/__openerp__.py 2012-10-09 10:00:45 +0000
341@@ -0,0 +1,41 @@
342+# -*- coding: utf-8 -*-
343+##############################################################################
344+#
345+# OpenERP, Open Source Management Solution
346+# Copyright (C) 2012 Domsense s.r.l. (<http://www.domsense.com>).
347+# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
348+#
349+# This program is free software: you can redistribute it and/or modify
350+# it under the terms of the GNU Affero General Public License as
351+# published by the Free Software Foundation, either version 3 of the
352+# License, or (at your option) any later version.
353+#
354+# This program is distributed in the hope that it will be useful,
355+# but WITHOUT ANY WARRANTY; without even the implied warranty of
356+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
357+# GNU Affero General Public License for more details.
358+#
359+# You should have received a copy of the GNU Affero General Public License
360+# along with this program. If not, see <http://www.gnu.org/licenses/>.
361+#
362+##############################################################################
363+
364+
365+{
366+ "name": "Sale layout hour package",
367+ "version": "1.0",
368+ 'category': 'Generic Modules/Accounting',
369+ "depends": ["sale_layout", "sale_hour_package"],
370+ "author": "Agile Business Group & Domsense",
371+ "description": """
372+Adapting sale_hour_package to sale_layout
373+ """,
374+ 'website': 'http://www.agilebg.com',
375+ 'init_xml': [],
376+ 'update_xml': [
377+ 'sale_view.xml',
378+ ],
379+ 'demo_xml': [],
380+ 'installable': True,
381+ 'active': False,
382+}
383
384=== added directory 'sale_layout_hour_package/i18n'
385=== added file 'sale_layout_hour_package/sale_view.xml'
386--- sale_layout_hour_package/sale_view.xml 1970-01-01 00:00:00 +0000
387+++ sale_layout_hour_package/sale_view.xml 2012-10-09 10:00:45 +0000
388@@ -0,0 +1,21 @@
389+<?xml version="1.0"?>
390+<openerp>
391+ <data>
392+
393+ <record model="ir.ui.view" id="view_order_form">
394+ <field name="name">sale.order.form</field>
395+ <field name="model">sale.order</field>
396+ <field name="type">form</field>
397+ <field name="inherit_id" ref="sale_layout.view_order_form_inherit_1"/>
398+ <field name="arch" type="xml">
399+ <field name="address_allotment_id" position="after">
400+ <newline/>
401+ <field name="is_hour_pack" readonly="1"/>
402+ <field name="order_state" invisible="1"/>
403+ <button type="object" name="generate_hour_pack" string="Generate hour package" icon="gtk-go-forward" attrs="{'invisible': ['|','|',('is_hour_pack', '=', False),('order_state','in', ['draft', 'cancel']),('hour_pack_id', '!=', False)]}" colspan="2"></button>
404+ <field name="hour_pack_id" />
405+ </field>
406+ </field>
407+ </record>
408+ </data>
409+</openerp>

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: