Merge lp:~openbig/bigconsulting/milestone_changes into lp:bigconsulting
- milestone_changes
- Merge into addons
Proposed by
gpa(OpenERP)
Status: | Merged |
---|---|
Merged at revision: | 36 |
Proposed branch: | lp:~openbig/bigconsulting/milestone_changes |
Merge into: | lp:bigconsulting |
Diff against target: |
535 lines (+273/-71) (has conflicts) 8 files modified
account_invoice_cash_discount/__init__.py (+2/-1) account_invoice_cash_discount/__terp__.py (+4/-0) account_invoice_cash_discount/account_invoice_cash_discount.py (+94/-50) account_invoice_cash_discount/account_invoice_cash_discount_view.xml (+40/-0) account_invoice_cash_discount/wizard/__init__.py (+1/-0) account_invoice_cash_discount/wizard/account_pay_invoice.py (+115/-16) account_invoice_cash_discount/wizard/account_pay_invoice_view.xml (+15/-2) packing_barcode_check/report/bar_code_check.rml (+2/-2) Text conflict in account_invoice_cash_discount/__terp__.py |
To merge this branch: | bzr merge lp:~openbig/bigconsulting/milestone_changes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
openbig | Pending | ||
Review via email: mp+28748@code.launchpad.net |
Commit message
Description of the change
Added changes as milestone1
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/__init__.py' | |||
2 | --- account_invoice_cash_discount/__init__.py 2010-05-26 13:32:15 +0000 | |||
3 | +++ account_invoice_cash_discount/__init__.py 2010-06-29 13:29:23 +0000 | |||
4 | @@ -20,7 +20,8 @@ | |||
5 | 20 | # | 20 | # |
6 | 21 | ############################################################################## | 21 | ############################################################################## |
7 | 22 | 22 | ||
8 | 23 | import wizard | ||
9 | 23 | import account_invoice_cash_discount | 24 | import account_invoice_cash_discount |
11 | 24 | import wizard | 25 | |
12 | 25 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 26 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
13 | 26 | 27 | ||
14 | 27 | 28 | ||
15 | === modified file 'account_invoice_cash_discount/__terp__.py' | |||
16 | --- account_invoice_cash_discount/__terp__.py 2010-06-24 10:49:42 +0000 | |||
17 | +++ account_invoice_cash_discount/__terp__.py 2010-06-29 13:29:23 +0000 | |||
18 | @@ -34,7 +34,11 @@ | |||
19 | 34 | "demo_xml" : [ | 34 | "demo_xml" : [ |
20 | 35 | ], | 35 | ], |
21 | 36 | "update_xml" : [ | 36 | "update_xml" : [ |
22 | 37 | <<<<<<< TREE | ||
23 | 37 | "security/ir.model.access.csv", | 38 | "security/ir.model.access.csv", |
24 | 39 | ======= | ||
25 | 40 | "account_invoice_cash_discount_wizard.xml", | ||
26 | 41 | >>>>>>> MERGE-SOURCE | ||
27 | 38 | "account_invoice_cash_discount_view.xml", | 42 | "account_invoice_cash_discount_view.xml", |
28 | 39 | 'wizard/account_pay_invoice_view.xml', | 43 | 'wizard/account_pay_invoice_view.xml', |
29 | 40 | ], | 44 | ], |
30 | 41 | 45 | ||
31 | === modified file 'account_invoice_cash_discount/account_invoice_cash_discount.py' | |||
32 | --- account_invoice_cash_discount/account_invoice_cash_discount.py 2010-08-17 13:38:00 +0000 | |||
33 | +++ account_invoice_cash_discount/account_invoice_cash_discount.py 2010-06-29 13:29:23 +0000 | |||
34 | @@ -175,7 +175,14 @@ | |||
35 | 175 | if invoice.type in ('in_invoice', 'in_refund'): | 175 | if invoice.type in ('in_invoice', 'in_refund'): |
36 | 176 | ref = invoice.reference | 176 | ref = invoice.reference |
37 | 177 | else: | 177 | else: |
39 | 178 | ref = self._convert_ref(cr, uid, invoice.number) | 178 | ref = self._convert_ref(cr, uid, invoice.number) |
40 | 179 | |||
41 | 180 | discount_amount = 0.0 | ||
42 | 181 | tax_total_amount = 0.0 | ||
43 | 182 | |||
44 | 183 | if 'cash_amount' in context and context['cash_amount']: | ||
45 | 184 | discount_amount = context['cash_amount'] | ||
46 | 185 | |||
47 | 179 | # Pay attention to the sign for both debit/credit AND amount_currency | 186 | # Pay attention to the sign for both debit/credit AND amount_currency |
48 | 180 | l1 = { | 187 | l1 = { |
49 | 181 | 'debit': direction * (pay_amount)>0 and direction * (pay_amount), | 188 | 'debit': direction * (pay_amount)>0 and direction * (pay_amount), |
50 | @@ -187,7 +194,11 @@ | |||
51 | 187 | 'currency_id':currency_id, | 194 | 'currency_id':currency_id, |
52 | 188 | 'amount_currency':amount_currency and direction * amount_currency or 0.0, | 195 | 'amount_currency':amount_currency and direction * amount_currency or 0.0, |
53 | 189 | } | 196 | } |
55 | 190 | 197 | ||
56 | 198 | ### if we change the amount paid and in the disocunt then it used the changes discount | ||
57 | 199 | if amount_discount != discount_amount and discount_amount>0.0: | ||
58 | 200 | amount_discount = discount_amount | ||
59 | 201 | |||
60 | 191 | l2 = { | 202 | l2 = { |
61 | 192 | 'debit': direction * (pay_amount-amount_discount)<0 and - direction * (pay_amount-amount_discount), | 203 | 'debit': direction * (pay_amount-amount_discount)<0 and - direction * (pay_amount-amount_discount), |
62 | 193 | 'credit': direction * (pay_amount-amount_discount)>0 and direction * (pay_amount-amount_discount), | 204 | 'credit': direction * (pay_amount-amount_discount)>0 and direction * (pay_amount-amount_discount), |
63 | @@ -201,74 +212,107 @@ | |||
64 | 201 | 212 | ||
65 | 202 | if not name: | 213 | if not name: |
66 | 203 | name = invoice.invoice_line and invoice.invoice_line[0].name or invoice.number | 214 | name = invoice.invoice_line and invoice.invoice_line[0].name or invoice.number |
67 | 215 | |||
68 | 204 | l1['name'] = name | 216 | l1['name'] = name |
69 | 205 | l2['name'] = name | 217 | l2['name'] = name |
70 | 206 | lines = [(0, 0, l1), (0, 0, l2)] | 218 | lines = [(0, 0, l1), (0, 0, l2)] |
71 | 207 | 219 | ||
96 | 208 | discount_amount = 0.0 | 220 | if 'tax_move_ids' in context and context['tax_move_ids']: |
97 | 209 | tax_total_amount = 0.0 | 221 | move_line = context['tax_move_ids'] |
98 | 210 | if 'cash_amount' in context and context['cash_amount']: | 222 | for move_line_id in move_line: |
99 | 211 | discount_amount = context['cash_amount'] | 223 | move_line_data = self.pool.get('account.move.line').browse(cr, uid,move_line_id) |
100 | 212 | 224 | l3 = { | |
101 | 213 | if discount_amount>0.0: | 225 | 'debit': move_line_data.debit, |
102 | 214 | for line in invoice.invoice_line: | 226 | 'credit': move_line_data.credit, |
103 | 215 | if line.invoice_line_tax_id: | 227 | 'account_id': move_line_data.account_id.id, |
104 | 216 | for tax in tax_obj.compute(cr, uid, line.invoice_line_tax_id, discount_amount, line.quantity, invoice.address_invoice_id.id, line.product_id, invoice.partner_id): | 228 | 'partner_id': move_line_data.partner_id.id, |
105 | 217 | tax_amount = tax['amount'] | 229 | 'ref':move_line_data.ref, |
106 | 218 | tax_total_amount += tax['amount'] | 230 | 'date': move_line_data.date, |
107 | 219 | 231 | 'currency_id':currency_id, | |
108 | 220 | tax_invoice_id = invoice_tax_obj.search(cr,uid,[('invoice_id','=',invoice.id),('name','=',tax['name'])]) | 232 | 'amount_currency':amount_currency and direction * amount_currency or 0.0, |
109 | 221 | for tax_id in tax_invoice_id: | 233 | 'name':move_line_data.name, |
110 | 222 | tax_value = invoice_tax_obj.browse(cr, uid, tax_id) | 234 | 'tax_code_id':move_line_data.tax_code_id.id, |
111 | 223 | tax_account_id = tax_value.account_id.id | 235 | 'tax_amount':move_line_data.tax_amount, |
112 | 224 | 236 | } | |
113 | 225 | l3 = { | 237 | lines.append((0, 0, l3)) |
114 | 226 | 'debit': direction * tax_amount<0 and - direction * tax_amount, | 238 | else: |
115 | 227 | 'credit': direction * tax_amount>0 and direction * tax_amount, | 239 | if amount_discount>0.0: |
116 | 228 | 'account_id': tax_account_id, | 240 | for line in invoice.invoice_line: |
117 | 229 | 'partner_id': invoice.partner_id.id, | 241 | if line.invoice_line_tax_id: |
118 | 230 | 'ref':ref, | 242 | for tax in tax_obj.compute(cr, uid, line.invoice_line_tax_id, amount_discount, line.quantity, invoice.address_invoice_id.id, line.product_id, invoice.partner_id): |
119 | 231 | 'date': date, | 243 | tax_amount = tax['amount'] |
120 | 244 | tax_total_amount += tax['amount'] | ||
121 | 245 | tax_invoice_id = invoice_tax_obj.search(cr,uid,[('invoice_id','=',invoice.id),('name','=',tax['name'])]) | ||
122 | 246 | for tax_id in tax_invoice_id: | ||
123 | 247 | tax_value = invoice_tax_obj.browse(cr, uid, tax_id) | ||
124 | 248 | tax_account_id = tax_value.account_id.id | ||
125 | 249 | l3 = { | ||
126 | 250 | 'debit': direction * tax_amount<0 and - direction * tax_amount, | ||
127 | 251 | 'credit': direction * tax_amount>0 and direction * tax_amount, | ||
128 | 252 | 'account_id': tax_account_id, | ||
129 | 253 | 'partner_id': invoice.partner_id.id, | ||
130 | 254 | 'ref':ref, | ||
131 | 255 | 'date': date, | ||
132 | 256 | 'currency_id':currency_id, | ||
133 | 257 | 'amount_currency':amount_currency and direction * amount_currency or 0.0, | ||
134 | 258 | 'tax_code_id':tax_value.tax_code_id.id, | ||
135 | 259 | 'tax_amount':tax_amount, | ||
136 | 260 | } | ||
137 | 261 | l3['name'] = name | ||
138 | 262 | lines.append((0, 0, l3)) | ||
139 | 263 | |||
140 | 264 | if 'discount_move_ids' in context and context['discount_move_ids']: | ||
141 | 265 | dis_move_id = context['discount_move_ids'][0] | ||
142 | 266 | move_id = self.pool.get('account.move.line').search(cr, uid,[('move_id','=',dis_move_id)]) | ||
143 | 267 | move_line_data = self.pool.get('account.move.line').browse(cr, uid, move_id[0]) | ||
144 | 268 | l4 = { | ||
145 | 269 | 'debit': move_line_data.debit, | ||
146 | 270 | 'credit':move_line_data.credit, | ||
147 | 271 | 'account_id': move_line_data.account_id.id, | ||
148 | 272 | 'partner_id': move_line_data.partner_id.id, | ||
149 | 273 | 'ref':move_line_data.ref, | ||
150 | 274 | 'date': move_line_data.date, | ||
151 | 232 | 'currency_id':currency_id, | 275 | 'currency_id':currency_id, |
152 | 233 | 'amount_currency':amount_currency and direction * amount_currency or 0.0, | 276 | 'amount_currency':amount_currency and direction * amount_currency or 0.0, |
153 | 277 | 'name':move_line_data.name, | ||
154 | 234 | } | 278 | } |
155 | 235 | l3['name'] = name | ||
156 | 236 | lines.append((0, 0, l3)) | ||
157 | 237 | |||
158 | 238 | if amount_discount>0: | ||
159 | 239 | if 'account_id' in context and context['account_id']: | ||
160 | 240 | account_id = context['account_id'] | ||
161 | 241 | |||
162 | 242 | if tax_total_amount>0: | ||
163 | 243 | amount_discount = (amount_discount - tax_total_amount) | ||
164 | 244 | else: | ||
165 | 245 | amount_discount = amount_discount | ||
166 | 246 | |||
167 | 247 | l4 = { | ||
168 | 248 | 'debit': direction * amount_discount<0 and - direction * amount_discount, | ||
169 | 249 | 'credit': direction * amount_discount>0 and direction * amount_discount, | ||
170 | 250 | 'account_id': account_id, | ||
171 | 251 | 'partner_id': invoice.partner_id.id, | ||
172 | 252 | 'ref':ref, | ||
173 | 253 | 'date': date, | ||
174 | 254 | 'currency_id':currency_id, | ||
175 | 255 | 'amount_currency':amount_currency and direction * amount_currency or 0.0, | ||
176 | 256 | } | ||
177 | 257 | l4['name'] = name | ||
178 | 258 | lines.append((0, 0, l4)) | 279 | lines.append((0, 0, l4)) |
179 | 280 | |||
180 | 281 | else: | ||
181 | 282 | if amount_discount>0: | ||
182 | 283 | if 'account_id' in context and context['account_id']: | ||
183 | 284 | account_id = context['account_id'] | ||
184 | 285 | if tax_total_amount>0: | ||
185 | 286 | amount_discount = (amount_discount - tax_total_amount) | ||
186 | 287 | else: | ||
187 | 288 | amount_discount = amount_discount | ||
188 | 289 | l4 = { | ||
189 | 290 | 'debit': direction * amount_discount<0 and - direction * amount_discount, | ||
190 | 291 | 'credit': direction * amount_discount>0 and direction * amount_discount, | ||
191 | 292 | 'account_id': account_id, | ||
192 | 293 | 'partner_id': invoice.partner_id.id, | ||
193 | 294 | 'ref':ref, | ||
194 | 295 | 'date': date, | ||
195 | 296 | 'currency_id':currency_id, | ||
196 | 297 | 'amount_currency':amount_currency and direction * amount_currency or 0.0, | ||
197 | 298 | } | ||
198 | 299 | l4['name'] = name | ||
199 | 300 | lines.append((0, 0, l4)) | ||
200 | 259 | 301 | ||
201 | 260 | move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date} | 302 | move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date} |
202 | 261 | move_id = self.pool.get('account.move').create(cr, uid, move, context=context) | 303 | move_id = self.pool.get('account.move').create(cr, uid, move, context=context) |
204 | 262 | 304 | ||
205 | 263 | line_ids = [] | 305 | line_ids = [] |
206 | 264 | total = 0.0 | 306 | total = 0.0 |
207 | 265 | line = self.pool.get('account.move.line') | 307 | line = self.pool.get('account.move.line') |
208 | 266 | cr.execute('select id from account_move_line where move_id in ('+str(move_id)+','+str(invoice.move_id.id)+')') | 308 | cr.execute('select id from account_move_line where move_id in ('+str(move_id)+','+str(invoice.move_id.id)+')') |
209 | 309 | |||
210 | 267 | lines = line.browse(cr, uid, map(lambda x: x[0], cr.fetchall()) ) | 310 | lines = line.browse(cr, uid, map(lambda x: x[0], cr.fetchall()) ) |
211 | 268 | for l in lines+invoice.payment_ids: | 311 | for l in lines+invoice.payment_ids: |
212 | 269 | if l.account_id.id==src_account_id: | 312 | if l.account_id.id==src_account_id: |
213 | 270 | line_ids.append(l.id) | 313 | line_ids.append(l.id) |
214 | 271 | total += (l.debit or 0.0) - (l.credit or 0.0) | 314 | total += (l.debit or 0.0) - (l.credit or 0.0) |
215 | 315 | |||
216 | 272 | if (not round(total,int(config['price_accuracy']))) or writeoff_acc_id: | 316 | if (not round(total,int(config['price_accuracy']))) or writeoff_acc_id: |
217 | 273 | self.pool.get('account.move.line').reconcile(cr, uid, line_ids, 'manual', writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context) | 317 | self.pool.get('account.move.line').reconcile(cr, uid, line_ids, 'manual', writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context) |
218 | 274 | else: | 318 | else: |
219 | 275 | 319 | ||
220 | === modified file 'account_invoice_cash_discount/account_invoice_cash_discount_view.xml' | |||
221 | --- account_invoice_cash_discount/account_invoice_cash_discount_view.xml 2010-06-01 05:48:55 +0000 | |||
222 | +++ account_invoice_cash_discount/account_invoice_cash_discount_view.xml 2010-06-29 13:29:23 +0000 | |||
223 | @@ -45,5 +45,45 @@ | |||
224 | 45 | </field> | 45 | </field> |
225 | 46 | </record> | 46 | </record> |
226 | 47 | 47 | ||
227 | 48 | <record id="bank_statement_form_view1" model="ir.ui.view"> | ||
228 | 49 | <field name="name">account.bank.statement.form</field> | ||
229 | 50 | <field name="model">account.bank.statement</field> | ||
230 | 51 | <field name="type">form</field> | ||
231 | 52 | <field name="inherit_id" ref="account.view_bank_statement_form"/> | ||
232 | 53 | <field name="arch" type="xml"> | ||
233 | 54 | <xpath expr="//button[@string='Import Invoice']" position="replace"> | ||
234 | 55 | <button name="%(wizard_populate_statement_from_inv1)d" type="action" string="Import Invoice" attrs="{'invisible':[('state','=','confirm')]}"/> | ||
235 | 56 | </xpath> | ||
236 | 57 | </field> | ||
237 | 58 | </record> | ||
238 | 59 | |||
239 | 60 | <record id="bank_statement_reconcile_form_view1" model="ir.ui.view"> | ||
240 | 61 | <field name="name">account.bank.statement.reconcile.form</field> | ||
241 | 62 | <field name="model">account.bank.statement.reconcile</field> | ||
242 | 63 | <field name="type">form</field> | ||
243 | 64 | <field name="inherit_id" ref="account.view_bank_statement_reconcile"/> | ||
244 | 65 | <field name="arch" type="xml"> | ||
245 | 66 | <field name="total_new" position="replace"> | ||
246 | 67 | <field name="total_new" string="Total Write Off / Cash Discount"/> | ||
247 | 68 | </field> | ||
248 | 69 | </field> | ||
249 | 70 | </record> | ||
250 | 71 | |||
251 | 72 | <record id="bank_statement_reconcile_form_view2" model="ir.ui.view"> | ||
252 | 73 | <field name="name">account.bank.statement.reconcile.form</field> | ||
253 | 74 | <field name="model">account.bank.statement.reconcile</field> | ||
254 | 75 | <field name="type">form</field> | ||
255 | 76 | <field name="inherit_id" ref="account.view_bank_statement_reconcile"/> | ||
256 | 77 | <field name="arch" type="xml"> | ||
257 | 78 | <xpath expr="//tree[@string='Write-Off']" position="replace"> | ||
258 | 79 | <tree editable="bottom" string="Write-Off and Cash-Discount"> | ||
259 | 80 | <field name="account_id" domain="[('type','<>','view'),('type','<>','consolidation')]"/> | ||
260 | 81 | <field name="amount"/> | ||
261 | 82 | <field name="name"/> | ||
262 | 83 | </tree> | ||
263 | 84 | </xpath> | ||
264 | 85 | </field> | ||
265 | 86 | </record> | ||
266 | 87 | |||
267 | 48 | </data> | 88 | </data> |
268 | 49 | </openerp> | 89 | </openerp> |
269 | 50 | 90 | ||
270 | === modified file 'account_invoice_cash_discount/wizard/__init__.py' | |||
271 | --- account_invoice_cash_discount/wizard/__init__.py 2010-06-01 05:48:55 +0000 | |||
272 | +++ account_invoice_cash_discount/wizard/__init__.py 2010-06-29 13:29:23 +0000 | |||
273 | @@ -21,6 +21,7 @@ | |||
274 | 21 | ############################################################################## | 21 | ############################################################################## |
275 | 22 | 22 | ||
276 | 23 | import account_pay_invoice | 23 | import account_pay_invoice |
277 | 24 | import invoice_statement_payment | ||
278 | 24 | 25 | ||
279 | 25 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 26 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
280 | 26 | 27 | ||
281 | 27 | 28 | ||
282 | === modified file 'account_invoice_cash_discount/wizard/account_pay_invoice.py' | |||
283 | --- account_invoice_cash_discount/wizard/account_pay_invoice.py 2010-08-17 13:38:00 +0000 | |||
284 | +++ account_invoice_cash_discount/wizard/account_pay_invoice.py 2010-06-29 13:29:23 +0000 | |||
285 | @@ -58,18 +58,18 @@ | |||
286 | 58 | 'amount': fields.float('Amount paid', required=True), | 58 | 'amount': fields.float('Amount paid', required=True), |
287 | 59 | 'name': fields.char('Entry Name', size=64, required=True), | 59 | 'name': fields.char('Entry Name', size=64, required=True), |
288 | 60 | 'date': fields.date('Date payment', required=True), | 60 | 'date': fields.date('Date payment', required=True), |
289 | 61 | 'cash_residual_amount': fields.float('Residual Amount', readonly=True), | ||
290 | 61 | 'journal_id': fields.many2one('account.journal', 'Journal/Payment Mode', required=True), | 62 | 'journal_id': fields.many2one('account.journal', 'Journal/Payment Mode', required=True), |
291 | 62 | 'period_id': fields.many2one('account.period', 'Period', required=True), | 63 | 'period_id': fields.many2one('account.period', 'Period', required=True), |
292 | 63 | 'cash_amount':fields.float('Cash Discount Amount',), | 64 | 'cash_amount':fields.float('Cash Discount Amount',), |
293 | 64 | 'account_id': fields.many2one('account.account', 'Account For Discount',), | 65 | 'account_id': fields.many2one('account.account', 'Account For Discount',), |
294 | 66 | 'cal_method_selection': fields.selection([('method_gross_methodology','Calculate Discount with Net Gross Methodology'), | ||
295 | 67 | ('method_net_methodology','Calculate Discount with Net Methodology'),], | ||
296 | 68 | 'Method To Calculation'), | ||
297 | 69 | 'discount_move_ids': fields.many2many('account.move', 'account_discount_move_rel', 'discount_account_id', 'discount_move_id', 'Account Discount Moves'), | ||
298 | 70 | 'tax_move_ids': fields.many2many('account.move.line', 'account_tax_move_rel', 'tax_account_id', 'tax_move_id', 'Account Taxes Moves'), | ||
299 | 65 | } | 71 | } |
300 | 66 | 72 | ||
301 | 67 | def view_init(self, cr, uid, ids, context=None): | ||
302 | 68 | invoice = self.pool.get('account.invoice').browse(cr, uid, context['active_id'], context=context) | ||
303 | 69 | if invoice.state in ['draft', 'proforma2', 'cancel']: | ||
304 | 70 | raise osv.except_osv(_('Error !'), _('Can not pay draft/proforma/cancel invoice.')) | ||
305 | 71 | pass | ||
306 | 72 | |||
307 | 73 | def _get_period(self, cr, uid, context=None): | 73 | def _get_period(self, cr, uid, context=None): |
308 | 74 | ids = self.pool.get('account.period').find(cr, uid, context=context) | 74 | ids = self.pool.get('account.period').find(cr, uid, context=context) |
309 | 75 | period_id = False | 75 | period_id = False |
310 | @@ -78,7 +78,10 @@ | |||
311 | 78 | return period_id | 78 | return period_id |
312 | 79 | 79 | ||
313 | 80 | def _get_amount(self, cr, uid, context=None): | 80 | def _get_amount(self, cr, uid, context=None): |
315 | 81 | residual_amount = self.pool.get('account.invoice').browse(cr, uid, context['id'], context=context).residual | 81 | obj_inv = self.pool.get('account.invoice') |
316 | 82 | invoice = obj_inv.browse(cr, uid, context['id'], context=context) | ||
317 | 83 | discount = obj_inv._get_payment(cr, uid, [context['id']] ,invoice.residual, invoice.payment_term.id, context=context) | ||
318 | 84 | residual_amount = invoice.residual - discount | ||
319 | 82 | return residual_amount | 85 | return residual_amount |
320 | 83 | 86 | ||
321 | 84 | def on_change_ammount(self, cr, uid, ids, amount, context=None): | 87 | def on_change_ammount(self, cr, uid, ids, amount, context=None): |
322 | @@ -88,8 +91,18 @@ | |||
323 | 88 | res = {} | 91 | res = {} |
324 | 89 | obj_inv = self.pool.get('account.invoice') | 92 | obj_inv = self.pool.get('account.invoice') |
325 | 90 | invoice = obj_inv.browse(cr, uid, context['id'], context=context) | 93 | invoice = obj_inv.browse(cr, uid, context['id'], context=context) |
328 | 91 | discount = obj_inv._get_payment(cr, uid, [context['id']] , amount, invoice.payment_term.id, context=context) | 94 | discount = obj_inv._get_payment(cr, uid, [context['id']] , invoice.residual, invoice.payment_term.id, context=context) |
329 | 92 | return {'value' : {'cash_amount':discount}} | 95 | diff_amount = round(invoice.residual - (amount + discount),2) |
330 | 96 | return {'value' : {'cash_residual_amount':diff_amount}} | ||
331 | 97 | |||
332 | 98 | def on_change_cash_discount_amount(self, cr, uid, ids, discount_amount, amount, context=None): | ||
333 | 99 | ### Return discount amount | ||
334 | 100 | res = {} | ||
335 | 101 | obj_inv = self.pool.get('account.invoice') | ||
336 | 102 | invoice = obj_inv.browse(cr, uid, context['id'], context=context) | ||
337 | 103 | diff_amount = 0.0 | ||
338 | 104 | diff_amount = round(invoice.residual - (amount + discount_amount),2) | ||
339 | 105 | return {'value' : {'cash_amount':discount_amount,'cash_residual_amount':diff_amount}} | ||
340 | 93 | 106 | ||
341 | 94 | def _get_discount(self, cr, uid, context=None): | 107 | def _get_discount(self, cr, uid, context=None): |
342 | 95 | obj_inv = self.pool.get('account.invoice') | 108 | obj_inv = self.pool.get('account.invoice') |
343 | @@ -116,12 +129,89 @@ | |||
344 | 116 | raise osv.except_osv(_('Error !'), _('Can not pay draft/proforma/cancel invoice.')) | 129 | raise osv.except_osv(_('Error !'), _('Can not pay draft/proforma/cancel invoice.')) |
345 | 117 | return res | 130 | return res |
346 | 118 | 131 | ||
347 | 132 | def _calculation(self, cr, uid, ids, context=None): | ||
348 | 133 | invoice_obj = self.pool.get('account.invoice') | ||
349 | 134 | data = self.read(cr, uid, ids,context=context)[0] | ||
350 | 135 | invoice = self.pool.get('account.invoice').browse(cr, uid, context['id'], context=context) | ||
351 | 136 | tax_obj = self.pool.get('account.tax') | ||
352 | 137 | invoice_tax_obj = self.pool.get("account.invoice.tax") | ||
353 | 138 | |||
354 | 139 | ######## to get ref | ||
355 | 140 | if invoice.type in ('in_invoice', 'in_refund'): | ||
356 | 141 | ref = invoice.reference | ||
357 | 142 | else: | ||
358 | 143 | ref = invoice_obj._convert_ref(cr, uid, invoice.number) | ||
359 | 144 | |||
360 | 145 | #### to get direction | ||
361 | 146 | types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1} | ||
362 | 147 | direction = types[invoice.type] | ||
363 | 148 | date=time.strftime('%Y-%m-%d') | ||
364 | 149 | |||
365 | 150 | #### to get name | ||
366 | 151 | name = invoice.invoice_line and invoice.invoice_line[0].name or invoice.number | ||
367 | 152 | |||
368 | 153 | ##### Entry in the discount account moves and entry in the tax account moves | ||
369 | 154 | |||
370 | 155 | ### Entry for taxes in the line of wizard tax | ||
371 | 156 | if data.get('cash_amount',0.0)>0.0: | ||
372 | 157 | lines3 = [] | ||
373 | 158 | tax_total_amount = 0.0 | ||
374 | 159 | line_ids = [] | ||
375 | 160 | for line in invoice.invoice_line: | ||
376 | 161 | if line.invoice_line_tax_id: | ||
377 | 162 | for tax in tax_obj.compute(cr, uid, line.invoice_line_tax_id, data['cash_amount'], line.quantity, invoice.address_invoice_id.id, line.product_id, invoice.partner_id): | ||
378 | 163 | tax_amount = tax['amount'] | ||
379 | 164 | tax_total_amount += tax['amount'] | ||
380 | 165 | tax_invoice_id = invoice_tax_obj.search(cr,uid,[('invoice_id','=',invoice.id),('name','=',tax['name'])]) | ||
381 | 166 | for tax_id in tax_invoice_id: | ||
382 | 167 | tax_value = invoice_tax_obj.browse(cr, uid, tax_id) | ||
383 | 168 | tax_account_id = tax_value.account_id.id | ||
384 | 169 | l3 = { | ||
385 | 170 | 'debit': direction * tax_amount<0 and - direction * tax_amount, | ||
386 | 171 | 'credit': direction * tax_amount>0 and direction * tax_amount, | ||
387 | 172 | 'account_id': tax_account_id, | ||
388 | 173 | 'partner_id': invoice.partner_id.id, | ||
389 | 174 | 'ref':ref, | ||
390 | 175 | 'date': date, | ||
391 | 176 | 'journal_id':data.get('journal_id',False) , | ||
392 | 177 | 'period_id':data.get('period_id',False), | ||
393 | 178 | 'name':name, | ||
394 | 179 | 'tax_code_id':tax_value.tax_code_id.id, | ||
395 | 180 | 'tax_amount':tax_amount, | ||
396 | 181 | } | ||
397 | 182 | line_id = self.pool.get('account.move.line').create(cr,uid,l3,context=context) | ||
398 | 183 | line_ids.append(line_id) | ||
399 | 184 | self.write(cr, uid, ids, {'tax_move_ids':[(6,0,line_ids)]}, context) | ||
400 | 185 | |||
401 | 186 | ### Entry for discount in the line of wizard discount | ||
402 | 187 | lines4 = [] | ||
403 | 188 | if tax_total_amount>0: | ||
404 | 189 | data['cash_amount'] = (data['cash_amount'] - tax_total_amount) | ||
405 | 190 | |||
406 | 191 | l4 = { | ||
407 | 192 | 'debit': direction * data.get('cash_amount',0.0)<0 and - direction * data.get('cash_amount',0.0), | ||
408 | 193 | 'credit': direction * data.get('cash_amount',0.0)>0 and direction * data.get('cash_amount',0.0), | ||
409 | 194 | 'account_id': data['account_id'], | ||
410 | 195 | 'partner_id': invoice.partner_id.id, | ||
411 | 196 | 'ref':ref, | ||
412 | 197 | 'date': date, | ||
413 | 198 | 'name':name | ||
414 | 199 | } | ||
415 | 200 | |||
416 | 201 | lines4.append((0, 0, l4)) | ||
417 | 202 | move = {'ref': ref, 'line_id': lines4, 'journal_id': data['journal_id'], 'period_id': data['period_id'], } | ||
418 | 203 | move_id = self.pool.get('account.move').create(cr, uid, move, context=context) | ||
419 | 204 | self.write(cr, uid, ids, {'discount_move_ids':[(6,0,[move_id])]}, context) | ||
420 | 205 | return True | ||
421 | 206 | |||
422 | 119 | _defaults = { | 207 | _defaults = { |
423 | 120 | 'date': lambda *a: time.strftime('%Y-%m-%d'), | 208 | 'date': lambda *a: time.strftime('%Y-%m-%d'), |
424 | 121 | 'period_id': _get_period, | 209 | 'period_id': _get_period, |
425 | 122 | 'amount': _get_amount, | 210 | 'amount': _get_amount, |
426 | 123 | 'cash_amount':_get_discount, | 211 | 'cash_amount':_get_discount, |
428 | 124 | 'account_id':_get_account | 212 | 'account_id':_get_account, |
429 | 213 | 'cash_residual_amount': lambda *a:0.0, | ||
430 | 214 | 'cal_method_selection':lambda *a :'method_gross_methodology', | ||
431 | 125 | } | 215 | } |
432 | 126 | 216 | ||
433 | 127 | def wo_check(self, cr, uid, ids, context=None): | 217 | def wo_check(self, cr, uid, ids, context=None): |
434 | @@ -186,13 +276,13 @@ | |||
435 | 186 | writeoff_account_id = False | 276 | writeoff_account_id = False |
436 | 187 | writeoff_journal_id = False | 277 | writeoff_journal_id = False |
437 | 188 | comment = False | 278 | comment = False |
439 | 189 | 279 | ||
440 | 190 | if 'write_off' in context and context['write_off'] : | 280 | if 'write_off' in context and context['write_off'] : |
441 | 191 | writeoff_account_id = context['write_off']['writeoff_acc_id'] | 281 | writeoff_account_id = context['write_off']['writeoff_acc_id'] |
442 | 192 | writeoff_journal_id = context['write_off']['writeoff_journal_id'] | 282 | writeoff_journal_id = context['write_off']['writeoff_journal_id'] |
443 | 193 | comment = context['write_off']['comment'] | 283 | comment = context['write_off']['comment'] |
444 | 194 | 284 | ||
446 | 195 | amount = data['amount'] | 285 | amount = data['amount'] + data['cash_amount'] |
447 | 196 | 286 | ||
448 | 197 | invoice = self.pool.get('account.invoice').browse(cr, uid, context['id'], context=context) | 287 | invoice = self.pool.get('account.invoice').browse(cr, uid, context['id'], context=context) |
449 | 198 | journal = self.pool.get('account.journal').browse(cr, uid, data['journal_id'], context=context) | 288 | journal = self.pool.get('account.journal').browse(cr, uid, data['journal_id'], context=context) |
450 | @@ -203,14 +293,14 @@ | |||
451 | 203 | amount = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, amount, context=ctx) | 293 | amount = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, amount, context=ctx) |
452 | 204 | currency_id = journal.currency.id | 294 | currency_id = journal.currency.id |
453 | 205 | # Put the paid amount in currency, and the currency, in the context if currency is different from company's currency | 295 | # Put the paid amount in currency, and the currency, in the context if currency is different from company's currency |
455 | 206 | context.update({'amount_currency':data['amount'],'currency_id':currency_id}) | 296 | context.update({'amount_currency':data['amount'] + data['cash_amount'],'currency_id':currency_id}) |
456 | 207 | 297 | ||
457 | 208 | if invoice.company_id.currency_id.id<>invoice.currency_id.id: | 298 | if invoice.company_id.currency_id.id<>invoice.currency_id.id: |
458 | 209 | ctx = {'date':data['date']} | 299 | ctx = {'date':data['date']} |
459 | 210 | amount = cur_obj.compute(cr, uid, invoice.currency_id.id, invoice.company_id.currency_id.id, amount, context=ctx) | 300 | amount = cur_obj.compute(cr, uid, invoice.currency_id.id, invoice.company_id.currency_id.id, amount, context=ctx) |
460 | 211 | currency_id = invoice.currency_id.id | 301 | currency_id = invoice.currency_id.id |
461 | 212 | # Put the paid amount in currency, and the currency, in the context if currency is different from company's currency | 302 | # Put the paid amount in currency, and the currency, in the context if currency is different from company's currency |
463 | 213 | context.update({'amount_currency':data['amount'],'currency_id':currency_id}) | 303 | context.update({'amount_currency':data['amount'] + data['cash_amount'],'currency_id':currency_id}) |
464 | 214 | 304 | ||
465 | 215 | # Take the choosen date | 305 | # Take the choosen date |
466 | 216 | if comment: | 306 | if comment: |
467 | @@ -218,8 +308,17 @@ | |||
468 | 218 | else: | 308 | else: |
469 | 219 | context.update({'date_p':data['date'],'comment':False}) | 309 | context.update({'date_p':data['date'],'comment':False}) |
470 | 220 | 310 | ||
473 | 221 | context.update({'account_id':data['account_id'],'cash_amount':data['cash_amount'],'amount_currency':data['amount']}) | 311 | context.update({'account_id':data['account_id'],'cash_amount':data['cash_amount'],'amount_currency':data['amount'] + data['cash_amount']}) |
474 | 222 | 312 | ||
475 | 313 | if data['discount_move_ids']: | ||
476 | 314 | context.update({'discount_move_ids':data['discount_move_ids']}) | ||
477 | 315 | |||
478 | 316 | if data['tax_move_ids']: | ||
479 | 317 | context.update({'tax_move_ids':data['tax_move_ids']}) | ||
480 | 318 | |||
481 | 319 | if data['cash_amount']: | ||
482 | 320 | context.update({'cash_amount':data['cash_amount']}) | ||
483 | 321 | |||
484 | 223 | acc_id = journal.default_credit_account_id and journal.default_credit_account_id.id | 322 | acc_id = journal.default_credit_account_id and journal.default_credit_account_id.id |
485 | 224 | if not acc_id: | 323 | if not acc_id: |
486 | 225 | raise osv.except_osv(_('Error !'), _('Your journal must have a default credit and debit account.')) | 324 | raise osv.except_osv(_('Error !'), _('Your journal must have a default credit and debit account.')) |
487 | 226 | 325 | ||
488 | === modified file 'account_invoice_cash_discount/wizard/account_pay_invoice_view.xml' | |||
489 | --- account_invoice_cash_discount/wizard/account_pay_invoice_view.xml 2010-08-17 13:38:00 +0000 | |||
490 | +++ account_invoice_cash_discount/wizard/account_pay_invoice_view.xml 2010-06-29 13:29:23 +0000 | |||
491 | @@ -9,14 +9,27 @@ | |||
492 | 9 | <form string="Pay invoice"> | 9 | <form string="Pay invoice"> |
493 | 10 | <group colspan="4" > | 10 | <group colspan="4" > |
494 | 11 | <field name="amount" on_change="on_change_ammount(amount,context)"/> | 11 | <field name="amount" on_change="on_change_ammount(amount,context)"/> |
496 | 12 | <newline/> | 12 | <field name="cash_residual_amount"/> |
497 | 13 | <field name="name"/> | 13 | <field name="name"/> |
498 | 14 | <field name="date"/> | 14 | <field name="date"/> |
499 | 15 | <field name="journal_id" domain="[('type','=','cash')]"/> | 15 | <field name="journal_id" domain="[('type','=','cash')]"/> |
500 | 16 | <field name="period_id"/> | 16 | <field name="period_id"/> |
502 | 17 | <field name="cash_amount" attrs="{'required':[('cash_amount','>',0)]}"/> | 17 | <field name="cash_amount" on_change="on_change_cash_discount_amount(cash_amount,amount,context)" attrs="{'required':[('cash_amount','>',0)]}"/> |
503 | 18 | <field name="account_id" attrs="{'required':[('cash_amount','>',0)]}"/> | 18 | <field name="account_id" attrs="{'required':[('cash_amount','>',0)]}"/> |
504 | 19 | </group> | 19 | </group> |
505 | 20 | <group> | ||
506 | 21 | <separator string="Method For Calculation" colspan="4"/> | ||
507 | 22 | <field name="cal_method_selection" colspan="4" nolabel="1"/> | ||
508 | 23 | <button icon="gtk-execute" string="Calculate" name="_calculation" type="object"/> | ||
509 | 24 | </group> | ||
510 | 25 | <group colspan="4"> | ||
511 | 26 | <separator string="Account Discount Moves" colspan="4"/> | ||
512 | 27 | <field name="discount_move_ids" widget="one2many_list" nolabel="1"/> | ||
513 | 28 | </group> | ||
514 | 29 | <group colspan="4"> | ||
515 | 30 | <separator string="Account Taxes Moves" colspan="4"/> | ||
516 | 31 | <field name="tax_move_ids" widget="one2many_list" nolabel="1"/> | ||
517 | 32 | </group> | ||
518 | 20 | <group colspan="4" col="6"> | 33 | <group colspan="4" col="6"> |
519 | 21 | <label string ="" colspan="2"/> | 34 | <label string ="" colspan="2"/> |
520 | 22 | <button icon="gtk-cancel" special="cancel" string="Cancel"/> | 35 | <button icon="gtk-cancel" special="cancel" string="Cancel"/> |
521 | 23 | 36 | ||
522 | === modified file 'packing_barcode_check/report/bar_code_check.rml' | |||
523 | --- packing_barcode_check/report/bar_code_check.rml 2010-06-24 12:19:20 +0000 | |||
524 | +++ packing_barcode_check/report/bar_code_check.rml 2010-06-29 13:29:23 +0000 | |||
525 | @@ -1,8 +1,8 @@ | |||
526 | 1 | <?xml version="1.0"?> | 1 | <?xml version="1.0"?> |
527 | 2 | <document filename="test.pdf"> | 2 | <document filename="test.pdf"> |
529 | 3 | <template pageSize="(320.0,210.0)" rightMargin="0.0cm" title="Test" author="Martin Simon" allowSplitting="20"> | 3 | <template pageSize="(235.0,210.0)" rightMargin="0.0cm" title="Test" author="Martin Simon" allowSplitting="20"> |
530 | 4 | <pageTemplate id="first"> | 4 | <pageTemplate id="first"> |
532 | 5 | <frame id="first" x1="1.5cm" y1="0.0cm" width="320.0" height="210"/> | 5 | <frame id="first" x1="65.0" y1="0.0" width="235.0" height="210"/> |
533 | 6 | </pageTemplate> | 6 | </pageTemplate> |
534 | 7 | </template> | 7 | </template> |
535 | 8 | <stylesheet> | 8 | <stylesheet> |