Merge lp:~openerp-community-testers/openobject-addons/trunk-bug1048305 into lp:openobject-addons

Proposed by Stéphane Bidoul (Acsone)
Status: Merged
Merged at revision: 7896
Proposed branch: lp:~openerp-community-testers/openobject-addons/trunk-bug1048305
Merge into: lp:openobject-addons
Diff against target: 246 lines (+161/-7)
4 files modified
hr_timesheet_invoice/__openerp__.py (+1/-0)
hr_timesheet_invoice/test/test_hr_timesheet_invoice.yml (+37/-3)
hr_timesheet_invoice/test/test_hr_timesheet_invoice_no_prod_tax.yml (+120/-0)
hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py (+3/-4)
To merge this branch: bzr merge lp:~openerp-community-testers/openobject-addons/trunk-bug1048305
Reviewer Review Type Date Requested Status
qdp (OpenERP) Pending
Review via email: mp+132073@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hr_timesheet_invoice/__openerp__.py'
2--- hr_timesheet_invoice/__openerp__.py 2012-09-26 12:16:27 +0000
3+++ hr_timesheet_invoice/__openerp__.py 2012-10-30 14:57:23 +0000
4@@ -50,6 +50,7 @@
5 ],
6 'demo': ['hr_timesheet_invoice_demo.xml'],
7 'test': ['test/test_hr_timesheet_invoice.yml',
8+ 'test/test_hr_timesheet_invoice_no_prod_tax.yml',
9 'test/hr_timesheet_invoice_report.yml',
10 ],
11 'installable': True,
12
13=== modified file 'hr_timesheet_invoice/test/test_hr_timesheet_invoice.yml'
14--- hr_timesheet_invoice/test/test_hr_timesheet_invoice.yml 2012-07-26 11:39:14 +0000
15+++ hr_timesheet_invoice/test/test_hr_timesheet_invoice.yml 2012-10-30 14:57:23 +0000
16@@ -30,6 +30,42 @@
17 -
18 !python {model: hr.analytic.timesheet}: |
19 self.on_change_account_id(cr, uid, [ref('account_analytic_line_developyamlforhrmodule0')], ref('account.analytic_agrolait'))
20+
21+-
22+ I create a Tax Codes
23+-
24+ !record {model: account.tax.code, id: tax_case}:
25+ name: Tax_case
26+ company_id: base.main_company
27+ sign: 1
28+-
29+ I create a Tax
30+-
31+ !record {model: account.tax, id: tax10}:
32+ name: Tax 10.0
33+ amount: 10.0
34+ type: fixed
35+ sequence: 1
36+ company_id: base.main_company
37+ type_tax_use: all
38+ tax_code_id: tax_case
39+-
40+ I create an Account with the tax
41+-
42+ !record {model: account.account, id: account_income_i000}:
43+ name: "income account"
44+ code: "I000"
45+ type: 'other'
46+ user_type: "account.data_account_type_income"
47+ tax_ids: [tax10]
48+-
49+ I set the account as property_account_income on the product and I set the tax on the product
50+-
51+ !record {model: product.product, id: product.product_product_consultant}:
52+ property_account_income: account_income_i000
53+ uom_id: product.product_uom_hour
54+ taxes_id: [tax10]
55+ list_price: 75
56 -
57 I create invoice on analytic Line using "Invoice analytic Line" wizard.
58 -
59@@ -39,13 +75,11 @@
60 price: 1
61 product: product.product_product_consultant
62 time: 1
63-
64 -
65 I click on "Create Invoice" button of "Invoice analytic Line" wizard to create invoice.
66 -
67 !python {model: hr.timesheet.invoice.create}: |
68 self.do_create(cr, uid, [ref("hr_timesheet_invoice_create_0")], {"active_ids": [ref("hr_timesheet_invoice.account_analytic_line_developyamlforhrmodule0")]})
69-
70 -
71 I check that Invoice is created for this timesheet.
72 -
73@@ -67,8 +101,8 @@
74 assert product == product_exp
75 assert aline.invoice_id, "Invoice created, but analytic line wasn't updated."
76 assert aline.invoice_id == invoice_id, "Invoice doesn't match the one at analytic line"
77- # The expected amount is hard coded here, please keep updated:
78 assert invoice_id.amount_untaxed == 187.5, "Invoice amount mismatch: %s" % invoice_id.amount_untaxed
79+ assert invoice_id.amount_tax == 50, "Invoice tax mismatch: %s" % invoice_id.amount_tax
80 -
81 I create final invoice for this analytic account.
82 -
83
84=== added file 'hr_timesheet_invoice/test/test_hr_timesheet_invoice_no_prod_tax.yml'
85--- hr_timesheet_invoice/test/test_hr_timesheet_invoice_no_prod_tax.yml 1970-01-01 00:00:00 +0000
86+++ hr_timesheet_invoice/test/test_hr_timesheet_invoice_no_prod_tax.yml 2012-10-30 14:57:23 +0000
87@@ -0,0 +1,120 @@
88+-
89+ In order to test hr_timesheet_invoice in OpenERP, I create account line to manage invoice based on costs.
90+-
91+ I create an account analytic line.
92+-
93+ !record {model: account.analytic.line, id: account_analytic_line_developyamlforhrmodule1 }:
94+ account_id: account.analytic_agrolait
95+ amount: -1.0
96+ general_account_id: account.a_expense
97+ journal_id: hr_timesheet.analytic_journal
98+ name: develop yaml for hr module
99+ product_id: product.product_product_consultant
100+ product_uom_id: product.product_uom_hour
101+ to_invoice: hr_timesheet_invoice.timesheet_invoice_factor2
102+ unit_amount: 5.00
103+-
104+ Assign partner name and price list in analytic account.
105+-
106+ !record {model: account.analytic.account, id: account.analytic_agrolait}:
107+ partner_id: base.res_partner_2
108+ pricelist_id: product.list0
109+-
110+ I open this account and make the state as pending.
111+-
112+ !python {model: account.analytic.account}: |
113+ self.set_open(cr, uid, [ref('account.analytic_agrolait')], None)
114+ self.set_pending(cr, uid, [ref('account.analytic_agrolait')], None)
115+-
116+ I assign account on analytic account line.
117+-
118+ !python {model: hr.analytic.timesheet}: |
119+ self.on_change_account_id(cr, uid, [ref('account_analytic_line_developyamlforhrmodule1')], ref('account.analytic_agrolait'))
120+
121+-
122+ I create a Tax Codes
123+-
124+ !record {model: account.tax.code, id: tax_case}:
125+ name: Tax_case
126+ company_id: base.main_company
127+ sign: 1
128+-
129+ I create a Tax
130+-
131+ !record {model: account.tax, id: tax8}:
132+ name: Tax 8.0
133+ amount: 8.0
134+ type: fixed
135+ sequence: 1
136+ company_id: base.main_company
137+ type_tax_use: all
138+ tax_code_id: tax_case
139+-
140+ I create an Account with the taxt
141+-
142+ !record {model: account.account, id: account_income_i000}:
143+ name: "income account"
144+ code: "I000"
145+ type: 'other'
146+ user_type: "account.data_account_type_income"
147+ tax_ids: [tax8]
148+-
149+ I set the account as property_account_income on the product and I set no tax on the product (so default tax from the account will be used)
150+-
151+ !record {model: product.product, id: product.product_product_consultant}:
152+ property_account_income: account_income_i000
153+ uom_id: product.product_uom_hour
154+ taxes_id: []
155+ list_price: 75
156+-
157+ I create invoice on analytic Line using "Invoice analytic Line" wizard.
158+-
159+ !record {model: hr.timesheet.invoice.create, id: hr_timesheet_invoice_create_0}:
160+ date: 1
161+ name: 1
162+ price: 1
163+ product: product.product_product_consultant
164+ time: 1
165+-
166+ I click on "Create Invoice" button of "Invoice analytic Line" wizard to create invoice.
167+-
168+ !python {model: hr.timesheet.invoice.create}: |
169+ self.do_create(cr, uid, [ref("hr_timesheet_invoice_create_0")], {"active_ids": [ref("hr_timesheet_invoice.account_analytic_line_developyamlforhrmodule1")]})
170+-
171+ I check that Invoice is created for this timesheet.
172+-
173+ !python {model: account.analytic.line}: |
174+ aline = self.browse(cr, uid, ref('account_analytic_line_developyamlforhrmodule1'))
175+ analytic_account_obj = self.pool.get('account.analytic.account')
176+ data = self.pool.get('hr.timesheet.invoice.create').read(cr, uid, [ref("hr_timesheet_invoice_create_0")], [], context)[0]
177+ partner = aline.account_id.partner_id.id
178+
179+ invoice_obj = self.pool.get('account.invoice')
180+ invoice_ids = invoice_obj.search(cr, uid, [('partner_id', '=', partner)])
181+ invoice_id = invoice_obj.browse(cr, uid, invoice_ids)[0]
182+
183+ for invoice in invoice_id.invoice_line:
184+ product = invoice.product_id.id
185+
186+ product_exp = data['product'][0]
187+
188+ assert product == product_exp
189+ assert aline.invoice_id, "Invoice created, but analytic line wasn't updated."
190+ assert aline.invoice_id == invoice_id, "Invoice doesn't match the one at analytic line"
191+ assert invoice_id.amount_untaxed == 187.5, "Invoice amount mismatch: %s" % invoice_id.amount_untaxed
192+ assert invoice_id.amount_tax == 40, "Invoice tax mismatch: %s" % invoice_id.amount_tax
193+-
194+ I create final invoice for this analytic account.
195+-
196+ !record {model: hr.timesheet.invoice.create.final, id: hr_timesheet_invoice_create_final_0}:
197+ date: 1
198+ name: 1
199+ price: 1
200+ time: 1
201+-
202+ I click on "Create Invoice" button to create Invoice and validate the invoice.
203+-
204+ !python {model: hr.timesheet.invoice.create.final}: |
205+ import netsvc
206+ wkf_service = netsvc.LocalService("workflow")
207+ res = self.do_create(cr, uid, [ref("hr_timesheet_invoice_create_final_0")], {"active_ids": [ref("account.analytic_agrolait")]})
208
209=== modified file 'hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py'
210--- hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py 2012-10-28 15:15:37 +0000
211+++ hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py 2012-10-30 14:57:23 +0000
212@@ -49,7 +49,6 @@
213 # }
214 def invoice_cost_create(self, cr, uid, ids, data=None, context=None):
215 analytic_account_obj = self.pool.get('account.analytic.account')
216- res_partner_obj = self.pool.get('res.partner')
217 account_payment_term_obj = self.pool.get('account.payment.term')
218 invoice_obj = self.pool.get('account.invoice')
219 product_obj = self.pool.get('product.product')
220@@ -115,7 +114,7 @@
221
222 for product_id, user_id, factor_id, qty, uom, line_name in cr.fetchall():
223 if data.get('product'):
224- product_id = data['product'][0]
225+ product_id = data['product'][0]
226 product = product_obj.browse(cr, uid, product_id, context=context2)
227 if not product:
228 raise osv.except_osv(_('Error!'), _('There is no product defined for the line %s. Please select one or force the product through the wizard.') % (line_name))
229@@ -132,7 +131,7 @@
230 general_account = product.product_tmpl_id.property_account_income or product.categ_id.property_account_income_categ
231 if not general_account:
232 raise osv.except_osv(_("Configuration Error!"), _("Please define income account for product '%s'.") % product.name)
233- taxes = product.taxes_id
234+ taxes = product.taxes_id or general_account.tax_ids
235 tax = fiscal_pos_obj.map_tax(cr, uid, account.partner_id.property_account_position, taxes)
236 curr_line = {
237 'price_unit': price,
238@@ -211,7 +210,7 @@
239 data = context and context.get('active_ids', [])
240 for analytic in analytic_obj.browse(cr, uid, data, context=context):
241 if analytic.invoice_id:
242- raise osv.except_osv(_('Warning!'), _("Invoice is already linked to some of the analytic line(s)!"))
243+ raise osv.except_osv(_('Warning!'), _("Invoice is already linked to some of the analytic line(s)!"))
244
245 def do_create(self, cr, uid, ids, context=None):
246 data = self.read(cr, uid, ids, [], context=context)[0]

Subscribers

People subscribed via source and target branches

to all changes: