Merge lp:~openerp-dev/openobject-addons/6.0-opw-50587-ira into lp:openobject-addons/6.0

Proposed by Ila Rana(Open ERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/6.0-opw-50587-ira
Merge into: lp:openobject-addons/6.0
Diff against target: 73 lines (+13/-25)
1 file modified
point_of_sale/wizard/pos_box_out.py (+13/-25)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.0-opw-50587-ira
Reviewer Review Type Date Requested Status
Ila Rana(Open ERP) (community) Needs Resubmitting
Vinay Rana (OpenERP) Pending
Review via email: mp+82662@code.launchpad.net

Description of the change

Hello Priyesh,

I have checked the Xavier Fernandez's patch and its working properly as per the expectation.
So the issue of account taking from product.template id is resolved now through this branch.

Thanks,
Ila Rana.

To post a comment you must log in.
Revision history for this message
Serpent Consulting Services (serpent-consulting-services) wrote :

Hello Ila Rana,

I see there are still the chances for optimization of this code.

The use of statement 'product_obj.browse(cr, uid, data['product_id'], context=context)' is many times rather than once.

Though it doesn't affect the fix, but its always better to prevent future optimization requests.

Moreover, 'res_obj.browse(cr, uid, uid, context=context)' is also ill-treated.

Hope this would surely help.

Thanks,
Serpent Consulting Services.

4922. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

4923. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

Revision history for this message
Ila Rana(Open ERP) (ira-openerp) :
review: Needs Resubmitting
4924. By Ila Rana(Open ERP)

[FIX]don't take income account from product's account inwizard pos.box.out:Case(50587)

Unmerged revisions

4924. By Ila Rana(Open ERP)

[FIX]don't take income account from product's account inwizard pos.box.out:Case(50587)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'point_of_sale/wizard/pos_box_out.py'
2--- point_of_sale/wizard/pos_box_out.py 2011-10-03 14:13:57 +0000
3+++ point_of_sale/wizard/pos_box_out.py 2011-11-21 12:54:09 +0000
4@@ -73,44 +73,33 @@
5 vals = {}
6 statement_obj = self.pool.get('account.bank.statement')
7 statement_line_obj = self.pool.get('account.bank.statement.line')
8- product_obj = self.pool.get('product.template')
9- productp_obj = self.pool.get('product.product')
10+ product_obj = self.pool.get('product.product')
11 res_obj = self.pool.get('res.users')
12+ res_user = res_obj.browse(cr, uid, uid, context=context)
13+
14 for data in self.read(cr, uid, ids, context=context):
15- curr_company = res_obj.browse(cr, uid, uid, context=context).company_id.id
16+ curr_company = res_user.company_id.id
17 statement_id = statement_obj.search(cr, uid, [('journal_id', '=', data['journal_id']), ('company_id', '=', curr_company), ('user_id', '=', uid), ('state', '=', 'open')], context=context)
18 monday = (datetime.today() + relativedelta(weekday=0)).strftime('%Y-%m-%d')
19 sunday = (datetime.today() + relativedelta(weekday=6)).strftime('%Y-%m-%d')
20 done_statmt = statement_obj.search(cr, uid, [('date', '>=', monday+' 00:00:00'), ('date', '<=', sunday+' 23:59:59'), ('journal_id', '=', data['journal_id']), ('company_id', '=', curr_company), ('user_id', '=', uid)], context=context)
21 stat_done = statement_obj.browse(cr, uid, done_statmt, context=context)
22- address_u = res_obj.browse(cr, uid, uid, context=context).address_id
23+ address_u = res_user.address_id
24 am = 0.0
25
26- amount_check = productp_obj.browse(cr, uid, data['product_id'], context=context).am_out or False
27+ product = product_obj.browse(cr, uid, data['product_id'], context=context)
28+ amount_check = product.am_out or False
29 for st in stat_done:
30 for s in st.line_ids:
31 if address_u and s.partner_id == address_u.partner_id and s.am_out:
32 am += s.amount
33- if (-data['amount'] or 0.0) + am < -(res_obj.browse(cr, uid, uid, context=context).company_id.max_diff or 0.0) and amount_check:
34- val = (res_obj.browse(cr, uid, uid).company_id.max_diff or 0.0) + am
35+ if (-data['amount'] or 0.0) + am < -(res_user.company_id.max_diff or 0.0) and amount_check:
36+ val = (res_user.company_id.max_diff or 0.0) + am
37 precision = '%0.' + str(dp.get_precision('Point Of Sale Discount')(cr)[1] or 0) + 'f'
38 raise osv.except_osv(_('Error !'), _('The maximum value you can still withdraw is exceeded. \n Remaining value is equal to %s') % (precision % val,))
39
40- acc_id = product_obj.browse(cr, uid, data['product_id'], context=context).property_account_income
41- if not acc_id:
42- raise osv.except_osv(_('Error !'), _('please check that account is set to %s')%(product_obj.browse(cr, uid, data['product_id'], context=context).name))
43- if not statement_id:
44- raise osv.except_osv(_('Error !'), _('You have to open at least one cashbox'))
45- if statement_id:
46- statement_id = statement_id[0]
47- if not statement_id:
48- statement_id = statement_obj.create(cr, uid, {
49- 'date': time.strftime('%Y-%m-%d 00:00:00'),
50- 'journal_id': data['journal_id'],
51- 'company_id': curr_company,
52- 'user_id': uid,
53- }, context=context)
54- vals['statement_id'] = statement_id
55+ acc_id = product.property_account_income
56+ vals['statement_id'] = statement_id[0]
57 vals['journal_id'] = data['journal_id']
58 if acc_id:
59 vals['account_id'] = acc_id.id
60@@ -118,11 +107,10 @@
61 if data['amount'] > 0:
62 amount = -data['amount']
63 vals['amount'] = amount
64- if productp_obj.browse(cr, uid, data['product_id'], context=context).am_out:
65+ if amount_check:
66 vals['am_out'] = True
67 vals['ref'] = data['ref'] or ''
68- vals['name'] = "%s: %s " % (product_obj.browse(cr, uid, data['product_id'], context=context).name, data['name'].decode('utf8'))
69- address_u = res_obj.browse(cr, uid, uid, context=context).address_id
70+ vals['name'] = "%s: %s " % (product.name, data['name'].decode('utf8'))
71 if address_u:
72 vals['partner_id'] = address_u.partner_id and address_u.partner_id.id or None
73 statement_line_obj.create(cr, uid, vals, context=context)