Merge lp:~serpentcs/openerp-usa/base_nationalacct into lp:openerp-usa

Proposed by Serpent Consulting Services
Status: Merged
Merged at revision: 6
Proposed branch: lp:~serpentcs/openerp-usa/base_nationalacct
Merge into: lp:openerp-usa
Diff against target: 736 lines (+268/-157)
9 files modified
account_payment_ccapi_authdotnet/cc_auth_api.py (+28/-126)
account_payment_ccapi_authdotnet/stock_return_picking.py (+7/-7)
account_payment_creditcard/account_journal.py (+5/-5)
account_payment_creditcard/account_voucher.py (+19/-19)
base_nationalacct/Change Log.txt (+15/-0)
base_nationalacct/__init__.py (+26/-0)
base_nationalacct/__openerp__.py (+43/-0)
base_nationalacct/partner.py (+89/-0)
base_nationalacct/partner_view.xml (+36/-0)
To merge this branch: bzr merge lp:~serpentcs/openerp-usa/base_nationalacct
Reviewer Review Type Date Requested Status
Novapoint Group Approve
Review via email: mp+229958@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Novapoint Group (npg-team) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_payment_ccapi_authdotnet/cc_auth_api.py'
2--- account_payment_ccapi_authdotnet/cc_auth_api.py 2014-01-09 18:15:04 +0000
3+++ account_payment_ccapi_authdotnet/cc_auth_api.py 2014-08-07 15:27:11 +0000
4@@ -128,11 +128,11 @@
5 # vals['type'] = 'sale'
6 # vals['currency_id'] = journal_obj.company_id.currency_id.id
7 # vals['line_cr_ids'] = [(0,0,cr_ids) for cr_ids in cr_ids_list]
8-## vals['narration'] = voucher_obj.narration
9+# # vals['narration'] = voucher_obj.narration
10 # vals['pay_now'] = 'pay_now'
11 # vals['account_id'] = journal_obj.default_debit_account_id.id
12-## vals['reference'] = voucher_obj.reference
13-## vals['tax_id'] = voucher_obj.tax_id.id
14+# # vals['reference'] = voucher_obj.reference
15+# # vals['tax_id'] = voucher_obj.tax_id.id
16 # vals['amount'] = sale_obj.amount_total
17 # vals['company_id'] = journal_obj.company_id.id
18 # voucher_id = self.pool.get('account.voucher').create(cr,uid,vals,context)
19@@ -153,9 +153,9 @@
20 acc_voucher_obj = voucher_obj.browse(cr, uid, ids, context={'cc_no':'no_mask'})
21 user = self.pool.get('res.users').browse(cr, uid, uid)
22
23- creditcard = acc_voucher_obj.cc_number# CREDIT CARD NUMBER
24- expiration = acc_voucher_obj.cc_e_d_month + acc_voucher_obj.cc_e_d_year ################ EXPIRATION DATE MM + YY
25- total = acc_voucher_obj.cc_order_amt ############## ORDER AMOUNT
26+ creditcard = acc_voucher_obj.cc_number # CREDIT CARD NUMBER
27+ expiration = acc_voucher_obj.cc_e_d_month + acc_voucher_obj.cc_e_d_year ################ EXPIRATION DATE MM + YY
28+ total = acc_voucher_obj.cc_order_amt ############## ORDER AMOUNT
29
30 if acc_voucher_obj.cc_save_card_details:
31 if not acc_voucher_obj.cc_bank:
32@@ -164,10 +164,10 @@
33 if not partner_bank_obj.search(cr, uid, [('cc_number', '=', creditcard), ('partner_id', '=', acc_voucher_obj.partner_id.id)]):
34 state_id = country_id = False
35 if acc_voucher_obj.cc_state:
36- state_ids = self.pool.get('res.country.state').search(cr, uid, [('name','=',acc_voucher_obj.cc_state)])
37+ state_ids = self.pool.get('res.country.state').search(cr, uid, [('name', '=', acc_voucher_obj.cc_state)])
38 state_id = state_ids and state_ids[0] or False
39 if acc_voucher_obj.cc_country:
40- country_ids = self.pool.get('res.country').search(cr, uid, [('name','=',acc_voucher_obj.cc_country)])
41+ country_ids = self.pool.get('res.country').search(cr, uid, [('name', '=', acc_voucher_obj.cc_country)])
42 country_id = country_ids and country_ids[0] or False
43 part = acc_voucher_obj.partner_id.id
44 if acc_voucher_obj.partner_id.parent_id:
45@@ -181,7 +181,7 @@
46 'bank':acc_voucher_obj.cc_bank.id,
47 'cc_v':acc_voucher_obj.cc_v,
48 'owner_name':acc_voucher_obj.cc_name,
49- 'street':str(acc_voucher_obj.cc_b_addr_1) +'-'+ str(acc_voucher_obj.cc_b_addr_2),
50+ 'street':str(acc_voucher_obj.cc_b_addr_1) + '-' + str(acc_voucher_obj.cc_b_addr_2),
51 'city': acc_voucher_obj.cc_city,
52 'zip': acc_voucher_obj.cc_zip,
53 'state_id': state_id,
54@@ -219,13 +219,13 @@
55
56 if str(login).strip() == '' or login == None:
57 raise osv.except_osv(_('Error'), _("No login name provided"))
58- #raise AuthnetAIMError('No login name provided')
59+ # raise AuthnetAIMError('No login name provided')
60 if str(transkey).strip() == '' or transkey == None:
61 raise osv.except_osv(_('Error'), _("No transaction key provided"))
62- #raise AuthnetAIMError('No transaction key provided')
63+ # raise AuthnetAIMError('No transaction key provided')
64 if testmode != True and testmode != False:
65 raise osv.except_osv(_('Error'), _("Invalid value for testmode. Must be True or False. "))
66- #raise AuthnetAIMError('Invalid value for testmode. Must be True or False. "{0}" given.'.format(testmode))
67+ # raise AuthnetAIMError('Invalid value for testmode. Must be True or False. "{0}" given.'.format(testmode))
68
69 parameters = {}
70 proxy = None
71@@ -247,24 +247,24 @@
72 parameters = voucher_obj.setParameter(parameters, 'x_login', login)
73 parameters = voucher_obj.setParameter(parameters, 'x_tran_key', transkey)
74
75- if acc_voucher_obj.cc_charge and x_type !='CREDIT':
76+ if acc_voucher_obj.cc_charge and x_type != 'CREDIT':
77 parameters = voucher_obj.setParameter(parameters, 'x_auth_code', acc_voucher_obj.cc_auth_code)
78
79- #PreAuth is done, so sending x_trans_id for capture
80- if x_type in ['PRIOR_AUTH_CAPTURE','CREDIT']:
81+ # PreAuth is done, so sending x_trans_id for capture
82+ if x_type in ['PRIOR_AUTH_CAPTURE', 'CREDIT']:
83 parameters = voucher_obj.setParameter(parameters, 'x_trans_id', acc_voucher_obj.cc_trans_id)
84
85 ########## setTransaction
86 if str(creditcard).strip() == '' or creditcard == None:
87 raise osv.except_osv(_('Error'), _("No credit card number passed to setTransaction()"))
88- #raise AuthnetAIMError('No credit card number passed to setTransaction(): {0}').format(creditcard)
89+ # raise AuthnetAIMError('No credit card number passed to setTransaction(): {0}').format(creditcard)
90 if str(expiration).strip() == '' or expiration == None:
91 raise osv.except_osv(_('Error'), _("No expiration number to setTransaction()"))
92- #raise AuthnetAIMError('No expiration number to setTransaction(): {0}').format(expiration)
93+ # raise AuthnetAIMError('No expiration number to setTransaction(): {0}').format(expiration)
94 if str(total).strip() == '' or total == None:
95 raise osv.except_osv(_('Error'), _("No total amount passed to setTransaction()"))
96
97- #raise AuthnetAIMError('No total amount passed to setTransaction(): {0}').format(total)
98+ # raise AuthnetAIMError('No total amount passed to setTransaction(): {0}').format(total)
99
100 parameters = voucher_obj.setParameter(parameters, 'x_card_num', creditcard)
101 parameters = voucher_obj.setParameter(parameters, 'x_exp_date', expiration)
102@@ -331,13 +331,13 @@
103 ret_dic['cc_trans_id'] = results[6]
104 ret_dic['cc_transaction'] = True
105 voucher_obj.write(cr, uid, ids, ret_dic)
106- voucher_obj._historise(cr, uid, acc_voucher_obj.id, 'Capture',trans_id=results[6], status=status, amount=acc_voucher_obj.cc_order_amt)
107+ voucher_obj._historise(cr, uid, acc_voucher_obj.id, 'Capture', trans_id=results[6], status=status, amount=acc_voucher_obj.cc_order_amt)
108 cr.commit()
109 if results[0] == '1':
110 '''
111 Validating sales receipt
112 '''
113- #self.validate_sales_reciept(cr, uid, ids, context=context)
114+ # self.validate_sales_reciept(cr, uid, ids, context=context)
115 '''
116 Posting payment voucher
117 '''
118@@ -348,11 +348,11 @@
119 elif x_type == 'CREDIT':
120 status = 'Refund: ' + str(results[3])
121 ret_dic['cc_status'] = status
122- voucher_obj._historise(cr, uid, acc_voucher_obj.id, 'Refund',trans_id=results[6], status=status, amount=acc_voucher_obj.cc_refund_amt)
123+ voucher_obj._historise(cr, uid, acc_voucher_obj.id, 'Refund', trans_id=results[6], status=status, amount=acc_voucher_obj.cc_refund_amt)
124 if results[0] == '1':
125 ret_dic['cc_transaction'] = False
126- #Domain : [('type','=','out_refund')]
127- #Context: {'type':'out_refund', 'journal_type': 'sale_refund'}
128+ # Domain : [('type','=','out_refund')]
129+ # Context: {'type':'out_refund', 'journal_type': 'sale_refund'}
130 refund_journal_id = False
131 j_ids = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'sale_refund')], context=context)
132 if j_ids:
133@@ -372,7 +372,7 @@
134 # inv_vals['sale_account_id'] = ship_method.account_id and ship_method.account_id.id,
135 inv_vals.update(invoice_obj.onchange_partner_id(cr, uid, [], 'out_refund', acc_voucher_obj.partner_id.id, '', '', '', '')['value'])
136 inv_lines = []
137- refund_lines = context.get('cc_refund',[])
138+ refund_lines = context.get('cc_refund', [])
139 for line in refund_lines:
140
141 inv_line_vals = {
142@@ -388,104 +388,6 @@
143
144 invoice_id = invoice_obj.create(cr, uid, inv_vals, context=context)
145 wf_service.trg_validate(uid, 'account.invoice', invoice_id, 'invoice_open', cr)
146-
147-# ret = True
148-# voucher_obj = self.pool.get('account.voucher')
149-#
150-#
151-# refund_journal_id = False
152-# if user.company_id.cc_refund_journal_id:
153-# refund_journal_id = user.company_id.cc_refund_journal_id.id
154-# else
155-# j_ids = self.pool.get('account.journal').search(cr, uid, [('type','=','sale_refund')], context=context)
156-# if j_ids:
157-# refund_journal_id = j_ids[0]
158-#
159-# account_id=False
160-# if refund_journal_id:
161-# default_debit_account_id = self.pool.get('account.journal').browse(cr, uid, refund_journal_id,context=context).default_debit_account_id.id
162-#
163-#
164-# vals1 = {
165-#
166-# 'name' : 'Refund : ' + (acc_voucher_obj.rel_sale_order_id and str(acc_voucher_obj.rel_sale_order_id.name) or ''),
167-# 'account_id' : default_debit_account_id,
168-# 'partner_id' : acc_voucher_obj.partner_id.id,
169-# 'amount' : acc_voucher_obj.cc_order_amt,
170-# 'currency_id' : user.company_id.currency_id.id,
171-# 'origin':acc_voucher_obj.rel_sale_order_id and acc_voucher_obj.rel_sale_order_id.name or ''
172-# }
173-#
174-#
175-# vals = voucher_obj.onchange_partner_id(cr, uid, [], acc_voucher_obj.partner_id.id, refund_journal_id , acc_voucher_obj.cc_order_amt , user.company_id.currency_id.id, 'sale', time())
176-#
177-# vals.update(vals1)
178-#
179-# vals['journal_id'] = refund_journal_id
180-# vals['type'] = 'sale'
181-#
182-#
183-#
184-#
185-# voucher_id = voucher_obj.create(cr, uid, vals, context=context)
186-#
187-#
188-# if acc_voucher_obj.cc_order_amt == acc_voucher_obj.rel_sale_order_id.amount_total and acc_voucher_obj.rel_sale_order_id.shipcharge:
189-# self.pool.get('sale.order').write(cr, uid, [acc_voucher_obj.rel_sale_order_id.id],{'cc_ship_refund':True},context=context)
190-#
191-# refund_voucher=False
192-# if 'cc_refund' not in context:
193-# refund_voucher=True
194-# sales_receipt_ids = voucher_obj.search(cr,uid,[('rel_sale_order_id','=',acc_voucher_obj.rel_sale_order_id.id),('state','=','posted'),('type','=','sale')], order="id desc",context=context)
195-#
196-# for receipt in voucher_obj.browse(cr, uid, sales_receipt_ids, context):
197-#
198-# for line in receipt.line_ids:
199-#
200-# if line.amount:
201-# vals = {
202-# 'voucher_id': voucher_id,
203-# 'name' : line.name,
204-# 'account_id' : line.account_id.id,
205-# 'partner_id' : line.partner_id.id,
206-# 'amount' : line.amount,
207-# 'type': line.type,
208-#
209-# }
210-# line_id = self.pool.get('account.voucher.line').create(cr, uid, vals, context)
211-# break
212-# else:
213-# for line in context['cc_refund']:
214-# product=self.pool.get('product.product').browse(cr, uid, line['product_id'],context)
215-#
216-# vals = {
217-# 'voucher_id': voucher_id,
218-# 'name' : product.name,
219-# 'account_id' : product.product_tmpl_id.property_account_income.id,
220-# 'partner_id' : acc_voucher_obj.partner_id.id,
221-# 'amount' : product.list_price * line['qty'],
222-# 'type' : 'cr',
223-# }
224-# line_id = self.pool.get('account.voucher.line').create(cr, uid, vals, context)
225-# if context.get('cc_ship_refund'):
226-# vals = {
227-# 'voucher_id': voucher_id,
228-# 'name' : 'Shipping Charges of ' + acc_voucher_obj.rel_sale_order_id.name,
229-# 'account_id' : acc_voucher_obj.rel_sale_order_id.ship_method_id and acc_voucher_obj.rel_sale_order_id.ship_method_id.account_id.id or False,
230-# 'partner_id' : acc_voucher_obj.partner_id.id,
231-# 'amount' : context['cc_ship_refund'],
232-# 'type' : 'cr',
233-# }
234-# line_id = self.pool.get('account.voucher.line').create(cr, uid, vals, context)
235-# self.pool.get('sale.order').write(cr, uid, [acc_voucher_obj.rel_sale_order_id.id],{'cc_ship_refund':True},context=context)
236-#
237-# # if x_type == 'CAPTURE_ONLY':
238-# status = "Capture: " + str(results[3])
239-# ret_dic['cc_status'] = status
240-# voucher_obj.write(cr, uid, ids, ret_dic)
241-# if not refund_voucher:
242-# wf_service = netsvc.LocalService('workflow')
243-# wf_service.trg_validate(uid, 'account.voucher', voucher_id, 'proforma_voucher', cr)
244
245 else:
246 ret_dic['cc_transaction'] = True
247@@ -505,7 +407,7 @@
248 '''
249
250 def check_transaction(self, cr, uid, ids, context=None):
251- transaction_record = self.browse( cr, uid, ids,context)
252+ transaction_record = self.browse(cr, uid, ids, context)
253 for record in transaction_record:
254 if record.cc_p_authorize and record.cc_auth_code:
255 raise osv.except_osv(_('Error'), _("Already Authorized!"))
256@@ -550,7 +452,7 @@
257 journal_obj = self.pool.get('account.journal').browse(cr, uid, journal_ids[0])
258 if sale_obj and sale_obj.order_line:
259 for sale_line in sale_obj.order_line:
260- cr_ids['account_id'] = self._get_prod_acc(sale_line.product_id and sale_line.product_id, journal_obj)#journal_obj.default_debit_account_id.id #Change this account to product's income account
261+ cr_ids['account_id'] = self._get_prod_acc(sale_line.product_id and sale_line.product_id, journal_obj) # journal_obj.default_debit_account_id.id #Change this account to product's income account
262 cr_ids['amount'] = sale_line.price_subtotal
263 cr_ids['partner_id'] = sale_obj.partner_id.id
264 cr_ids['name'] = sale_line.name
265@@ -565,7 +467,7 @@
266 else:
267 vals['journal_id'] = False
268 vals['partner_id'] = sale_obj.partner_id.id
269- #vals['date'] = sale_obj.date_order
270+ # vals['date'] = sale_obj.date_order
271 vals['rel_sale_order_id'] = ids[0]
272 vals['name'] = 'Auto generated Sales Receipt'
273 vals['type'] = 'sale'
274@@ -588,7 +490,7 @@
275 ret = super(sale_order, self).action_wait(cr, uid, ids, context=context)
276 for o in self.browse(cr, uid, ids, context=context):
277 if (o.order_policy == 'credit_card'):
278- #self.create_sales_reciept(cr, uid, [o.id])
279+ # self.create_sales_reciept(cr, uid, [o.id])
280 invoice_id = self.action_invoice_create(cr, uid, [o.id], context=context)
281 wf_service = netsvc.LocalService('workflow')
282 wf_service.trg_validate(uid, 'account.invoice', invoice_id, 'invoice_open', cr)
283
284=== modified file 'account_payment_ccapi_authdotnet/stock_return_picking.py'
285--- account_payment_ccapi_authdotnet/stock_return_picking.py 2014-01-09 18:15:04 +0000
286+++ account_payment_ccapi_authdotnet/stock_return_picking.py 2014-08-07 15:27:11 +0000
287@@ -28,7 +28,7 @@
288 _inherit = 'stock.return.picking'
289 _columns = {
290 'cc_ship_refund' : fields.boolean(string='Refund Shipcharge', required=True),
291- 'invoice_state': fields.selection([('2binvoiced', 'To be refunded/invoiced'), ('none', 'No invoicing'),('cc_refund','Credit Card Refund')], 'Invoicing',required=True),
292+ 'invoice_state': fields.selection([('2binvoiced', 'To be refunded/invoiced'), ('none', 'No invoicing'), ('cc_refund', 'Credit Card Refund')], 'Invoicing', required=True),
293 }
294
295 def default_get(self, cr, uid, fields, context=None):
296@@ -79,7 +79,7 @@
297 res = super(stock_return_picking, self).create_returns(cr, uid, ids, context)
298
299 move_lines = data['product_return_moves']
300- #@ Moving the refund process to On Delivery process of related incoming shipment
301+ # @ Moving the refund process to On Delivery process of related incoming shipment
302 if data['invoice_state'] == 'cc_refund':
303 amount = 0.00
304 for move in move_lines:
305@@ -136,11 +136,11 @@
306 amount = 0.00
307 vch_lines = []
308 Lines = pick.move_lines
309- if pick.backorder_id.id and pick.state=='assigned':
310+ if pick.backorder_id.id and pick.state == 'assigned':
311 Lines = pick.backorder_id.move_lines
312 for move in Lines:
313- partial_data = partial_datas.get('move%s'%(move.id), {})
314- new_qty = partial_data.get('product_qty',0.0)
315+ partial_data = partial_datas.get('move%s' % (move.id), {})
316+ new_qty = partial_data.get('product_qty', 0.0)
317 line = {}
318 if IN:
319 line['product_id'] = move.product_id.id
320@@ -162,7 +162,7 @@
321 if sale and sale.payment_method == 'cc_pre_auth' and not sale.invoiced:
322 rel_voucher = sale.rel_account_voucher_id or False
323 if rel_voucher and rel_voucher.state != 'posted' and rel_voucher.cc_auth_code:
324- vals_vouch = {'cc_order_amt': amount,'cc_p_authorize': False, 'cc_charge': True}
325+ vals_vouch = {'cc_order_amt': amount, 'cc_p_authorize': False, 'cc_charge': True}
326 if 'trans_type' in rel_voucher._columns.keys():
327 vals_vouch.update({'trans_type': 'PriorAuthCapture'})
328 voucher_obj.write(cr, uid, [rel_voucher.id], vals_vouch, context=context)
329@@ -176,4 +176,4 @@
330
331 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
332
333-
334\ No newline at end of file
335+
336
337=== modified file 'account_payment_creditcard/account_journal.py'
338--- account_payment_creditcard/account_journal.py 2014-01-09 18:15:04 +0000
339+++ account_payment_creditcard/account_journal.py 2014-08-07 15:27:11 +0000
340@@ -36,8 +36,8 @@
341 _inherit = "res.partner"
342
343 def write(self, cr, uid, ids, vals, context=None):
344- if vals.get('bank_ids',[]) and len(vals['bank_ids'][0]) == 3 and vals['bank_ids'][0][2] :
345- if vals['bank_ids'][0][2].get('cc_number',False):
346+ if vals.get('bank_ids', []) and len(vals['bank_ids'][0]) == 3 and vals['bank_ids'][0][2] :
347+ if vals['bank_ids'][0][2].get('cc_number', False):
348 if ('XXXXXXXXX' in vals['bank_ids'][0][2]['cc_number']):
349 if vals.get('cc_number'):
350 del vals['cc_number']
351@@ -52,7 +52,7 @@
352 _inherit = "res.partner.bank"
353
354 _columns = {
355- 'cc_number':fields.char('Credit Card Number', size=256),#Given size 256 because the credit card is stored as encrypted format.
356+ 'cc_number':fields.char('Credit Card Number', size=256), # Given size 256 because the credit card is stored as encrypted format.
357 'cc_e_d_month':fields.char('Expiration Date MM', size=32),
358 'cc_e_d_year':fields.char('Expiration Date YY', size=32),
359 'cc_v':fields.char('Card Code Verification', size=3),
360@@ -94,7 +94,7 @@
361 if context is None:
362 context = {}
363 context.update({'cc_no':'no_mask'})
364- if not isinstance(ids,list):
365+ if not isinstance(ids, list):
366 ids = [ids]
367 for record in self.browse(cr, uid, ids, context=context):
368 if vals.get('cc_number', False):
369@@ -159,4 +159,4 @@
370
371 res_partner_bank()
372
373-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
374\ No newline at end of file
375+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
376
377=== modified file 'account_payment_creditcard/account_voucher.py'
378--- account_payment_creditcard/account_voucher.py 2014-01-09 18:15:04 +0000
379+++ account_payment_creditcard/account_voucher.py 2014-08-07 15:27:11 +0000
380@@ -124,7 +124,7 @@
381 if context is None:
382 context = {}
383 context.update({'cc_no':'no_mask'})
384- if not isinstance(ids,list):
385+ if not isinstance(ids, list):
386 ids = [ids]
387 for record in self.browse(cr, uid, ids, context=context):
388 if vals.get('cc_number', False):
389@@ -222,7 +222,7 @@
390 'cc_zip':fields.char('Postal/Zip', size=32,),
391 'cc_country':fields.char('Country', size=32,),
392 'cc_order_date':fields.date('Order Date',),
393- 'cc_order_amt':fields.float('Order Amt',required=True),
394+ 'cc_order_amt':fields.float('Order Amt', required=True),
395 'cc_number':fields.char('Credit Card Number', size=256),
396 'cc_v':fields.char('Card Code Verification', size=3),
397 'cc_e_d_month':fields.char('Expiration Date MM', size=32),
398@@ -278,7 +278,7 @@
399 cc_allow_refunds = jorurnal_cc_allow = False
400 cardholder_details = self._get_cardholder_details(cr, uid, ids, partner_id, context=context)
401 if journal_id and cardholder_details:
402- journal_read = self.pool.get('account.journal').read(cr, uid, journal_id, ['cc_allow_processing','cc_allow_refunds'])
403+ journal_read = self.pool.get('account.journal').read(cr, uid, journal_id, ['cc_allow_processing', 'cc_allow_refunds'])
404 jorurnal_cc_allow = journal_read['cc_allow_processing']
405 cc_allow_refunds = journal_read['cc_allow_refunds']
406 res['value']['cc_name'] = cardholder_details['name']
407@@ -349,12 +349,12 @@
408 journal_pool = self.pool.get('account.journal')
409 line_pool = self.pool.get('account.voucher.line')
410
411- #set default values
412+ # set default values
413 default = {
414- 'value': {'line_dr_ids': [] ,'line_cr_ids': [] ,'pre_line': False,},
415+ 'value': {'line_dr_ids': [] , 'line_cr_ids': [] , 'pre_line': False, },
416 }
417
418- #drop existing lines
419+ # drop existing lines
420 line_ids = ids and line_pool.search(cr, uid, [('voucher_id', '=', ids[0])]) or False
421 if line_ids:
422 line_pool.unlink(cr, uid, line_ids)
423@@ -377,14 +377,14 @@
424 account_type = 'receivable'
425
426 if not context.get('move_line_ids', False):
427- ids = move_line_pool.search(cr, uid, [('state','=','valid'), ('account_id.type', '=', account_type), ('reconcile_id', '=', False), ('partner_id', '=', partner_id)], context=context)
428+ ids = move_line_pool.search(cr, uid, [('state', '=', 'valid'), ('account_id.type', '=', account_type), ('reconcile_id', '=', False), ('partner_id', '=', partner_id)], context=context)
429 else:
430 ids = context['move_line_ids']
431 invoice_id = context.get('invoice_id', False)
432 company_currency = journal.company_id.currency_id.id
433 move_line_found = False
434
435- #order the lines by most old first
436+ # order the lines by most old first
437 ids.reverse()
438 account_move_lines = move_line_pool.browse(cr, uid, ids, context=context)
439
440@@ -393,25 +393,25 @@
441 if context.get('sale_id'):
442 INV_IDS = [x.id for x in self.pool.get('sale.order').browse(cr, uid, context['sale_id'], context=context).invoice_ids]
443
444- #compute the total debit/credit and look for a matching open amount or invoice
445+ # compute the total debit/credit and look for a matching open amount or invoice
446 for line in account_move_lines:
447 if _remove_noise_in_o2m():
448 continue
449
450 if INV_IDS:
451 if line.invoice.id in INV_IDS:
452- #if the invoice linked to the voucher line is equal to the invoice_id in context
453- #then we assign the amount on that line, whatever the other voucher lines
454+ # if the invoice linked to the voucher line is equal to the invoice_id in context
455+ # then we assign the amount on that line, whatever the other voucher lines
456 move_line_found = line.id
457 break
458 elif currency_id == company_currency:
459- #otherwise treatments is the same but with other field names
460+ # otherwise treatments is the same but with other field names
461 if line.amount_residual == price:
462- #if the amount residual is equal the amount voucher, we assign it to that voucher
463- #line, whatever the other voucher lines
464+ # if the amount residual is equal the amount voucher, we assign it to that voucher
465+ # line, whatever the other voucher lines
466 move_line_found = line.id
467 break
468- #otherwise we will split the voucher amount on each line (by most old first)
469+ # otherwise we will split the voucher amount on each line (by most old first)
470 total_credit += line.credit or 0.0
471 total_debit += line.debit or 0.0
472 elif currency_id == line.currency_id.id:
473@@ -422,7 +422,7 @@
474 total_debit += line.debit and line.amount_currency or 0.0
475
476
477- #voucher line creation
478+ # voucher line creation
479 for line in account_move_lines:
480 if _remove_noise_in_o2m():
481 continue
482@@ -430,7 +430,7 @@
483 amount_original = abs(line.amount_currency)
484 amount_unreconciled = abs(line.amount_residual_currency)
485 else:
486- #always use the amount booked in the company currency as the basis of the conversion into the voucher currency
487+ # always use the amount booked in the company currency as the basis of the conversion into the voucher currency
488 amount_original = currency_pool.compute(cr, uid, company_currency, currency_id, line.credit or line.debit or 0.0, context=context_multi_currency)
489 amount_unreconciled = currency_pool.compute(cr, uid, company_currency, currency_id, abs(line.amount_residual), context=context_multi_currency)
490 line_currency_id = line.currency_id and line.currency_id.id or company_currency
491@@ -446,8 +446,8 @@
492 'amount_unreconciled': amount_unreconciled,
493 'currency_id': line_currency_id,
494 }
495- #in case a corresponding move_line hasn't been found, we now try to assign the voucher amount
496- #on existing invoices: we split voucher amount by most old first, but only for lines in the same currency
497+ # in case a corresponding move_line hasn't been found, we now try to assign the voucher amount
498+ # on existing invoices: we split voucher amount by most old first, but only for lines in the same currency
499 inv_ids = []
500 REC = False
501 if line.invoice.id and context.get('sale_id'):
502
503=== added directory 'base_nationalacct'
504=== added file 'base_nationalacct/Change Log.txt'
505--- base_nationalacct/Change Log.txt 1970-01-01 00:00:00 +0000
506+++ base_nationalacct/Change Log.txt 2014-08-07 15:27:11 +0000
507@@ -0,0 +1,15 @@
508+===============================================================================
509+ Version Change Log (base_jdc)
510+===============================================================================
511+2.00 (2014-08-07) By Serpent Consulting Services Pvt Ltd.
512+ * Code migration to v7
513+
514+1.02 (2012-03-20) By Sinoj
515+ * Code clean-up
516+
517+ 1.01 (2011-01-13) By Sinoj
518+ * Module is reviewed and comments added
519+
520+ 1.0 (2010-11-23) By jabir
521+ * Created "National Acct Parent" variable in partner and displayed it in tree and form view
522+ * Displayed parent partner in partner form
523
524=== added file 'base_nationalacct/__init__.py'
525--- base_nationalacct/__init__.py 1970-01-01 00:00:00 +0000
526+++ base_nationalacct/__init__.py 2014-08-07 15:27:11 +0000
527@@ -0,0 +1,26 @@
528+# -*- coding: utf-8 -*-
529+##############################################################################
530+#
531+# OpenERP, Open Source Management Solution
532+# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
533+# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
534+#
535+# This program is free software: you can redistribute it and/or modify
536+# it under the terms of the GNU General Public License as published by
537+# the Free Software Foundation, either version 3 of the License, or
538+# (at your option) any later version.
539+#
540+# This program is distributed in the hope that it will be useful,
541+# but WITHOUT ANY WARRANTY; without even the implied warranty of
542+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
543+# GNU General Public License for more details.
544+#
545+# You should have received a copy of the GNU General Public License
546+# along with this program. If not, see <http://www.gnu.org/licenses/>
547+#
548+##############################################################################
549+
550+from . import partner
551+
552+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
553+
554
555=== added file 'base_nationalacct/__openerp__.py'
556--- base_nationalacct/__openerp__.py 1970-01-01 00:00:00 +0000
557+++ base_nationalacct/__openerp__.py 2014-08-07 15:27:11 +0000
558@@ -0,0 +1,43 @@
559+# -*- coding: utf-8 -*-
560+##############################################################################
561+#
562+# OpenERP, Open Source Management Solution
563+# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
564+# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
565+#
566+# This program is free software: you can redistribute it and/or modify
567+# it under the terms of the GNU General Public License as published by
568+# the Free Software Foundation, either version 3 of the License, or
569+# (at your option) any later version.
570+#
571+# This program is distributed in the hope that it will be useful,
572+# but WITHOUT ANY WARRANTY; without even the implied warranty of
573+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
574+# GNU General Public License for more details.
575+#
576+# You should have received a copy of the GNU General Public License
577+# along with this program. If not, see <http://www.gnu.org/licenses/>
578+#
579+##############################################################################
580+
581+
582+{
583+ 'name': 'Base Modifications',
584+ 'version': '2.0',
585+ 'category': 'US Localisation/Account',
586+ 'description': """
587+ This module implements changes to Partner and Company .
588+ Adds new field National Acct Parent in Partner.
589+ The parent company can process the invoice of child company if the account is national account
590+ """,
591+ 'author': 'NovaPoint Group',
592+ 'website': 'http://www.novapointgroup.com',
593+ 'depends': ['account'],
594+ 'data': [
595+ 'partner_view.xml',
596+ ],
597+ 'installable': True,
598+ 'auto_install': False,
599+ 'certificate': '',
600+}
601+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
602
603=== added file 'base_nationalacct/partner.py'
604--- base_nationalacct/partner.py 1970-01-01 00:00:00 +0000
605+++ base_nationalacct/partner.py 2014-08-07 15:27:11 +0000
606@@ -0,0 +1,89 @@
607+# -*- coding: utf-8 -*-
608+##############################################################################
609+#
610+# OpenERP, Open Source Management Solution
611+# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
612+# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
613+#
614+# This program is free software: you can redistribute it and/or modify
615+# it under the terms of the GNU General Public License as published by
616+# the Free Software Foundation, either version 3 of the License, or
617+# (at your option) any later version.
618+#
619+# This program is distributed in the hope that it will be useful,
620+# but WITHOUT ANY WARRANTY; without even the implied warranty of
621+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
622+# GNU General Public License for more details.
623+#
624+# You should have received a copy of the GNU General Public License
625+# along with this program. If not, see <http://www.gnu.org/licenses/>
626+#
627+##############################################################################
628+
629+from openerp.osv import fields, osv
630+
631+class res_partner(osv.Model):
632+ _inherit = "res.partner"
633+
634+ #===========================================================================
635+ # Overriding a function defined on account module.
636+ # This is to include the payable and receivable from child partners if the
637+ # account is a national account.
638+ #===========================================================================
639+ def _credit_debit_get(self, cr, uid, ids, field_names, arg, context=None):
640+ """
641+ calculating payable and receivable from account moves for the mentioned partners
642+ """
643+ query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
644+ cr.execute("""
645+ SELECT l.partner_id, a.type, SUM(l.debit-l.credit)
646+ FROM account_move_line l
647+ LEFT JOIN account_account a ON (l.account_id=a.id)
648+ WHERE a.type IN ('receivable','payable')
649+ AND l.partner_id IN %s
650+ AND l.reconcile_id IS NULL
651+ AND """ + query + """
652+ GROUP BY l.partner_id, a.type
653+ """,(tuple(ids), ))
654+ maps = {'receivable': 'credit', 'payable': 'debit'}
655+ res = {}
656+ for id in ids:
657+ res[id] = dict.fromkeys(field_names, 0)
658+ for pid, type, val in cr.fetchall():
659+ if val is None: val = 0
660+ partner = self.browse(cr, uid, pid, context=context)
661+ #Include the payable and receivable form child partner if the Partner is national account
662+ if partner.nat_acc_parent:
663+ res[pid][maps[type]] = (type == 'receivable') and val or -val
664+ child_partner_ids = self.search(cr, uid, [('parent_id', 'child_of', [partner.id])], context=context)
665+ if child_partner_ids:
666+ child_partner_ids.remove(partner.id)
667+ for val in self.read(cr, uid, child_partner_ids, ['credit', 'debit'], context=context):
668+ res[pid][maps[type]] += val.get(maps[type], 0)
669+ else:
670+ res[pid][maps[type]] = (type == 'receivable') and val or -val
671+
672+ return res
673+
674+ def _credit_search(self, cr, uid, obj, name, args, context=None):
675+ """
676+ search function for the credit field
677+ """
678+ return self._asset_difference_search(cr, uid, obj, name, 'receivable', args, context=context)
679+
680+ def _debit_search(self, cr, uid, obj, name, args, context=None):
681+ """
682+ search function for the debit field
683+ """
684+ return self._asset_difference_search(cr, uid, obj, name, 'payable', args, context=context)
685+
686+ _columns = {
687+ 'credit': fields.function(_credit_debit_get, fnct_search=_credit_search, method=True, string='Total Receivable', multi='dc',
688+ help="Total amount this customer owes you."),
689+ 'debit': fields.function(_credit_debit_get, fnct_search=_debit_search, method=True, string='Total Payable', multi='dc',
690+ help="Total amount you have to pay to this supplier."),
691+ 'nat_acc_parent': fields.boolean('National Acct Parent', help='Designates this partner as the top level parent of a "National Account".'),
692+ }
693+
694+
695+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
696
697=== added file 'base_nationalacct/partner_view.xml'
698--- base_nationalacct/partner_view.xml 1970-01-01 00:00:00 +0000
699+++ base_nationalacct/partner_view.xml 2014-08-07 15:27:11 +0000
700@@ -0,0 +1,36 @@
701+<?xml version="1.0" encoding="utf-8"?>
702+<openerp>
703+ <data>
704+
705+ <!-- Partner Form -->
706+
707+ <record id="view_partner_form_base_nat" model="ir.ui.view">
708+ <field name="name">res.partner.form.base.nat</field>
709+ <field name="model">res.partner</field>
710+ <field name="type">form</field>
711+ <field name="inherit_id" ref="base.view_partner_form"/>
712+ <field name="priority" eval="1"/>
713+ <field name="arch" type="xml">
714+ <xpath expr="//field[@name='date']" position="after" >
715+ <field name="nat_acc_parent" />
716+ </xpath>
717+ </field>
718+ </record>
719+
720+ <!-- Partner List-->
721+
722+ <record id="view_partner_tree_base_nat" model="ir.ui.view">
723+ <field name="name">res.partner.tree.base.nat</field>
724+ <field name="model">res.partner</field>
725+ <field name="type">tree</field>
726+ <field eval="8" name="priority"/>
727+ <field name="inherit_id" ref="base.view_partner_tree"/>
728+ <field name="arch" type="xml">
729+ <xpath expr="//field[@name='user_id']" position="after">
730+ <field name="nat_acc_parent"/>
731+ </xpath>
732+ </field>
733+ </record>
734+
735+ </data>
736+</openerp>

Subscribers

People subscribed via source and target branches