Bharat Devnani (Open ERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-bug-710533-bde into
lp:openobject-addons.
Requested reviews:
Bharat Devnani (Open ERP) (bde-openerp)
Purnendu Singh (OpenERP) (psi-tinyerp)
Mustufa Rangwala (Open ERP) (mra-tinyerp)
Related bugs:
Bug #710533 in OpenERP Addons: "account invoice model translation problem
with no context param"
https://bugs.launchpad.net/openobject-addons/+bug/710533
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-710533-bde/+merge/85293
Hello Sir,
I have passed context agruments in some methods of account/account_invoice.py.
Thanks & Regards,
Devnani Bharat R.
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-710533-bde/+merge/85293
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-bug-710533-bde.
=== modified file 'account/account_invoice.py'
--- account/account_invoice.py 2011-12-18 19:36:38 +0000
+++ account/account_invoice.py 2011-12-21 10:17:28 +0000
@@ -794,29 +794,33 @@
line.append((0,0,val))
return line
- def action_move_create(self, cr, uid, ids, *args):
+ def action_move_create(self, cr, uid, ids, context=None):
"""Creates invoice related analytics and financial move lines"""
ait_obj = self.pool.get('account.invoice.tax')
cur_obj = self.pool.get('res.currency')
period_obj = self.pool.get('account.period')
- context = {}
- for inv in self.browse(cr, uid, ids):
+ payment_term_obj = self.pool.get('account.payment.term')
+ journal_obj = self.pool.get('account.journal')
+ move_obj = self.pool.get('account.move')
+ if context is None:
+ context = {}
+ for inv in self.browse(cr, uid, ids, context=context):
if not inv.journal_id.sequence_id:
raise osv.except_osv(_('Error !'), _('Please define sequence on invoice journal'))
if not inv.invoice_line:
raise osv.except_osv(_('No Invoice Lines !'), _('Please create some invoice lines.'))
if inv.move_id:
continue
-
+
+ ctx = context.copy()
+ ctx.update({'lang': inv.partner_id.lang})
if not inv.date_invoice:
- self.write(cr, uid, [inv.id], {'date_invoice':time.strftime('%Y-%m-%d')})
+ self.write(cr, uid, [inv.id], {'date_invoice':time.strftime('%Y-%m-%d')}, context=ctx)
company_currency = inv.company_id.currency_id.id
# create the analytical lines
# one move line per invoice line
- iml = self._get_analytic_lines(cr, uid, inv.id)
+ iml = self._get_analytic_lines(cr, uid, inv.id, context=ctx)
# check if taxes are all computed
- ctx = context.copy()
- ctx.update({'lang': inv.partner_id.lang})
compute_taxes = ait_obj.compute(cr, uid, inv.id, context=ctx)
self.check_tax_lines(cr, uid, inv, compute_taxes, ait_obj)
@@ -859,8 +863,8 @@
name = inv['name'] or '/'
totlines = False
if inv.payment_term:
- totlines = self.pool.get('account.payment.term').compute(cr,
- uid, inv.payment_term.id, total, inv.date_invoice or False)
+ totlines = payment_term_obj.compute(cr,
+ uid, inv.payment_term.id, total, inv.date_invoice or False, context=ctx)
if totlines:
res_amount_currency = total_currency
i = 0
@@ -906,12 +910,12 @@
date = inv.date_invoice or time.strftime('%Y-%m-%d')
part = inv.partner_id.id
- line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x, part, date, context={})),iml)
+ line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x, part, date, context=ctx)),iml)
line = self.group_lines(cr, uid, iml, line, inv)
journal_id = inv.journal_id.id
- journal = self.pool.get('account.journal').browse(cr, uid, journal_id)
+ journal = journal_obj.browse(cr, uid, journal_id, context=ctx)
if journal.centralisation:
raise osv.except_osv(_('UserError'),
_('You cannot create an invoice on a centralised journal. Uncheck the centralised counterpart box in the related journal from the configuration menu.'))
@@ -935,13 +939,14 @@
for i in line:
i[2]['period_id'] = period_id
- move_id = self.pool.get('account.move').create(cr, uid, move, context=context)
- new_move_name = self.pool.get('account.move').browse(cr, uid, move_id).name
+ move_id = move_obj.create(cr, uid, move, context=ctx)
+ new_move_name = move_obj.browse(cr, uid, move_id).name
# make the invoice point to that move
- self.write(cr, uid, [inv.id], {'move_id': move_id,'period_id':period_id, 'move_name':new_move_name})
+ self.write(cr, uid, [inv.id], {'move_id': move_id,'period_id':period_id, 'move_name':new_move_name}, context=ctx)
# Pass invoice in context in method post: used if you want to get the same
# account move reference when creating the same invoice after a cancelled one:
- self.pool.get('account.move').post(cr, uid, [move_id], context={'invoice':inv})
+ ctx.update({'invoice':inv})
+ move_obj.post(cr, uid, [move_id], context=ctx)
self._log_event(cr, uid, ids)
return True
=== modified file 'account_analytic_plans/account_analytic_plans.py'
--- account_analytic_plans/account_analytic_plans.py 2011-10-16 01:28:00 +0000
+++ account_analytic_plans/account_analytic_plans.py 2011-12-21 10:17:28 +0000
@@ -380,7 +380,7 @@
res['analytics_id'] = x.get('analytics_id', False)
return res
- def _get_analytic_lines(self, cr, uid, id):
+ def _get_analytic_lines(self, cr, uid, id, context=None):
inv = self.browse(cr, uid, [id])[0]
cur_obj = self.pool.get('res.currency')
invoice_line_obj = self.pool.get('account.invoice.line')
@@ -391,7 +391,7 @@
else:
sign = -1
- iml = invoice_line_obj.move_line_get(cr, uid, inv.id)
+ iml = invoice_line_obj.move_line_get(cr, uid, inv.id, context=context)
for il in iml:
if il.get('analytics_id', False):
=== modified file 'analytic_journal_billing_rate/analytic_journal_billing_rate.py'
--- analytic_journal_billing_rate/analytic_journal_billing_rate.py 2011-04-29 08:49:48 +0000
+++ analytic_journal_billing_rate/analytic_journal_billing_rate.py 2011-12-21 10:17:28 +0000
@@ -100,8 +100,8 @@
class account_invoice(osv.osv):
_inherit = "account.invoice"
- def _get_analytic_lines(self, cr, uid, id):
- iml = super(account_invoice, self)._get_analytic_lines(cr, uid, id)
+ def _get_analytic_lines(self, cr, uid, id, context=None):
+ iml = super(account_invoice, self)._get_analytic_lines(cr, uid, id, context=context)
for il in iml:
if il['account_analytic_id'] and il.get('analytic_lines', False):
=== modified file 'hr_timesheet_invoice/hr_timesheet_invoice.py'
--- hr_timesheet_invoice/hr_timesheet_invoice.py 2011-12-18 19:36:38 +0000
+++ hr_timesheet_invoice/hr_timesheet_invoice.py 2011-12-21 10:17:28 +0000
@@ -170,8 +170,8 @@
class account_invoice(osv.osv):
_inherit = "account.invoice"
- def _get_analytic_lines(self, cr, uid, id):
- iml = super(account_invoice, self)._get_analytic_lines(cr, uid, id)
+ def _get_analytic_lines(self, cr, uid, id, context=None):
+ iml = super(account_invoice, self)._get_analytic_lines(cr, uid, id, context=context)
inv = self.browse(cr, uid, [id])[0]
if inv.type == 'in_invoice':
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp