Merge lp:~openbig/bigconsulting/improvement_cash_discount into lp:bigconsulting

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
Reviewer Review Type Date Requested Status
Husen Daudi Needs Fixing
Review via email: mp+28985@code.launchpad.net

Description of the change

Added changes as improvement by client

To post a comment you must log in.
Revision history for this message
Husen Daudi (husendaudi) wrote :

remove print statement and improve code to remove self.pool.get and make object at the starting of method.

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'account_invoice_cash_discount/account_invoice_cash_discount.py'
--- account_invoice_cash_discount/account_invoice_cash_discount.py 2010-06-29 13:22:59 +0000
+++ account_invoice_cash_discount/account_invoice_cash_discount.py 2010-07-01 12:23:23 +0000
@@ -221,6 +221,7 @@
221 move_line = context['tax_move_ids']221 move_line = context['tax_move_ids']
222 for move_line_id in move_line:222 for move_line_id in move_line:
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)
224 print "move_line_data::::::",move_line_data
224 l3 = {225 l3 = {
225 'debit': move_line_data.debit,226 'debit': move_line_data.debit,
226 'credit': move_line_data.credit,227 'credit': move_line_data.credit,
@@ -235,6 +236,8 @@
235 'tax_amount':move_line_data.tax_amount,236 'tax_amount':move_line_data.tax_amount,
236 }237 }
237 lines.append((0, 0, l3))238 lines.append((0, 0, l3))
239 self.pool.get('account.move.line').unlink(cr, uid,[move_line_id])
240 self.pool.get('account.move').unlink(cr, uid,[move_line_data.move_id.id])
238 else:241 else:
239 if amount_discount>0.0: 242 if amount_discount>0.0:
240 for line in invoice.invoice_line:243 for line in invoice.invoice_line:
@@ -278,6 +281,7 @@
278 }281 }
279 lines.append((0, 0, l4))282 lines.append((0, 0, l4))
280 283
284 self.pool.get('account.move').unlink(cr, uid, context['discount_move_ids'])
281 else:285 else:
282 if amount_discount>0:286 if amount_discount>0:
283 if 'account_id' in context and context['account_id']:287 if 'account_id' in context and context['account_id']:
@@ -324,5 +328,24 @@
324 328
325account_invoice()329account_invoice()
326330
331class account_move_line(osv.osv):
332 _name = 'account.move.line'
333 _inherit = 'account.move.line'
334
335 def _invoice(self, cr, uid, ids, name, arg, context=None):
336 res = {}
337 if ids:
338 return super(account_move_line, self)._invoice(cr, uid, ids, name, arg, context)
339 else:
340 return res
341
342 def _invoice_search(self, cr, uid, obj, name, args, context={}):
343 return super(account_move_line, self)._invoice_search(cr, uid, obj, name, args, context=context)
344
345 _columns = {
346 'invoice': fields.function(_invoice, method=True, string='Invoice',
347 type='many2one', relation='account.invoice', fnct_search=_invoice_search),
348 }
349account_move_line()
327# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:350# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
328351
329352
=== modified file 'account_invoice_cash_discount/wizard/account_pay_invoice.py'
--- account_invoice_cash_discount/wizard/account_pay_invoice.py 2010-06-29 13:22:59 +0000
+++ account_invoice_cash_discount/wizard/account_pay_invoice.py 2010-07-01 12:23:23 +0000
@@ -19,7 +19,7 @@
19#19#
20##############################################################################20##############################################################################
21import time21import time
2222from lxml import etree
23from osv import fields, osv23from osv import fields, osv
24from tools.translate import _24from tools.translate import _
25#import decimal_precision as dp25#import decimal_precision as dp
@@ -62,7 +62,7 @@
62 'journal_id': fields.many2one('account.journal', 'Journal/Payment Mode', required=True),62 'journal_id': fields.many2one('account.journal', 'Journal/Payment Mode', required=True),
63 'period_id': fields.many2one('account.period', 'Period', required=True),63 'period_id': fields.many2one('account.period', 'Period', required=True),
64 'cash_amount':fields.float('Cash Discount Amount',),64 'cash_amount':fields.float('Cash Discount Amount',),
65 'account_id': fields.many2one('account.account', 'Account For Discount',),65 'account_id': fields.many2one('account.account', 'Customers Cash Discount Account',),
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'),
67 ('method_net_methodology','Calculate Discount with Net Methodology'),],67 ('method_net_methodology','Calculate Discount with Net Methodology'),],
68 'Method To Calculation'),68 'Method To Calculation'),
@@ -135,7 +135,7 @@
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)
136 tax_obj = self.pool.get('account.tax')136 tax_obj = self.pool.get('account.tax')
137 invoice_tax_obj = self.pool.get("account.invoice.tax")137 invoice_tax_obj = self.pool.get("account.invoice.tax")
138138
139 ######## to get ref139 ######## to get ref
140 if invoice.type in ('in_invoice', 'in_refund'):140 if invoice.type in ('in_invoice', 'in_refund'):
141 ref = invoice.reference141 ref = invoice.reference
@@ -155,7 +155,7 @@
155 ### Entry for taxes in the line of wizard tax155 ### Entry for taxes in the line of wizard tax
156 if data.get('cash_amount',0.0)>0.0:156 if data.get('cash_amount',0.0)>0.0:
157 lines3 = []157 lines3 = []
158 tax_total_amount = 0.0 158 tax_total_amount = 0.0
159 line_ids = [] 159 line_ids = []
160 for line in invoice.invoice_line:160 for line in invoice.invoice_line:
161 if line.invoice_line_tax_id:161 if line.invoice_line_tax_id:
@@ -166,6 +166,7 @@
166 for tax_id in tax_invoice_id:166 for tax_id in tax_invoice_id:
167 tax_value = invoice_tax_obj.browse(cr, uid, tax_id)167 tax_value = invoice_tax_obj.browse(cr, uid, tax_id)
168 tax_account_id = tax_value.account_id.id168 tax_account_id = tax_value.account_id.id
169
169 l3 = {170 l3 = {
170 'debit': direction * tax_amount<0 and - direction * tax_amount,171 'debit': direction * tax_amount<0 and - direction * tax_amount,
171 'credit': direction * tax_amount>0 and direction * tax_amount,172 'credit': direction * tax_amount>0 and direction * tax_amount,
@@ -182,16 +183,29 @@
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)
183 line_ids.append(line_id)184 line_ids.append(line_id)
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)
185186
186 ### Entry for discount in the line of wizard discount187 ### Entry for discount in the line of wizard discount
187 lines4 = []188 lines4 = []
188 if tax_total_amount>0:189 if tax_total_amount>0:
189 data['cash_amount'] = (data['cash_amount'] - tax_total_amount)190 data['cash_amount'] = (data['cash_amount'] - tax_total_amount)
190 191
192 ############################ if method type net methology than discount account journal account
193 discount_account_id = False
194
195 if data['cal_method_selection'] == 'method_net_methodology':
196 journal_id = data['journal_id']
197 if context['type'] == 'out_invoice':
198 discount_account_id = self.pool.get('account.journal').browse(cr, uid, journal_id).default_debit_account_id.id
199 else:
200 discount_account_id = self.pool.get('account.journal').browse(cr, uid, journal_id).default_credit_account_id.id
201 else:
202 discount_account_id = data['account_id']
203 ###############################################3
204
191 l4 = {205 l4 = {
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),
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),
194 'account_id': data['account_id'],208 'account_id': discount_account_id,
195 'partner_id': invoice.partner_id.id,209 'partner_id': invoice.partner_id.id,
196 'ref':ref,210 'ref':ref,
197 'date': date,211 'date': date,
@@ -326,7 +340,20 @@
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,
327 data['period_id'], writeoff_journal_id, context, data['name'])341 data['period_id'], writeoff_journal_id, context, data['name'])
328 return {}342 return {}
329343
344 def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False):
345 res = super(account_invoice_pay,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar)
346 fields=res.get('fields',{})
347 word = "Supplier Cash Discount Account"
348 type = context.get('type',False)
349 eview = etree.fromstring(res['arch'])
350 res['arch'] = etree.tostring(eview)
351 if type == 'in_invoice':
352 for f in res['fields']:
353 if 'Customers Cash Discount Account' in res['fields'][f]['string']:
354 res['fields'][f]['string'] = res['fields'][f]['string'].replace('Customers Cash Discount Account',word)
355 return res
356
330account_invoice_pay()357account_invoice_pay()
331358
332# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:359# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
333\ No newline at end of file360\ No newline at end of file
334361
=== modified file 'account_invoice_cash_discount/wizard/account_pay_invoice_view.xml'
--- account_invoice_cash_discount/wizard/account_pay_invoice_view.xml 2010-06-29 13:22:59 +0000
+++ account_invoice_cash_discount/wizard/account_pay_invoice_view.xml 2010-07-01 12:23:23 +0000
@@ -70,7 +70,5 @@
70 </form>70 </form>
71 </field>71 </field>
72 </record>72 </record>
73
74
75 </data>73 </data>
76</openerp>74</openerp>
77\ No newline at end of file75\ No newline at end of file
7876
=== modified file 'packing_barcode_check/wizard/scan_product.py'
--- packing_barcode_check/wizard/scan_product.py 2010-06-29 06:24:04 +0000
+++ packing_barcode_check/wizard/scan_product.py 2010-07-01 12:23:23 +0000
@@ -51,8 +51,14 @@
51 product_ean = ean_data.ean51 product_ean = ean_data.ean
52 if product_ean == form_ean:52 if product_ean == form_ean:
53 EAN_Found = True53 EAN_Found = True
54 return 'scan_product_number'54
55 if not EAN_Found:55 if EAN_Found:
56 if move_data.product_id.track_production:
57 return 'scan_product_number'
58 else:
59 stock_move_obj.write(cr, uid, [move_id],{'scaned_qty':move_data.scaned_qty+1}, context=context)
60 return 'init'
61 else:
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.'))
57 return {}63 return {}
5864

Subscribers

People subscribed via source and target branches