Merge lp:~openbig/bigconsulting/added_new_changes_in_cash_account into lp:bigconsulting
- added_new_changes_in_cash_account
- Merge into addons
Proposed by
gpa(OpenERP)
Status: | Merged |
---|---|
Merged at revision: | 26 |
Proposed branch: | lp:~openbig/bigconsulting/added_new_changes_in_cash_account |
Merge into: | lp:bigconsulting |
Diff against target: |
228 lines (+77/-32) 4 files modified
account_invoice_cash_discount/account_invoice_cash_discount.py (+47/-9) account_invoice_cash_discount/wizard/account_pay_invoice.py (+14/-8) account_invoice_cash_discount/wizard/account_pay_invoice_view.xml (+1/-1) product_ean13_generator/product_ean13_generator.py (+15/-14) |
To merge this branch: | bzr merge lp:~openbig/bigconsulting/added_new_changes_in_cash_account |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
openbig | Pending | ||
Review via email: mp+28053@code.launchpad.net |
Commit message
Description of the change
Added modification in cash discount module by client. And solve problem of product_
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-06-18 13:06:05 +0000 | |||
3 | +++ account_invoice_cash_discount/account_invoice_cash_discount.py 2010-06-21 13:43:25 +0000 | |||
4 | @@ -128,19 +128,23 @@ | |||
5 | 128 | payment_term_lines = self.pool.get('account.payment.term').browse(cr, uid, payment_term, context=context) | 128 | payment_term_lines = self.pool.get('account.payment.term').browse(cr, uid, payment_term, context=context) |
6 | 129 | if payment_term_lines.cash_discount_ids: | 129 | if payment_term_lines.cash_discount_ids: |
7 | 130 | res = 0.0 | 130 | res = 0.0 |
8 | 131 | dis = 0.0 | ||
9 | 131 | for discount_line in payment_term_lines.cash_discount_ids: | 132 | for discount_line in payment_term_lines.cash_discount_ids: |
11 | 132 | if diff_day == discount_line.delay or diff_day < discount_line.delay: | 133 | if diff_day >= dis and diff_day <= discount_line.delay: |
12 | 133 | account_id = discount_line.discount_account_id.id | 134 | account_id = discount_line.discount_account_id.id |
13 | 135 | dis = discount_line.delay | ||
14 | 134 | return account_id | 136 | return account_id |
15 | 135 | 137 | ||
16 | 136 | def pay_and_reconcile(self, cr, uid, ids, pay_amount, pay_account_id, period_id, pay_journal_id, writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context=None, name=''): | 138 | def pay_and_reconcile(self, cr, uid, ids, pay_amount, pay_account_id, period_id, pay_journal_id, writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context=None, name=''): |
17 | 137 | |||
18 | 138 | if context is None: | 139 | if context is None: |
19 | 139 | context = {} | 140 | context = {} |
20 | 140 | #TODO check if we can use different period for payment and the writeoff line | 141 | #TODO check if we can use different period for payment and the writeoff line |
21 | 141 | assert len(ids)==1, "Can only pay one invoice at a time" | 142 | assert len(ids)==1, "Can only pay one invoice at a time" |
22 | 142 | invoice = self.browse(cr, uid, ids[0]) | 143 | invoice = self.browse(cr, uid, ids[0]) |
23 | 143 | 144 | ||
24 | 145 | tax_obj = self.pool.get('account.tax') | ||
25 | 146 | invoice_tax_obj = self.pool.get("account.invoice.tax") | ||
26 | 147 | |||
27 | 144 | if 'amount_currency' in context and context['amount_currency']: | 148 | if 'amount_currency' in context and context['amount_currency']: |
28 | 145 | amount_currency = context['amount_currency'] | 149 | amount_currency = context['amount_currency'] |
29 | 146 | else: | 150 | else: |
30 | @@ -183,6 +187,7 @@ | |||
31 | 183 | 'currency_id':currency_id, | 187 | 'currency_id':currency_id, |
32 | 184 | 'amount_currency':amount_currency and direction * amount_currency or 0.0, | 188 | 'amount_currency':amount_currency and direction * amount_currency or 0.0, |
33 | 185 | } | 189 | } |
34 | 190 | |||
35 | 186 | l2 = { | 191 | l2 = { |
36 | 187 | 'debit': direction * (pay_amount-amount_discount)<0 and - direction * (pay_amount-amount_discount), | 192 | 'debit': direction * (pay_amount-amount_discount)<0 and - direction * (pay_amount-amount_discount), |
37 | 188 | 'credit': direction * (pay_amount-amount_discount)>0 and direction * (pay_amount-amount_discount), | 193 | 'credit': direction * (pay_amount-amount_discount)>0 and direction * (pay_amount-amount_discount), |
38 | @@ -199,12 +204,47 @@ | |||
39 | 199 | l1['name'] = name | 204 | l1['name'] = name |
40 | 200 | l2['name'] = name | 205 | l2['name'] = name |
41 | 201 | lines = [(0, 0, l1), (0, 0, l2)] | 206 | lines = [(0, 0, l1), (0, 0, l2)] |
42 | 207 | |||
43 | 208 | discount_amount = 0.0 | ||
44 | 209 | tax_total_amount = 0.0 | ||
45 | 210 | if 'cash_amount' in context and context['cash_amount']: | ||
46 | 211 | discount_amount = context['cash_amount'] | ||
47 | 212 | |||
48 | 213 | if discount_amount>0.0: | ||
49 | 214 | for line in invoice.invoice_line: | ||
50 | 215 | if line.invoice_line_tax_id: | ||
51 | 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): | ||
52 | 217 | tax_amount = tax['amount'] | ||
53 | 218 | tax_total_amount += tax['amount'] | ||
54 | 219 | |||
55 | 220 | tax_invoice_id = invoice_tax_obj.search(cr,uid,[('invoice_id','=',invoice.id),('name','=',tax['name'])]) | ||
56 | 221 | for tax_id in tax_invoice_id: | ||
57 | 222 | tax_value = invoice_tax_obj.browse(cr, uid, tax_id) | ||
58 | 223 | tax_account_id = tax_value.account_id.id | ||
59 | 202 | 224 | ||
60 | 225 | l3 = { | ||
61 | 226 | 'debit': direction * tax_amount<0 and - direction * tax_amount, | ||
62 | 227 | 'credit': direction * tax_amount>0 and direction * tax_amount, | ||
63 | 228 | 'account_id': tax_account_id, | ||
64 | 229 | 'partner_id': invoice.partner_id.id, | ||
65 | 230 | 'ref':ref, | ||
66 | 231 | 'date': date, | ||
67 | 232 | 'currency_id':currency_id, | ||
68 | 233 | 'amount_currency':amount_currency and direction * amount_currency or 0.0, | ||
69 | 234 | } | ||
70 | 235 | l3['name'] = name | ||
71 | 236 | lines.append((0, 0, l3)) | ||
72 | 237 | |||
73 | 203 | if amount_discount>0: | 238 | if amount_discount>0: |
74 | 204 | if 'account_id' in context and context['account_id']: | 239 | if 'account_id' in context and context['account_id']: |
78 | 205 | account_id = context['account_id'] | 240 | account_id = context['account_id'] |
79 | 206 | 241 | ||
80 | 207 | l3 = { | 242 | if tax_total_amount>0: |
81 | 243 | amount_discount = (amount_discount - tax_total_amount) | ||
82 | 244 | else: | ||
83 | 245 | amount_discount = amount_discount | ||
84 | 246 | |||
85 | 247 | l4 = { | ||
86 | 208 | 'debit': direction * amount_discount<0 and - direction * amount_discount, | 248 | 'debit': direction * amount_discount<0 and - direction * amount_discount, |
87 | 209 | 'credit': direction * amount_discount>0 and direction * amount_discount, | 249 | 'credit': direction * amount_discount>0 and direction * amount_discount, |
88 | 210 | 'account_id': account_id, | 250 | 'account_id': account_id, |
89 | @@ -214,10 +254,8 @@ | |||
90 | 214 | 'currency_id':currency_id, | 254 | 'currency_id':currency_id, |
91 | 215 | 'amount_currency':amount_currency and direction * amount_currency or 0.0, | 255 | 'amount_currency':amount_currency and direction * amount_currency or 0.0, |
92 | 216 | } | 256 | } |
97 | 217 | l3['name'] = name | 257 | l4['name'] = name |
98 | 218 | 258 | lines.append((0, 0, l4)) | |
95 | 219 | lines = [(0, 0, l1), (0, 0, l2), (0, 0, l3)] | ||
96 | 220 | |||
99 | 221 | 259 | ||
100 | 222 | move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date} | 260 | move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date} |
101 | 223 | move_id = self.pool.get('account.move').create(cr, uid, move, context=context) | 261 | move_id = self.pool.get('account.move').create(cr, uid, move, context=context) |
102 | 224 | 262 | ||
103 | === modified file 'account_invoice_cash_discount/wizard/account_pay_invoice.py' | |||
104 | --- account_invoice_cash_discount/wizard/account_pay_invoice.py 2010-06-18 13:06:05 +0000 | |||
105 | +++ account_invoice_cash_discount/wizard/account_pay_invoice.py 2010-06-21 13:43:25 +0000 | |||
106 | @@ -79,7 +79,6 @@ | |||
107 | 79 | 79 | ||
108 | 80 | def _get_amount(self, cr, uid, context=None): | 80 | def _get_amount(self, cr, uid, context=None): |
109 | 81 | residual_amount = self.pool.get('account.invoice').browse(cr, uid, context['id'], context=context).residual | 81 | residual_amount = self.pool.get('account.invoice').browse(cr, uid, context['id'], context=context).residual |
110 | 82 | residual_amount -= self._get_discount(cr, uid, context=context) | ||
111 | 83 | return residual_amount | 82 | return residual_amount |
112 | 84 | 83 | ||
113 | 85 | def on_change_ammount(self, cr, uid, ids, amount, context=None): | 84 | def on_change_ammount(self, cr, uid, ids, amount, context=None): |
114 | @@ -110,6 +109,13 @@ | |||
115 | 110 | account = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, account) | 109 | account = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, account) |
116 | 111 | return account | 110 | return account |
117 | 112 | 111 | ||
118 | 112 | def default_get(self, cr, uid, fields, context=None): | ||
119 | 113 | res = super(account_invoice_pay, self).default_get(cr, uid, fields, context=context) | ||
120 | 114 | invoice = self.pool.get('account.invoice').browse(cr, uid, context['id'], context=context) | ||
121 | 115 | if invoice.state in ['draft', 'proforma2', 'cancel']: | ||
122 | 116 | raise osv.except_osv(_('Error !'), _('Can not pay draft/proforma/cancel invoice.')) | ||
123 | 117 | return res | ||
124 | 118 | |||
125 | 113 | _defaults = { | 119 | _defaults = { |
126 | 114 | 'date': lambda *a: time.strftime('%Y-%m-%d'), | 120 | 'date': lambda *a: time.strftime('%Y-%m-%d'), |
127 | 115 | 'period_id': _get_period, | 121 | 'period_id': _get_period, |
128 | @@ -143,9 +149,9 @@ | |||
129 | 143 | # Get the current amount paid in company currency | 149 | # Get the current amount paid in company currency |
130 | 144 | if journal.currency and invoice.company_id.currency_id.id<>journal.currency.id: | 150 | if journal.currency and invoice.company_id.currency_id.id<>journal.currency.id: |
131 | 145 | ctx = {'date':data['date']} | 151 | ctx = {'date':data['date']} |
133 | 146 | amount_paid = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, data['amount']+data['cash_amount'], round=True, context=ctx) | 152 | amount_paid = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, data['amount'], round=True, context=ctx) |
134 | 147 | else: | 153 | else: |
136 | 148 | amount_paid = data['amount'] + data['cash_amount'] | 154 | amount_paid = data['amount'] |
137 | 149 | # Get the old payment if there are some | 155 | # Get the old payment if there are some |
138 | 150 | if invoice.payment_ids: | 156 | if invoice.payment_ids: |
139 | 151 | debit=credit=0.0 | 157 | debit=credit=0.0 |
140 | @@ -186,8 +192,8 @@ | |||
141 | 186 | writeoff_journal_id = context['write_off']['writeoff_journal_id'] | 192 | writeoff_journal_id = context['write_off']['writeoff_journal_id'] |
142 | 187 | comment = context['write_off']['comment'] | 193 | comment = context['write_off']['comment'] |
143 | 188 | 194 | ||
146 | 189 | amount = data['amount'] + data['cash_amount'] | 195 | amount = data['amount'] |
147 | 190 | 196 | ||
148 | 191 | invoice = self.pool.get('account.invoice').browse(cr, uid, context['id'], context=context) | 197 | invoice = self.pool.get('account.invoice').browse(cr, uid, context['id'], context=context) |
149 | 192 | journal = self.pool.get('account.journal').browse(cr, uid, data['journal_id'], context=context) | 198 | journal = self.pool.get('account.journal').browse(cr, uid, data['journal_id'], context=context) |
150 | 193 | # Compute the amount in company's currency, with the journal currency (which is equal to payment currency) | 199 | # Compute the amount in company's currency, with the journal currency (which is equal to payment currency) |
151 | @@ -197,14 +203,14 @@ | |||
152 | 197 | amount = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, amount, context=ctx) | 203 | amount = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, amount, context=ctx) |
153 | 198 | currency_id = journal.currency.id | 204 | currency_id = journal.currency.id |
154 | 199 | # Put the paid amount in currency, and the currency, in the context if currency is different from company's currency | 205 | # Put the paid amount in currency, and the currency, in the context if currency is different from company's currency |
156 | 200 | context.update({'amount_currency':data['amount'] + data['cash_amount'],'currency_id':currency_id}) | 206 | context.update({'amount_currency':data['amount'],'currency_id':currency_id}) |
157 | 201 | 207 | ||
158 | 202 | if invoice.company_id.currency_id.id<>invoice.currency_id.id: | 208 | if invoice.company_id.currency_id.id<>invoice.currency_id.id: |
159 | 203 | ctx = {'date':data['date']} | 209 | ctx = {'date':data['date']} |
160 | 204 | amount = cur_obj.compute(cr, uid, invoice.currency_id.id, invoice.company_id.currency_id.id, amount, context=ctx) | 210 | amount = cur_obj.compute(cr, uid, invoice.currency_id.id, invoice.company_id.currency_id.id, amount, context=ctx) |
161 | 205 | currency_id = invoice.currency_id.id | 211 | currency_id = invoice.currency_id.id |
162 | 206 | # Put the paid amount in currency, and the currency, in the context if currency is different from company's currency | 212 | # Put the paid amount in currency, and the currency, in the context if currency is different from company's currency |
164 | 207 | context.update({'amount_currency':data['amount'] + data['cash_amount'],'currency_id':currency_id}) | 213 | context.update({'amount_currency':data['amount'],'currency_id':currency_id}) |
165 | 208 | 214 | ||
166 | 209 | # Take the choosen date | 215 | # Take the choosen date |
167 | 210 | if comment: | 216 | if comment: |
168 | @@ -212,7 +218,7 @@ | |||
169 | 212 | else: | 218 | else: |
170 | 213 | context.update({'date_p':data['date'],'comment':False}) | 219 | context.update({'date_p':data['date'],'comment':False}) |
171 | 214 | 220 | ||
173 | 215 | context.update({'account_id':data['account_id'],'cash_amount':data['cash_amount'],'amount_currency':data['amount'] + data['cash_amount']}) | 221 | context.update({'account_id':data['account_id'],'cash_amount':data['cash_amount'],'amount_currency':data['amount']}) |
174 | 216 | 222 | ||
175 | 217 | acc_id = journal.default_credit_account_id and journal.default_credit_account_id.id | 223 | acc_id = journal.default_credit_account_id and journal.default_credit_account_id.id |
176 | 218 | if not acc_id: | 224 | if not acc_id: |
177 | 219 | 225 | ||
178 | === modified file 'account_invoice_cash_discount/wizard/account_pay_invoice_view.xml' | |||
179 | --- account_invoice_cash_discount/wizard/account_pay_invoice_view.xml 2010-08-05 13:41:54 +0000 | |||
180 | +++ account_invoice_cash_discount/wizard/account_pay_invoice_view.xml 2010-06-21 13:43:25 +0000 | |||
181 | @@ -12,7 +12,7 @@ | |||
182 | 12 | <newline/> | 12 | <newline/> |
183 | 13 | <field name="name"/> | 13 | <field name="name"/> |
184 | 14 | <field name="date"/> | 14 | <field name="date"/> |
186 | 15 | <field name="journal_id"/> | 15 | <field name="journal_id" domain="[('type','=','cash')]"/> |
187 | 16 | <field name="period_id"/> | 16 | <field name="period_id"/> |
188 | 17 | <field name="cash_amount" attrs="{'required':[('cash_amount','>',0)]}"/> | 17 | <field name="cash_amount" attrs="{'required':[('cash_amount','>',0)]}"/> |
189 | 18 | <field name="account_id" attrs="{'required':[('cash_amount','>',0)]}"/> | 18 | <field name="account_id" attrs="{'required':[('cash_amount','>',0)]}"/> |
190 | 19 | 19 | ||
191 | === modified file 'product_ean13_generator/product_ean13_generator.py' | |||
192 | --- product_ean13_generator/product_ean13_generator.py 2010-06-03 06:48:10 +0000 | |||
193 | +++ product_ean13_generator/product_ean13_generator.py 2010-06-21 13:43:25 +0000 | |||
194 | @@ -37,20 +37,21 @@ | |||
195 | 37 | raise ValueError('invalid test') | 37 | raise ValueError('invalid test') |
196 | 38 | cr.execute('select id from ir_sequence where '+test+' and active=%s', (sequence_id, True,)) | 38 | cr.execute('select id from ir_sequence where '+test+' and active=%s', (sequence_id, True,)) |
197 | 39 | res = cr.dictfetchone() | 39 | res = cr.dictfetchone() |
212 | 40 | ean_nr = self.browse(cr, uid, res['id'], context=context) | 40 | if res: |
213 | 41 | sequence = super(ir_sequence, self).get_id(cr, uid, sequence_id, test, context) | 41 | ean_nr = self.browse(cr, uid, res['id'], context=context) |
214 | 42 | code = 'generator.ean13' | 42 | sequence = super(ir_sequence, self).get_id(cr, uid, sequence_id, test, context) |
215 | 43 | 43 | code = 'generator.ean13' | |
216 | 44 | if ean_nr.code == code: | 44 | |
217 | 45 | number = ean_nr.number_max | 45 | if ean_nr.code == code: |
218 | 46 | check_seq = sequence[8:] | 46 | number = ean_nr.number_max |
219 | 47 | if check_seq >= ean_nr.warning_number: | 47 | check_seq = sequence[8:] |
220 | 48 | obj = self.pool.get("ir.actions.server") | 48 | if check_seq >= ean_nr.warning_number: |
221 | 49 | action_name = "EAN Generator Action" | 49 | obj = self.pool.get("ir.actions.server") |
222 | 50 | id = obj.search(cr, uid, [('name',"ilike",action_name)]) | 50 | action_name = "EAN Generator Action" |
223 | 51 | context.update({'active_id':res['id']}) | 51 | id = obj.search(cr, uid, [('name',"ilike",action_name)]) |
224 | 52 | obj.run(cr, uid, id, context) | 52 | context.update({'active_id':res['id']}) |
225 | 53 | return sequence | 53 | obj.run(cr, uid, id, context) |
226 | 54 | return sequence | ||
227 | 54 | 55 | ||
228 | 55 | ir_sequence() | 56 | ir_sequence() |
229 | 56 | 57 |