Merge lp:~openbig/bigconsulting/improvement_cash_discount into lp:bigconsulting
- improvement_cash_discount
- Merge into addons
Proposed by
gpa(OpenERP)
Status: | Merged |
---|---|
Merged at revision: | 41 |
Proposed branch: | lp:~openbig/bigconsulting/improvement_cash_discount |
Merge into: | lp:bigconsulting |
Diff against target: |
190 lines (+66/-12) 4 files modified
account_invoice_cash_discount/account_invoice_cash_discount.py (+23/-0) account_invoice_cash_discount/wizard/account_pay_invoice.py (+35/-8) account_invoice_cash_discount/wizard/account_pay_invoice_view.xml (+0/-2) packing_barcode_check/wizard/scan_product.py (+8/-2) |
To merge this branch: | bzr merge lp:~openbig/bigconsulting/improvement_cash_discount |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Husen Daudi | Needs Fixing | ||
Review via email: mp+28985@code.launchpad.net |
Commit message
Description of the change
Added changes as improvement by client
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-29 13:22:59 +0000 | |||
3 | +++ account_invoice_cash_discount/account_invoice_cash_discount.py 2010-07-01 12:23:23 +0000 | |||
4 | @@ -221,6 +221,7 @@ | |||
5 | 221 | move_line = context['tax_move_ids'] | 221 | move_line = context['tax_move_ids'] |
6 | 222 | for move_line_id in move_line: | 222 | for move_line_id in move_line: |
7 | 223 | move_line_data = self.pool.get('account.move.line').browse(cr, uid,move_line_id) | 223 | move_line_data = self.pool.get('account.move.line').browse(cr, uid,move_line_id) |
8 | 224 | print "move_line_data::::::",move_line_data | ||
9 | 224 | l3 = { | 225 | l3 = { |
10 | 225 | 'debit': move_line_data.debit, | 226 | 'debit': move_line_data.debit, |
11 | 226 | 'credit': move_line_data.credit, | 227 | 'credit': move_line_data.credit, |
12 | @@ -235,6 +236,8 @@ | |||
13 | 235 | 'tax_amount':move_line_data.tax_amount, | 236 | 'tax_amount':move_line_data.tax_amount, |
14 | 236 | } | 237 | } |
15 | 237 | lines.append((0, 0, l3)) | 238 | lines.append((0, 0, l3)) |
16 | 239 | self.pool.get('account.move.line').unlink(cr, uid,[move_line_id]) | ||
17 | 240 | self.pool.get('account.move').unlink(cr, uid,[move_line_data.move_id.id]) | ||
18 | 238 | else: | 241 | else: |
19 | 239 | if amount_discount>0.0: | 242 | if amount_discount>0.0: |
20 | 240 | for line in invoice.invoice_line: | 243 | for line in invoice.invoice_line: |
21 | @@ -278,6 +281,7 @@ | |||
22 | 278 | } | 281 | } |
23 | 279 | lines.append((0, 0, l4)) | 282 | lines.append((0, 0, l4)) |
24 | 280 | 283 | ||
25 | 284 | self.pool.get('account.move').unlink(cr, uid, context['discount_move_ids']) | ||
26 | 281 | else: | 285 | else: |
27 | 282 | if amount_discount>0: | 286 | if amount_discount>0: |
28 | 283 | if 'account_id' in context and context['account_id']: | 287 | if 'account_id' in context and context['account_id']: |
29 | @@ -324,5 +328,24 @@ | |||
30 | 324 | 328 | ||
31 | 325 | account_invoice() | 329 | account_invoice() |
32 | 326 | 330 | ||
33 | 331 | class account_move_line(osv.osv): | ||
34 | 332 | _name = 'account.move.line' | ||
35 | 333 | _inherit = 'account.move.line' | ||
36 | 334 | |||
37 | 335 | def _invoice(self, cr, uid, ids, name, arg, context=None): | ||
38 | 336 | res = {} | ||
39 | 337 | if ids: | ||
40 | 338 | return super(account_move_line, self)._invoice(cr, uid, ids, name, arg, context) | ||
41 | 339 | else: | ||
42 | 340 | return res | ||
43 | 341 | |||
44 | 342 | def _invoice_search(self, cr, uid, obj, name, args, context={}): | ||
45 | 343 | return super(account_move_line, self)._invoice_search(cr, uid, obj, name, args, context=context) | ||
46 | 344 | |||
47 | 345 | _columns = { | ||
48 | 346 | 'invoice': fields.function(_invoice, method=True, string='Invoice', | ||
49 | 347 | type='many2one', relation='account.invoice', fnct_search=_invoice_search), | ||
50 | 348 | } | ||
51 | 349 | account_move_line() | ||
52 | 327 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 350 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
53 | 328 | 351 | ||
54 | 329 | 352 | ||
55 | === modified file 'account_invoice_cash_discount/wizard/account_pay_invoice.py' | |||
56 | --- account_invoice_cash_discount/wizard/account_pay_invoice.py 2010-06-29 13:22:59 +0000 | |||
57 | +++ account_invoice_cash_discount/wizard/account_pay_invoice.py 2010-07-01 12:23:23 +0000 | |||
58 | @@ -19,7 +19,7 @@ | |||
59 | 19 | # | 19 | # |
60 | 20 | ############################################################################## | 20 | ############################################################################## |
61 | 21 | import time | 21 | import time |
63 | 22 | 22 | from lxml import etree | |
64 | 23 | from osv import fields, osv | 23 | from osv import fields, osv |
65 | 24 | from tools.translate import _ | 24 | from tools.translate import _ |
66 | 25 | #import decimal_precision as dp | 25 | #import decimal_precision as dp |
67 | @@ -62,7 +62,7 @@ | |||
68 | 62 | 'journal_id': fields.many2one('account.journal', 'Journal/Payment Mode', required=True), | 62 | 'journal_id': fields.many2one('account.journal', 'Journal/Payment Mode', required=True), |
69 | 63 | 'period_id': fields.many2one('account.period', 'Period', required=True), | 63 | 'period_id': fields.many2one('account.period', 'Period', required=True), |
70 | 64 | 'cash_amount':fields.float('Cash Discount Amount',), | 64 | 'cash_amount':fields.float('Cash Discount Amount',), |
72 | 65 | 'account_id': fields.many2one('account.account', 'Account For Discount',), | 65 | 'account_id': fields.many2one('account.account', 'Customers Cash Discount Account',), |
73 | 66 | 'cal_method_selection': fields.selection([('method_gross_methodology','Calculate Discount with Net Gross Methodology'), | 66 | 'cal_method_selection': fields.selection([('method_gross_methodology','Calculate Discount with Net Gross Methodology'), |
74 | 67 | ('method_net_methodology','Calculate Discount with Net Methodology'),], | 67 | ('method_net_methodology','Calculate Discount with Net Methodology'),], |
75 | 68 | 'Method To Calculation'), | 68 | 'Method To Calculation'), |
76 | @@ -135,7 +135,7 @@ | |||
77 | 135 | invoice = self.pool.get('account.invoice').browse(cr, uid, context['id'], context=context) | 135 | invoice = self.pool.get('account.invoice').browse(cr, uid, context['id'], context=context) |
78 | 136 | tax_obj = self.pool.get('account.tax') | 136 | tax_obj = self.pool.get('account.tax') |
79 | 137 | invoice_tax_obj = self.pool.get("account.invoice.tax") | 137 | invoice_tax_obj = self.pool.get("account.invoice.tax") |
81 | 138 | 138 | ||
82 | 139 | ######## to get ref | 139 | ######## to get ref |
83 | 140 | if invoice.type in ('in_invoice', 'in_refund'): | 140 | if invoice.type in ('in_invoice', 'in_refund'): |
84 | 141 | ref = invoice.reference | 141 | ref = invoice.reference |
85 | @@ -155,7 +155,7 @@ | |||
86 | 155 | ### Entry for taxes in the line of wizard tax | 155 | ### Entry for taxes in the line of wizard tax |
87 | 156 | if data.get('cash_amount',0.0)>0.0: | 156 | if data.get('cash_amount',0.0)>0.0: |
88 | 157 | lines3 = [] | 157 | lines3 = [] |
90 | 158 | tax_total_amount = 0.0 | 158 | tax_total_amount = 0.0 |
91 | 159 | line_ids = [] | 159 | line_ids = [] |
92 | 160 | for line in invoice.invoice_line: | 160 | for line in invoice.invoice_line: |
93 | 161 | if line.invoice_line_tax_id: | 161 | if line.invoice_line_tax_id: |
94 | @@ -166,6 +166,7 @@ | |||
95 | 166 | for tax_id in tax_invoice_id: | 166 | for tax_id in tax_invoice_id: |
96 | 167 | tax_value = invoice_tax_obj.browse(cr, uid, tax_id) | 167 | tax_value = invoice_tax_obj.browse(cr, uid, tax_id) |
97 | 168 | tax_account_id = tax_value.account_id.id | 168 | tax_account_id = tax_value.account_id.id |
98 | 169 | |||
99 | 169 | l3 = { | 170 | l3 = { |
100 | 170 | 'debit': direction * tax_amount<0 and - direction * tax_amount, | 171 | 'debit': direction * tax_amount<0 and - direction * tax_amount, |
101 | 171 | 'credit': direction * tax_amount>0 and direction * tax_amount, | 172 | 'credit': direction * tax_amount>0 and direction * tax_amount, |
102 | @@ -182,16 +183,29 @@ | |||
103 | 182 | line_id = self.pool.get('account.move.line').create(cr,uid,l3,context=context) | 183 | line_id = self.pool.get('account.move.line').create(cr,uid,l3,context=context) |
104 | 183 | line_ids.append(line_id) | 184 | line_ids.append(line_id) |
105 | 184 | self.write(cr, uid, ids, {'tax_move_ids':[(6,0,line_ids)]}, context) | 185 | self.write(cr, uid, ids, {'tax_move_ids':[(6,0,line_ids)]}, context) |
107 | 185 | 186 | ||
108 | 186 | ### Entry for discount in the line of wizard discount | 187 | ### Entry for discount in the line of wizard discount |
109 | 187 | lines4 = [] | 188 | lines4 = [] |
110 | 188 | if tax_total_amount>0: | 189 | if tax_total_amount>0: |
111 | 189 | data['cash_amount'] = (data['cash_amount'] - tax_total_amount) | 190 | data['cash_amount'] = (data['cash_amount'] - tax_total_amount) |
113 | 190 | 191 | ||
114 | 192 | ############################ if method type net methology than discount account journal account | ||
115 | 193 | discount_account_id = False | ||
116 | 194 | |||
117 | 195 | if data['cal_method_selection'] == 'method_net_methodology': | ||
118 | 196 | journal_id = data['journal_id'] | ||
119 | 197 | if context['type'] == 'out_invoice': | ||
120 | 198 | discount_account_id = self.pool.get('account.journal').browse(cr, uid, journal_id).default_debit_account_id.id | ||
121 | 199 | else: | ||
122 | 200 | discount_account_id = self.pool.get('account.journal').browse(cr, uid, journal_id).default_credit_account_id.id | ||
123 | 201 | else: | ||
124 | 202 | discount_account_id = data['account_id'] | ||
125 | 203 | ###############################################3 | ||
126 | 204 | |||
127 | 191 | l4 = { | 205 | l4 = { |
128 | 192 | 'debit': direction * data.get('cash_amount',0.0)<0 and - direction * data.get('cash_amount',0.0), | 206 | 'debit': direction * data.get('cash_amount',0.0)<0 and - direction * data.get('cash_amount',0.0), |
129 | 193 | 'credit': direction * data.get('cash_amount',0.0)>0 and direction * data.get('cash_amount',0.0), | 207 | 'credit': direction * data.get('cash_amount',0.0)>0 and direction * data.get('cash_amount',0.0), |
131 | 194 | 'account_id': data['account_id'], | 208 | 'account_id': discount_account_id, |
132 | 195 | 'partner_id': invoice.partner_id.id, | 209 | 'partner_id': invoice.partner_id.id, |
133 | 196 | 'ref':ref, | 210 | 'ref':ref, |
134 | 197 | 'date': date, | 211 | 'date': date, |
135 | @@ -326,7 +340,20 @@ | |||
136 | 326 | amount, acc_id, data['period_id'], data['journal_id'], writeoff_account_id, | 340 | amount, acc_id, data['period_id'], data['journal_id'], writeoff_account_id, |
137 | 327 | data['period_id'], writeoff_journal_id, context, data['name']) | 341 | data['period_id'], writeoff_journal_id, context, data['name']) |
138 | 328 | return {} | 342 | return {} |
140 | 329 | 343 | ||
141 | 344 | def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False): | ||
142 | 345 | res = super(account_invoice_pay,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar) | ||
143 | 346 | fields=res.get('fields',{}) | ||
144 | 347 | word = "Supplier Cash Discount Account" | ||
145 | 348 | type = context.get('type',False) | ||
146 | 349 | eview = etree.fromstring(res['arch']) | ||
147 | 350 | res['arch'] = etree.tostring(eview) | ||
148 | 351 | if type == 'in_invoice': | ||
149 | 352 | for f in res['fields']: | ||
150 | 353 | if 'Customers Cash Discount Account' in res['fields'][f]['string']: | ||
151 | 354 | res['fields'][f]['string'] = res['fields'][f]['string'].replace('Customers Cash Discount Account',word) | ||
152 | 355 | return res | ||
153 | 356 | |||
154 | 330 | account_invoice_pay() | 357 | account_invoice_pay() |
155 | 331 | 358 | ||
156 | 332 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 359 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
157 | 333 | \ No newline at end of file | 360 | \ No newline at end of file |
158 | 334 | 361 | ||
159 | === modified file 'account_invoice_cash_discount/wizard/account_pay_invoice_view.xml' | |||
160 | --- account_invoice_cash_discount/wizard/account_pay_invoice_view.xml 2010-06-29 13:22:59 +0000 | |||
161 | +++ account_invoice_cash_discount/wizard/account_pay_invoice_view.xml 2010-07-01 12:23:23 +0000 | |||
162 | @@ -70,7 +70,5 @@ | |||
163 | 70 | </form> | 70 | </form> |
164 | 71 | </field> | 71 | </field> |
165 | 72 | </record> | 72 | </record> |
166 | 73 | |||
167 | 74 | |||
168 | 75 | </data> | 73 | </data> |
169 | 76 | </openerp> | 74 | </openerp> |
170 | 77 | \ No newline at end of file | 75 | \ No newline at end of file |
171 | 78 | 76 | ||
172 | === modified file 'packing_barcode_check/wizard/scan_product.py' | |||
173 | --- packing_barcode_check/wizard/scan_product.py 2010-06-29 06:24:04 +0000 | |||
174 | +++ packing_barcode_check/wizard/scan_product.py 2010-07-01 12:23:23 +0000 | |||
175 | @@ -51,8 +51,14 @@ | |||
176 | 51 | product_ean = ean_data.ean | 51 | product_ean = ean_data.ean |
177 | 52 | if product_ean == form_ean: | 52 | if product_ean == form_ean: |
178 | 53 | EAN_Found = True | 53 | EAN_Found = True |
181 | 54 | return 'scan_product_number' | 54 | |
182 | 55 | if not EAN_Found: | 55 | if EAN_Found: |
183 | 56 | if move_data.product_id.track_production: | ||
184 | 57 | return 'scan_product_number' | ||
185 | 58 | else: | ||
186 | 59 | stock_move_obj.write(cr, uid, [move_id],{'scaned_qty':move_data.scaned_qty+1}, context=context) | ||
187 | 60 | return 'init' | ||
188 | 61 | else: | ||
189 | 56 | raise osv.except_osv(_('Warning!'),('Product does not belongs to this picking or already scanned.')) | 62 | raise osv.except_osv(_('Warning!'),('Product does not belongs to this picking or already scanned.')) |
190 | 57 | return {} | 63 | return {} |
191 | 58 | 64 |
remove print statement and improve code to remove self.pool.get and make object at the starting of method.