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
=== added directory 'sale_hour_package'
=== added file 'sale_hour_package/AUTHORS.txt'
--- sale_hour_package/AUTHORS.txt 1970-01-01 00:00:00 +0000
+++ sale_hour_package/AUTHORS.txt 2012-10-09 10:00:45 +0000
@@ -0,0 +1,1 @@
1Lorenzo Battistini <lorenzo.battistini@domsense.com>
02
=== added file 'sale_hour_package/__init__.py'
--- sale_hour_package/__init__.py 1970-01-01 00:00:00 +0000
+++ sale_hour_package/__init__.py 2012-10-09 10:00:45 +0000
@@ -0,0 +1,24 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2012 Domsense s.r.l. (<http://www.domsense.com>).
6# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22import product
23import sale
24import analytic
025
=== added file 'sale_hour_package/__openerp__.py'
--- sale_hour_package/__openerp__.py 1970-01-01 00:00:00 +0000
+++ sale_hour_package/__openerp__.py 2012-10-09 10:00:45 +0000
@@ -0,0 +1,47 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011-2012 Domsense s.r.l. (<http://www.domsense.com>).
6# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23
24{
25 "name": "Sale hour package",
26 "version": "1.0",
27 'category': 'Generic Modules/Accounting',
28 "depends": ["sale"],
29 "author": "Agile Business Group & Domsense",
30 "description": """
31 Generate hour package contracts from sale orders.
32
33 If you are selling a product configured as 'hour package', you can generate the 'hour package' analytic account directly from sale order line.
34 In order to do this, you first have to define a 'hour package container' analytic account for the partner you are selling to.
35
36 """,
37 'website': 'http://www.agilebg.com',
38 'init_xml': [],
39 'update_xml': [
40 'product_view.xml',
41 'analytic_view.xml',
42 'sale_view.xml',
43 ],
44 'demo_xml': [],
45 'installable': True,
46 'active': False,
47}
048
=== added file 'sale_hour_package/analytic.py'
--- sale_hour_package/analytic.py 1970-01-01 00:00:00 +0000
+++ sale_hour_package/analytic.py 2012-10-09 10:00:45 +0000
@@ -0,0 +1,31 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2012 Domsense s.r.l. (<http://www.domsense.com>).
6# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23from osv import fields, osv
24
25class analytic_account(osv.osv):
26
27 _inherit = "account.analytic.account"
28
29 _columns = {
30 'hour_pack_container': fields.boolean('Is hour package container'),
31 }
032
=== added file 'sale_hour_package/analytic_view.xml'
--- sale_hour_package/analytic_view.xml 1970-01-01 00:00:00 +0000
+++ sale_hour_package/analytic_view.xml 2012-10-09 10:00:45 +0000
@@ -0,0 +1,17 @@
1<?xml version="1.0"?>
2<openerp>
3 <data>
4
5 <record model="ir.ui.view" id="view_account_analytic_account_form">
6 <field name="name">account.analytic.account.form</field>
7 <field name="model">account.analytic.account</field>
8 <field name="type">form</field>
9 <field name="inherit_id" ref="account.view_account_analytic_account_form"/>
10 <field name="arch" type="xml">
11 <field name="type" position="after">
12 <field name="hour_pack_container"></field>
13 </field>
14 </field>
15 </record>
16 </data>
17</openerp>
018
=== added directory 'sale_hour_package/i18n'
=== added file 'sale_hour_package/product.py'
--- sale_hour_package/product.py 1970-01-01 00:00:00 +0000
+++ sale_hour_package/product.py 2012-10-09 10:00:45 +0000
@@ -0,0 +1,31 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2012 Domsense s.r.l. (<http://www.domsense.com>).
6# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23from osv import fields, osv
24
25class product_product(osv.osv):
26
27 _inherit = "product.product"
28
29 _columns = {
30 'hour_pack': fields.boolean('Is hour package'),
31 }
032
=== added file 'sale_hour_package/product_view.xml'
--- sale_hour_package/product_view.xml 1970-01-01 00:00:00 +0000
+++ sale_hour_package/product_view.xml 2012-10-09 10:00:45 +0000
@@ -0,0 +1,17 @@
1<?xml version="1.0"?>
2<openerp>
3 <data>
4
5 <record model="ir.ui.view" id="product_normal_form_view">
6 <field name="name">product.normal.form</field>
7 <field name="model">product.product</field>
8 <field name="type">form</field>
9 <field name="inherit_id" ref="product.product_normal_form_view"/>
10 <field name="arch" type="xml">
11 <field name="type" position="after">
12 <field name="hour_pack" attrs="{'invisible': [('type', '!=', 'service')]}"></field>
13 </field>
14 </field>
15 </record>
16 </data>
17</openerp>
018
=== added file 'sale_hour_package/sale.py'
--- sale_hour_package/sale.py 1970-01-01 00:00:00 +0000
+++ sale_hour_package/sale.py 2012-10-09 10:00:45 +0000
@@ -0,0 +1,68 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2012 Domsense s.r.l. (<http://www.domsense.com>).
6# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23from osv import fields, osv
24from tools.translate import _
25
26class sale_order_line(osv.osv):
27
28 _inherit = "sale.order.line"
29
30 _columns = {
31 'hour_pack_id': fields.many2one('account.analytic.account','Hour package', readonly=True),
32 'is_hour_pack': fields.related('product_id', 'hour_pack', type='boolean', string='Is hour package', store=True),
33 'order_state': fields.related('order_id', 'state', type='char', size=64, string='Order state', store=True),
34 }
35
36 def invoice_line_create(self, cr, uid, ids, context=None):
37 if context is None:
38 context = {}
39 line_obj = self.pool.get('account.invoice.line')
40 create_ids = super(sale_order_line, self).invoice_line_create(cr, uid, ids, context=context)
41 i = 0
42 for line in self.browse(cr, uid, ids, context=context):
43 if line.hour_pack_id:
44 line_obj.write(cr, uid, [create_ids[i]], {'account_analytic_id': line.hour_pack_id.id})
45 i = i + 1
46 return create_ids
47
48 def generate_hour_pack(self, cr, uid, ids, context=None):
49 anal_acc_pool = self.pool.get('account.analytic.account')
50 for so_line in self.browse(cr, uid, ids, context):
51 parent_ids = anal_acc_pool.search(cr, uid, [
52 ('partner_id','=', so_line.order_id.partner_id.id),
53 ('hour_pack_container', '=', True),
54 ])
55 if not parent_ids:
56 raise osv.except_osv(_('Error'), _('No hour package container (analytic account) defined for partner %s') % so_line.order_id.partner_id.name)
57 if so_line.product_id and so_line.product_id.hour_pack:
58 if so_line.hour_pack_id:
59 raise osv.except_osv(_('Error'), _('Order line %s has hour package yet. Remove it first') % so_line.name)
60 acc_vals = {
61 'name': so_line.name + ' ['+so_line.order_id.name+'] '+ str(so_line.product_uom_qty) + ' '+ so_line.product_uom.name,
62 'partner_id': so_line.order_id.partner_id.id,
63 'quantity_max': so_line.product_uom_qty,
64 'parent_id': parent_ids[0],
65 }
66 acc_id = anal_acc_pool.create(cr, uid, acc_vals, context)
67 so_line.write({'hour_pack_id': acc_id})
68 return True
069
=== added file 'sale_hour_package/sale_view.xml'
--- sale_hour_package/sale_view.xml 1970-01-01 00:00:00 +0000
+++ sale_hour_package/sale_view.xml 2012-10-09 10:00:45 +0000
@@ -0,0 +1,21 @@
1<?xml version="1.0"?>
2<openerp>
3 <data>
4
5 <record model="ir.ui.view" id="view_order_form">
6 <field name="name">sale.order.form</field>
7 <field name="model">sale.order</field>
8 <field name="type">form</field>
9 <field name="inherit_id" ref="sale.view_order_form"/>
10 <field name="arch" type="xml">
11 <field name="address_allotment_id" position="after">
12 <newline/>
13 <field name="is_hour_pack" readonly="1"/>
14 <field name="order_state" invisible="1"/>
15 <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>
16 <field name="hour_pack_id" />
17 </field>
18 </field>
19 </record>
20 </data>
21</openerp>
022
=== added directory 'sale_layout_hour_package'
=== added file 'sale_layout_hour_package/AUTHORS.txt'
--- sale_layout_hour_package/AUTHORS.txt 1970-01-01 00:00:00 +0000
+++ sale_layout_hour_package/AUTHORS.txt 2012-10-09 10:00:45 +0000
@@ -0,0 +1,1 @@
1Lorenzo Battistini <lorenzo.battistini@domsense.com>
02
=== added file 'sale_layout_hour_package/__init__.py'
--- sale_layout_hour_package/__init__.py 1970-01-01 00:00:00 +0000
+++ sale_layout_hour_package/__init__.py 2012-10-09 10:00:45 +0000
@@ -0,0 +1,21 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2012 Domsense s.r.l. (<http://www.domsense.com>).
6# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
022
=== added file 'sale_layout_hour_package/__openerp__.py'
--- sale_layout_hour_package/__openerp__.py 1970-01-01 00:00:00 +0000
+++ sale_layout_hour_package/__openerp__.py 2012-10-09 10:00:45 +0000
@@ -0,0 +1,41 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2012 Domsense s.r.l. (<http://www.domsense.com>).
6# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23
24{
25 "name": "Sale layout hour package",
26 "version": "1.0",
27 'category': 'Generic Modules/Accounting',
28 "depends": ["sale_layout", "sale_hour_package"],
29 "author": "Agile Business Group & Domsense",
30 "description": """
31Adapting sale_hour_package to sale_layout
32 """,
33 'website': 'http://www.agilebg.com',
34 'init_xml': [],
35 'update_xml': [
36 'sale_view.xml',
37 ],
38 'demo_xml': [],
39 'installable': True,
40 'active': False,
41}
042
=== added directory 'sale_layout_hour_package/i18n'
=== added file 'sale_layout_hour_package/sale_view.xml'
--- sale_layout_hour_package/sale_view.xml 1970-01-01 00:00:00 +0000
+++ sale_layout_hour_package/sale_view.xml 2012-10-09 10:00:45 +0000
@@ -0,0 +1,21 @@
1<?xml version="1.0"?>
2<openerp>
3 <data>
4
5 <record model="ir.ui.view" id="view_order_form">
6 <field name="name">sale.order.form</field>
7 <field name="model">sale.order</field>
8 <field name="type">form</field>
9 <field name="inherit_id" ref="sale_layout.view_order_form_inherit_1"/>
10 <field name="arch" type="xml">
11 <field name="address_allotment_id" position="after">
12 <newline/>
13 <field name="is_hour_pack" readonly="1"/>
14 <field name="order_state" invisible="1"/>
15 <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>
16 <field name="hour_pack_id" />
17 </field>
18 </field>
19 </record>
20 </data>
21</openerp>

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: