Merge lp:~openbig/bigconsulting/milestone_v3 into lp:bigconsulting
- milestone_v3
- Merge into addons
Proposed by
gpa(OpenERP)
Status: | Merged |
---|---|
Merged at revision: | 64 |
Proposed branch: | lp:~openbig/bigconsulting/milestone_v3 |
Merge into: | lp:bigconsulting |
Diff against target: |
404 lines (+159/-52) 4 files modified
account_invoice_cash_discount/account_invoice_cash_discount.py (+80/-22) account_invoice_cash_discount/account_invoice_cash_discount_view.xml (+44/-5) account_invoice_cash_discount/wizard/account_pay_invoice.py (+23/-18) account_invoice_cash_discount/wizard/invoice_statement_payment.py (+12/-7) |
To merge this branch: | bzr merge lp:~openbig/bigconsulting/milestone_v3 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
openbig | Pending | ||
Review via email: mp+31950@code.launchpad.net |
This proposal supersedes a proposal from 2010-08-06.
Commit message
Description of the change
added changes for the milestone2
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 'account_invoice_cash_discount/account_invoice_cash_discount.py' |
2 | --- account_invoice_cash_discount/account_invoice_cash_discount.py 2010-08-05 07:53:59 +0000 |
3 | +++ account_invoice_cash_discount/account_invoice_cash_discount.py 2010-08-06 12:30:56 +0000 |
4 | @@ -323,6 +323,8 @@ |
5 | line_tax_amount = 0.0 |
6 | tax_account_id = False |
7 | tax_code_id = False |
8 | + tax_base = False |
9 | + tax_code = False |
10 | |
11 | for tax in tax_obj.compute(cr, uid, line.invoice_line_tax_id, line.price_subtotal/line.quantity, line.quantity, invoice.address_invoice_id.id, line.product_id, invoice.partner_id): |
12 | line_tax_amount += tax['amount'] |
13 | @@ -339,13 +341,11 @@ |
14 | tax_amt = discount_ratio * tax_data.amount |
15 | tax_real_amt = tax_amt / (1 + tax_data.amount) |
16 | total_tax_amount += tax_real_amt |
17 | - |
18 | - if tax_data.description: |
19 | - tax_name = tax_data.description + " - " + tax_data.name |
20 | - else: |
21 | - tax_name = tax_data.name |
22 | - |
23 | - tax_invoice_id = invoice_tax_obj.search(cr,uid,[('invoice_id','=',invoice.id),('name','=',tax_name)]) |
24 | + |
25 | + tax_base = tax_data.base_code_id.id |
26 | + tax_code = tax_data.tax_code_id.id |
27 | + tax_invoice_id = invoice_tax_obj.search(cr, uid, [('invoice_id','=',invoice.id),('tax_code_id','=',tax_code),('base_code_id','=',tax_base)]) |
28 | + |
29 | for tax_id in tax_invoice_id: |
30 | tax_value = invoice_tax_obj.browse(cr, uid, tax_id) |
31 | tax_account_id = tax_value.account_id.id |
32 | @@ -401,7 +401,8 @@ |
33 | discount_amount_currency = 0.0 |
34 | line_tax_amount = 0.0 |
35 | total_tax_amount = 0.0 |
36 | - |
37 | + tax_base = False |
38 | + tax_code = False |
39 | for tax in tax_obj.compute(cr, uid, line.invoice_line_tax_id, line.price_subtotal/line.quantity, line.quantity, invoice.address_invoice_id.id, line.product_id, invoice.partner_id): |
40 | line_tax_amount += tax['amount'] |
41 | line_total = line.price_subtotal + line_tax_amount |
42 | @@ -416,12 +417,10 @@ |
43 | tax_real_amt = tax_amt / (1 + tax_data.amount) |
44 | total_tax_amount += tax_real_amt |
45 | |
46 | - if tax_data.description: |
47 | - tax_name = tax_data.description + " - " + tax_data.name |
48 | - else: |
49 | - tax_name = tax_data.name |
50 | + tax_base = tax_data.base_code_id.id |
51 | + tax_code = tax_data.tax_code_id.id |
52 | + tax_invoice_id = invoice_tax_obj.search(cr, uid, [('invoice_id','=',invoice.id),('tax_code_id','=',tax_code),('base_code_id','=',tax_base)]) |
53 | |
54 | - tax_invoice_id = invoice_tax_obj.search(cr,uid,[('invoice_id','=',invoice.id),('name','=',tax_name)]) |
55 | for tax_id in tax_invoice_id: |
56 | tax_value = invoice_tax_obj.browse(cr, uid, tax_id) |
57 | tax_account_id = tax_value.account_id.id |
58 | @@ -481,6 +480,13 @@ |
59 | return res |
60 | account_bank_statement_reconcile() |
61 | |
62 | +class account_bank_statement_reconcile_line(osv.osv): |
63 | + _inherit='account.bank.statement.reconcile.line' |
64 | + _columns = { |
65 | + 'tax_code_id': fields.many2one('account.tax.code', 'Tax Account'), |
66 | + } |
67 | +account_bank_statement_reconcile_line() |
68 | + |
69 | class res_company(osv.osv): |
70 | _inherit = "res.company" |
71 | |
72 | @@ -581,14 +587,47 @@ |
73 | company_currency_id, move.amount, context=context, |
74 | account=acc_cur) |
75 | |
76 | - st_tax_amount = 0.00 |
77 | + st_tax_amount = 0.0 |
78 | st_base_code_id = False |
79 | + move_tax_amount = 0.0 |
80 | + tax_real_amt = 0.0 |
81 | |
82 | - if move.tax_id: |
83 | - tax = tax_obj.compute(cr, uid, [move.tax_id], move.amount, 1.00)[0] |
84 | - st_tax_amount = tax['amount'] |
85 | - st_base_code_id = tax['base_code_id'] |
86 | - |
87 | + if move.type == 'general': |
88 | + if move.tax_type == 'tax_included': |
89 | + st_tax_data = tax_obj.browse(cr, uid, move.tax_id.id, context=context) |
90 | + st_tax_amt = move.amount * st_tax_data.amount |
91 | + st_tax_amount = st_tax_amt / (1 + st_tax_data.amount) |
92 | + st_base_code_id = st_tax_data.base_code_id.id |
93 | + amount = amount - st_tax_amount |
94 | + tax_pay = st_tax_amount |
95 | + st_tax_amount = 0.0 |
96 | + |
97 | + else: |
98 | + st_tax_data = tax_obj.browse(cr, uid, move.tax_id.id, context=context) |
99 | + st_tax_amt = move.amount * st_tax_data.amount |
100 | + st_tax_amount = st_tax_amt |
101 | + tax_pay = st_tax_amount |
102 | + st_base_code_id = st_tax_data.base_code_id.id |
103 | + |
104 | + if not st_tax_data.tax_code_id.id: |
105 | + tax_val = { |
106 | + 'name': move.name, |
107 | + 'date': move.date, |
108 | + 'ref': move.ref, |
109 | + 'move_id': move_id, |
110 | + 'partner_id': ((move.partner_id) and move.partner_id.id) or False, |
111 | + 'account_id': (move.account_id) and move.account_id.id, |
112 | + 'credit': ((tax_pay>0) and tax_pay) or 0.0, |
113 | + 'debit': ((tax_pay<0) and -tax_pay) or 0.0, |
114 | + 'statement_id': st.id, |
115 | + 'journal_id': st.journal_id.id, |
116 | + 'period_id': st.period_id.id, |
117 | + 'currency_id': st.currency.id, |
118 | + 'tax_code_id':st_base_code_id, |
119 | + 'tax_amount':move_tax_amount, |
120 | + } |
121 | + torec.append(account_move_line_obj.create(cr, uid, tax_val, context=context)) |
122 | + |
123 | val = { |
124 | 'name': move.name, |
125 | 'date': move.date, |
126 | @@ -604,7 +643,7 @@ |
127 | 'currency_id': st.currency.id, |
128 | 'tax_code_id':st_base_code_id, |
129 | 'account_tax_id':move.tax_id.id, |
130 | - 'tax_amount':move.amount, |
131 | + 'tax_amount':move_tax_amount, |
132 | } |
133 | amount = res_currency_obj.compute(cr, uid, st.currency.id, |
134 | company_currency_id, move.amount, context=context, |
135 | @@ -624,7 +663,7 @@ |
136 | move.account_id.currency_id.id, amount, context=context, |
137 | account=acc_cur) |
138 | val['amount_currency'] = amount_cur |
139 | - |
140 | + |
141 | torec.append(account_move_line_obj.create(cr, uid, val, context=context)) |
142 | |
143 | newline_sum = 0.0 |
144 | @@ -641,6 +680,8 @@ |
145 | 'debit': newline.amount>0 and newline.amount or 0.0, |
146 | 'credit': newline.amount<0 and -newline.amount or 0.0, |
147 | 'statement_id': st.id, |
148 | + 'tax_code_id':newline.tax_code_id.id, |
149 | + 'tax_amount':-newline.amount, |
150 | 'journal_id': st.journal_id.id, |
151 | 'period_id': st.period_id.id, |
152 | |
153 | @@ -732,7 +773,6 @@ |
154 | 'amount_currency': amount_currency, |
155 | 'currency_id': currency_id, |
156 | }, context=context) |
157 | - |
158 | account_move_line_obj.create(cr, uid, { |
159 | 'name': move.name, |
160 | 'date': move.date, |
161 | @@ -804,10 +844,28 @@ |
162 | return False |
163 | _columns = { |
164 | 'tax_id': fields.many2one('account.tax', 'Tax'), |
165 | + 'tax_type': fields.selection([('tax_included','Tax included'), |
166 | + ('tax_excluded','Tax excluded')], |
167 | + 'Tax method', required=True,), |
168 | } |
169 | + |
170 | + def onchange_account_id(self, cr, uid, ids, account_id, context=None): |
171 | + result={} |
172 | + tax = False |
173 | + taxes = self.pool.get('account.account').browse(cr, uid, account_id, context=context).tax_ids |
174 | + for tax_id in taxes: |
175 | + tax = tax_id.id |
176 | + |
177 | + if tax: |
178 | + result['tax_id'] = tax |
179 | + else: |
180 | + result['tax_id'] = False |
181 | + |
182 | + return {'value': result} |
183 | _defaults = { |
184 | 'account_id': _get_account, |
185 | 'tax_id': _get_tax, |
186 | + 'tax_type':lambda *a :'tax_included', |
187 | } |
188 | account_bank_statement_line() |
189 | |
190 | |
191 | === modified file 'account_invoice_cash_discount/account_invoice_cash_discount_view.xml' |
192 | --- account_invoice_cash_discount/account_invoice_cash_discount_view.xml 2010-08-05 07:30:49 +0000 |
193 | +++ account_invoice_cash_discount/account_invoice_cash_discount_view.xml 2010-08-06 12:30:56 +0000 |
194 | @@ -161,6 +161,19 @@ |
195 | <field name="note">This Configuration step use to set default Account</field> |
196 | <field name="action_id" ref="action_res_company_wizard"/> |
197 | </record> |
198 | + |
199 | + |
200 | + <record model="ir.ui.view" id="view_bank_statement_reconcile_view122"> |
201 | + <field name="name">account.bank.statement.reconcile.form</field> |
202 | + <field name="model">account.bank.statement.reconcile</field> |
203 | + <field name="inherit_id" ref="account.view_bank_statement_reconcile" /> |
204 | + <field name="type">form</field> |
205 | + <field name="arch" type="xml"> |
206 | + <xpath expr="//field[@name='line_new_ids']/tree/field[@name='name']" position="after"> |
207 | + <field name="tax_code_id"/> |
208 | + </xpath> |
209 | + </field> |
210 | + </record> |
211 | |
212 | <record id="view_move_line_tree1" model="ir.ui.view"> |
213 | <field name="name">account.move.line.tree</field> |
214 | @@ -188,6 +201,19 @@ |
215 | </field> |
216 | </record> |
217 | |
218 | + <record model="ir.ui.view" id="view_bank_statement_form23233"> |
219 | + <field name="name">account.bank.statement.form1</field> |
220 | + <field name="model">account.bank.statement</field> |
221 | + <field name="inherit_id" ref="account.view_bank_statement_form" /> |
222 | + <field name="type">form</field> |
223 | + <field name="arch" type="xml"> |
224 | + <field name="account_id" position="replace"> |
225 | + <field name="account_id" on_change="onchange_account_id(account_id)"/> |
226 | + </field> |
227 | + </field> |
228 | + </record> |
229 | + |
230 | + |
231 | <record model="ir.ui.view" id="view_bank_statement_form222"> |
232 | <field name="name">account.bank.statement.tree1</field> |
233 | <field name="model">account.bank.statement</field> |
234 | @@ -196,10 +222,23 @@ |
235 | <field name="arch" type="xml"> |
236 | <xpath expr="//field[@name='line_ids']/tree/field[@name='reconcile_amount']" position="after"> |
237 | <field name="tax_id"/> |
238 | - </xpath> |
239 | - </field> |
240 | - </record> |
241 | - |
242 | - |
243 | + <field name="tax_type"/> |
244 | + </xpath> |
245 | + </field> |
246 | + </record> |
247 | + |
248 | + <record model="ir.ui.view" id="view_bank_statement_form2322"> |
249 | + <field name="name">account.bank.statement.tree1</field> |
250 | + <field name="model">account.bank.statement</field> |
251 | + <field name="inherit_id" ref="account.view_bank_statement_form" /> |
252 | + <field name="type">form</field> |
253 | + <field name="arch" type="xml"> |
254 | + <xpath expr="//field[@name='line_ids']/form/field[@name='ref']" position="after"> |
255 | + <field name="tax_type"/> |
256 | + </xpath> |
257 | + </field> |
258 | + </record> |
259 | + |
260 | + |
261 | </data> |
262 | </openerp> |
263 | |
264 | === modified file 'account_invoice_cash_discount/wizard/account_pay_invoice.py' |
265 | --- account_invoice_cash_discount/wizard/account_pay_invoice.py 2010-08-03 10:41:37 +0000 |
266 | +++ account_invoice_cash_discount/wizard/account_pay_invoice.py 2010-08-06 12:30:56 +0000 |
267 | @@ -143,6 +143,9 @@ |
268 | total_tax_amount = 0.0 |
269 | ######## |
270 | line_tax_amount = 0.0 |
271 | + tax_base = False |
272 | + tax_code = False |
273 | + |
274 | for tax in tax_obj.compute(cr, uid, line.invoice_line_tax_id, line.price_subtotal/line.quantity, line.quantity, invoice.address_invoice_id.id, line.product_id, invoice.partner_id): |
275 | line_tax_amount += tax['amount'] |
276 | line_total = line.price_subtotal + line_tax_amount |
277 | @@ -157,12 +160,11 @@ |
278 | tax_amt = discount_pay * tax_data.amount |
279 | tax_real_amt = tax_amt / (1 + tax_data.amount) |
280 | total_tax_amount += tax_real_amt |
281 | - if tax_data.description: |
282 | - tax_name = tax_data.description + " - " + tax_data.name |
283 | - else: |
284 | - tax_name = tax_data.name |
285 | + |
286 | + tax_base = tax_data.base_code_id.id |
287 | + tax_code = tax_data.tax_code_id.id |
288 | |
289 | - tax_invoice_id = invoice_tax_obj.search(cr,uid,[('invoice_id','=',invoice.id),('name','=',tax_name)]) |
290 | + tax_invoice_id = invoice_tax_obj.search(cr, uid, [('invoice_id','=',invoice.id),('tax_code_id','=',tax_code),('base_code_id','=',tax_base)]) |
291 | for tax_id in tax_invoice_id: |
292 | tax_value = invoice_tax_obj.browse(cr, uid, tax_id) |
293 | base_code_id = tax_value.base_code_id.id |
294 | @@ -211,6 +213,9 @@ |
295 | |
296 | tax_code_id = False |
297 | tax_account_id = False |
298 | + tax_base = False |
299 | + tax_code = False |
300 | + |
301 | discount = self._get_discount(cr, uid, context=context) |
302 | if discount>0.0: |
303 | for line in invoice.invoice_line: |
304 | @@ -231,13 +236,12 @@ |
305 | tax_amt = discount_pay * tax_data.amount |
306 | tax_real_amt = tax_amt / (1 + tax_data.amount) |
307 | total_tax_amount += tax_real_amt |
308 | - |
309 | - if tax_data.description: |
310 | - tax_name = tax_data.description + " - " + tax_data.name |
311 | - else: |
312 | - tax_name = tax_data.name |
313 | - |
314 | - tax_invoice_id = invoice_tax_obj.search(cr,uid,[('invoice_id','=',invoice.id),('name','=',tax_name)]) |
315 | + |
316 | + tax_base = tax_data.base_code_id.id |
317 | + tax_code = tax_data.tax_code_id.id |
318 | + |
319 | + tax_invoice_id = invoice_tax_obj.search(cr, uid, [('invoice_id','=',invoice.id),('tax_code_id','=',tax_code),('base_code_id','=',tax_base)]) |
320 | + |
321 | for tax_id in tax_invoice_id: |
322 | tax_value = invoice_tax_obj.browse(cr, uid, tax_id) |
323 | tax_account_id = tax_value.account_id.id |
324 | @@ -335,6 +339,8 @@ |
325 | tax_code_id = False |
326 | base_code_id = False |
327 | tax_account_id = False |
328 | + tax_base = False |
329 | + tax_code = False |
330 | |
331 | for line in invoice.invoice_line: |
332 | line_tax_amount = 0.0 |
333 | @@ -353,12 +359,11 @@ |
334 | tax_amt = discount_pay * tax_data.amount |
335 | tax_real_amt = tax_amt / (1 + tax_data.amount) |
336 | total_tax_amount += tax_real_amt |
337 | - if tax_data.description: |
338 | - tax_name = tax_data.description + " - " + tax_data.name |
339 | - else: |
340 | - tax_name = tax_data.name |
341 | - |
342 | - tax_invoice_id = invoice_tax_obj.search(cr, uid, [('invoice_id','=',invoice.id),('name','=',tax_name)]) |
343 | + |
344 | + tax_base = tax_data.base_code_id.id |
345 | + tax_code = tax_data.tax_code_id.id |
346 | + |
347 | + tax_invoice_id = invoice_tax_obj.search(cr, uid, [('invoice_id','=',invoice.id),('tax_code_id','=',tax_code),('base_code_id','=',tax_base)]) |
348 | for tax_id in tax_invoice_id: |
349 | tax_value = invoice_tax_obj.browse(cr, uid, tax_id) |
350 | tax_account_id = tax_value.account_id.id |
351 | |
352 | === modified file 'account_invoice_cash_discount/wizard/invoice_statement_payment.py' |
353 | --- account_invoice_cash_discount/wizard/invoice_statement_payment.py 2010-08-03 10:41:37 +0000 |
354 | +++ account_invoice_cash_discount/wizard/invoice_statement_payment.py 2010-08-06 12:30:56 +0000 |
355 | @@ -146,8 +146,11 @@ |
356 | invoice = obj_inv.browse(cursor, user, line.invoice.id, context=context) |
357 | for invoice_line in invoice.invoice_line: |
358 | line_tax_amount = 0.0 |
359 | + invoice_amount = 0.0 |
360 | total_tax_amount = 0.0 |
361 | tax_account_id = False |
362 | + tax_code_id = False |
363 | + tax_base_id = False |
364 | #####get the ratio of the line in the total invoice amount |
365 | for tax in tax_obj.compute(cursor, user, invoice_line.invoice_line_tax_id, invoice_line.price_subtotal/invoice_line.quantity, invoice_line.quantity, invoice.address_invoice_id.id, invoice_line.product_id, invoice.partner_id): |
366 | line_tax_amount += tax['amount'] |
367 | @@ -170,22 +173,23 @@ |
368 | tax_real_amt = tax_amt / (1 + tax_data.amount) |
369 | total_tax_amount += tax_real_amt |
370 | |
371 | - if tax_data.description: |
372 | - tax_name = tax_data.description + " - " + tax_data.name |
373 | - else: |
374 | - tax_name = tax_data.name |
375 | - |
376 | - tax_invoice_id = invoice_tax_obj.search(cursor, user, [('invoice_id','=',invoice.id),('name','=',tax_name)]) |
377 | + tax_base = tax_data.base_code_id.id |
378 | + tax_code = tax_data.tax_code_id.id |
379 | + |
380 | + tax_invoice_id = invoice_tax_obj.search(cursor, user, [('invoice_id','=',invoice.id),('tax_code_id','=',tax_code),('base_code_id','=',tax_base)]) |
381 | for tax_id in tax_invoice_id: |
382 | tax_value = invoice_tax_obj.browse(cursor, user, tax_id) |
383 | tax_account_id = tax_value.account_id.id |
384 | - |
385 | + tax_code_id = tax_value.tax_code_id.id |
386 | + tax_base_id = tax_value.base_code_id.id |
387 | + |
388 | if tax_real_amt>0: |
389 | statement_reconcile_line_obj.create(cursor, user, { |
390 | 'name': line.name, |
391 | 'amount': tax_real_amt, |
392 | 'account_id': tax_account_id, |
393 | 'line_id': reconcile_id, |
394 | + 'tax_code_id':tax_code_id |
395 | }, context=context) |
396 | if discount>0: |
397 | discount = discount * line_ratio |
398 | @@ -194,6 +198,7 @@ |
399 | 'amount': discount - total_tax_amount, |
400 | 'account_id': account, |
401 | 'line_id': reconcile_id, |
402 | + 'tax_code_id':tax_base_id |
403 | }, context=context) |
404 | ########################################################################## |
405 |