[IMP] Code impovement

This commit is contained in:
vrenaville
2014-12-01 09:32:35 +01:00
parent dcef3a73b2
commit fb90cda388

View File

@@ -27,37 +27,33 @@ class payment_order_create(orm.TransientModel):
def create_payment(self, cr, uid, ids, context=None): def create_payment(self, cr, uid, ids, context=None):
""" """
We recreate function to be able set We add is_multi_currency tag to be able set
'amount_currency': line.amount_residual_currency 'amount_currency': line.amount_residual_currency
instead of instead of
'amount_currency': line.amount_to_pay 'amount_currency': line.amount_to_pay
To be compliant with multi currency To be compliant with multi currency
Allready corrected in V8 but will not be corrected in V7 Allready corrected in V8 but will not be corrected in V7
""" """
res = super(payment_order_create, self).create_payment(cr, context.update({'is_multi_currency': True})
return super(payment_order_create, self).create_payment(
cr,
uid, uid,
ids, ids,
context=context) context=context)
line_obj = self.pool.get('account.move.line')
payment_obj = self.pool.get('payment.line')
data = self.browse(cr, uid, ids, context=context)[0] class payment_line(orm.Model):
line_ids = [entry.id for entry in data.entries] _inherit = 'payment.line'
if not line_ids:
return res def create(self, cr, uid, vals, context=None):
# Finally populate the current payment with new lines: """In case of multi currency
for line in line_obj.browse(cr, uid, line_ids, context=context): we use amount_residual_currency instead of amount_to_pay"""
payment_line_id = payment_obj.search(cr, uid, if context.get('is_multi_currency'):
[('move_line_id', account_move_line_obj = self.pool['account.move.line']
'=', move_line = account_move_line_obj.browse(
line.id)],
context=context)
if payment_line_id:
payment_obj.write(
cr, cr,
uid, uid,
payment_line_id, vals['move_line_id'],
{'amount_currency': line.amount_residual_currency}, context=context)
context=context vals['amount_currency'] = move_line.amount_residual_currency
) return super(payment_line, self).create(cr, uid, vals, context=context)
return res