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
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 move_line = context['tax_move_ids']
6 for move_line_id in move_line:
7 move_line_data = self.pool.get('account.move.line').browse(cr, uid,move_line_id)
8+ print "move_line_data::::::",move_line_data
9 l3 = {
10 'debit': move_line_data.debit,
11 'credit': move_line_data.credit,
12@@ -235,6 +236,8 @@
13 'tax_amount':move_line_data.tax_amount,
14 }
15 lines.append((0, 0, l3))
16+ self.pool.get('account.move.line').unlink(cr, uid,[move_line_id])
17+ self.pool.get('account.move').unlink(cr, uid,[move_line_data.move_id.id])
18 else:
19 if amount_discount>0.0:
20 for line in invoice.invoice_line:
21@@ -278,6 +281,7 @@
22 }
23 lines.append((0, 0, l4))
24
25+ self.pool.get('account.move').unlink(cr, uid, context['discount_move_ids'])
26 else:
27 if amount_discount>0:
28 if 'account_id' in context and context['account_id']:
29@@ -324,5 +328,24 @@
30
31 account_invoice()
32
33+class account_move_line(osv.osv):
34+ _name = 'account.move.line'
35+ _inherit = 'account.move.line'
36+
37+ def _invoice(self, cr, uid, ids, name, arg, context=None):
38+ res = {}
39+ if ids:
40+ return super(account_move_line, self)._invoice(cr, uid, ids, name, arg, context)
41+ else:
42+ return res
43+
44+ def _invoice_search(self, cr, uid, obj, name, args, context={}):
45+ return super(account_move_line, self)._invoice_search(cr, uid, obj, name, args, context=context)
46+
47+ _columns = {
48+ 'invoice': fields.function(_invoice, method=True, string='Invoice',
49+ type='many2one', relation='account.invoice', fnct_search=_invoice_search),
50+ }
51+account_move_line()
52 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
53
54
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 #
60 ##############################################################################
61 import time
62-
63+from lxml import etree
64 from osv import fields, osv
65 from tools.translate import _
66 #import decimal_precision as dp
67@@ -62,7 +62,7 @@
68 'journal_id': fields.many2one('account.journal', 'Journal/Payment Mode', required=True),
69 'period_id': fields.many2one('account.period', 'Period', required=True),
70 'cash_amount':fields.float('Cash Discount Amount',),
71- 'account_id': fields.many2one('account.account', 'Account For Discount',),
72+ 'account_id': fields.many2one('account.account', 'Customers Cash Discount Account',),
73 'cal_method_selection': fields.selection([('method_gross_methodology','Calculate Discount with Net Gross Methodology'),
74 ('method_net_methodology','Calculate Discount with Net Methodology'),],
75 'Method To Calculation'),
76@@ -135,7 +135,7 @@
77 invoice = self.pool.get('account.invoice').browse(cr, uid, context['id'], context=context)
78 tax_obj = self.pool.get('account.tax')
79 invoice_tax_obj = self.pool.get("account.invoice.tax")
80-
81+
82 ######## to get ref
83 if invoice.type in ('in_invoice', 'in_refund'):
84 ref = invoice.reference
85@@ -155,7 +155,7 @@
86 ### Entry for taxes in the line of wizard tax
87 if data.get('cash_amount',0.0)>0.0:
88 lines3 = []
89- tax_total_amount = 0.0
90+ tax_total_amount = 0.0
91 line_ids = []
92 for line in invoice.invoice_line:
93 if line.invoice_line_tax_id:
94@@ -166,6 +166,7 @@
95 for tax_id in tax_invoice_id:
96 tax_value = invoice_tax_obj.browse(cr, uid, tax_id)
97 tax_account_id = tax_value.account_id.id
98+
99 l3 = {
100 'debit': direction * tax_amount<0 and - direction * tax_amount,
101 'credit': direction * tax_amount>0 and direction * tax_amount,
102@@ -182,16 +183,29 @@
103 line_id = self.pool.get('account.move.line').create(cr,uid,l3,context=context)
104 line_ids.append(line_id)
105 self.write(cr, uid, ids, {'tax_move_ids':[(6,0,line_ids)]}, context)
106-
107+
108 ### Entry for discount in the line of wizard discount
109 lines4 = []
110 if tax_total_amount>0:
111 data['cash_amount'] = (data['cash_amount'] - tax_total_amount)
112-
113+
114+ ############################ if method type net methology than discount account journal account
115+ discount_account_id = False
116+
117+ if data['cal_method_selection'] == 'method_net_methodology':
118+ journal_id = data['journal_id']
119+ if context['type'] == 'out_invoice':
120+ discount_account_id = self.pool.get('account.journal').browse(cr, uid, journal_id).default_debit_account_id.id
121+ else:
122+ discount_account_id = self.pool.get('account.journal').browse(cr, uid, journal_id).default_credit_account_id.id
123+ else:
124+ discount_account_id = data['account_id']
125+ ###############################################3
126+
127 l4 = {
128 'debit': direction * data.get('cash_amount',0.0)<0 and - direction * data.get('cash_amount',0.0),
129 'credit': direction * data.get('cash_amount',0.0)>0 and direction * data.get('cash_amount',0.0),
130- 'account_id': data['account_id'],
131+ 'account_id': discount_account_id,
132 'partner_id': invoice.partner_id.id,
133 'ref':ref,
134 'date': date,
135@@ -326,7 +340,20 @@
136 amount, acc_id, data['period_id'], data['journal_id'], writeoff_account_id,
137 data['period_id'], writeoff_journal_id, context, data['name'])
138 return {}
139-
140+
141+ def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False):
142+ res = super(account_invoice_pay,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar)
143+ fields=res.get('fields',{})
144+ word = "Supplier Cash Discount Account"
145+ type = context.get('type',False)
146+ eview = etree.fromstring(res['arch'])
147+ res['arch'] = etree.tostring(eview)
148+ if type == 'in_invoice':
149+ for f in res['fields']:
150+ if 'Customers Cash Discount Account' in res['fields'][f]['string']:
151+ res['fields'][f]['string'] = res['fields'][f]['string'].replace('Customers Cash Discount Account',word)
152+ return res
153+
154 account_invoice_pay()
155
156 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
157\ No newline at end of file
158
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 </form>
164 </field>
165 </record>
166-
167-
168 </data>
169 </openerp>
170\ No newline at end of file
171
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 product_ean = ean_data.ean
177 if product_ean == form_ean:
178 EAN_Found = True
179- return 'scan_product_number'
180- if not EAN_Found:
181+
182+ if EAN_Found:
183+ if move_data.product_id.track_production:
184+ return 'scan_product_number'
185+ else:
186+ stock_move_obj.write(cr, uid, [move_id],{'scaned_qty':move_data.scaned_qty+1}, context=context)
187+ return 'init'
188+ else:
189 raise osv.except_osv(_('Warning!'),('Product does not belongs to this picking or already scanned.'))
190 return {}
191

Subscribers

People subscribed via source and target branches