|
@@ -79,17 +79,8 @@ class PaymentsSales(http.Controller):
|
|
|
if moveline.amount_residual > 0 and moveline.state != "draft" and moveline.credit <= 0:
|
|
|
currencyAmount = []
|
|
|
decimal_precision = request.env['decimal.precision'].precision_get('Account')
|
|
|
- # print("\n\n")
|
|
|
- # # accountConfig = request.env['account.config.settings']
|
|
|
- # import web_pdb; web_pdb.set_trace()
|
|
|
- # print(request.env.user)
|
|
|
- # print("\n")
|
|
|
-
|
|
|
- # if (request.env.user.in_group_7):
|
|
|
- # domain = [[('active', '=', True)], ['id', '=', user.company_id.currency_id.id]]
|
|
|
- # else:
|
|
|
- domain = [('active', '=', True)]
|
|
|
|
|
|
+ domain = [('active', '=', True)]
|
|
|
|
|
|
for currency in request.env['res.currency'].search(domain):
|
|
|
amount_currency = moveline.amount_currency
|
|
@@ -311,11 +302,18 @@ class PaymentsSales(http.Controller):
|
|
|
# get customer
|
|
|
customerId = request.env['res.partner'].browse(customerId)
|
|
|
decimal_precision = request.env['decimal.precision'].precision_get('Account')
|
|
|
+ # Currencies
|
|
|
+ company_currency = request.env.user.company_id.currency_id
|
|
|
+ currencyVocuher = request.env['res.currency'].browse(currency_id)
|
|
|
# Create Line Voucher
|
|
|
line_cr_ids = []
|
|
|
amount = round(float(amountPayments), decimal_precision)
|
|
|
|
|
|
for line in move_line:
|
|
|
+ amount_residual = line.amount_residual
|
|
|
+ if (company_currency.id != currencyVocuher.id):
|
|
|
+ amount_residual = round((amount_residual * (currencyVocuher.rate / company_currency.rate)), decimal_precision)
|
|
|
+
|
|
|
line_cr_ids.append([0, False, {
|
|
|
'date_due': line.date_maturity,
|
|
|
'account_id': line.account_id.id,
|
|
@@ -323,14 +321,11 @@ class PaymentsSales(http.Controller):
|
|
|
'move_line_id': line.id,
|
|
|
'amount_original': abs(line.credit or line.debit or 0.0),
|
|
|
'amount_unreconciled': abs(line.amount_residual),
|
|
|
- 'amount': min(abs(amount), line.amount_residual),
|
|
|
- 'reconcile': True if abs(line.amount_residual) == min(abs(amount), line.amount_residual) else False,
|
|
|
+ 'amount': min(abs(amount), abs(amount_residual)),
|
|
|
+ 'reconcile': True if abs(amount_residual) == min(abs(amount), abs(amount_residual)) else False,
|
|
|
'currency_id': currency_id
|
|
|
}])
|
|
|
- amount -= min(abs(amount), line.amount_residual)
|
|
|
-
|
|
|
- company_currency = request.env.user.company_id.currency_id
|
|
|
- currencyVocuher = request.env['res.currency'].browse(currency_id)
|
|
|
+ amount -= min(abs(amount), amount_residual)
|
|
|
|
|
|
values = {
|
|
|
'reference': invoice.number,
|
|
@@ -360,10 +355,10 @@ class PaymentsSales(http.Controller):
|
|
|
invoice = request.env['account.invoice'].search([('id', '=', invoiceid)])
|
|
|
|
|
|
if invoice.residual <= 0:
|
|
|
- invoice.write({
|
|
|
- 'state': 'paid'
|
|
|
- })
|
|
|
- # invoice.confirm_paid()
|
|
|
+ # invoice.write({
|
|
|
+ # 'state': 'paid'
|
|
|
+ # })
|
|
|
+ invoice.confirm_paid()
|
|
|
return invoice
|
|
|
|
|
|
'''
|