Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
5122 Lượt xem

I'n Odoo9 there is method

@api.one
@api.depends(
'state', 'currency_id', 'invoice_line_ids.price_subtotal',
'move_id.line_ids.amount_residual',
'move_id.line_ids.currency_id')
def _compute_residual(self):
residual = 0.0
residual_company_signed = 0.0
sign = self.type in ['in_refund', 'out_refund'] and -1 or 1
for line in self.sudo().move_id.line_ids:
if line.account_id.internal_type in ('receivable', 'payable'):
residual_company_signed += line.amount_residual
if line.currency_id == self.currency_id:
residual += line.amount_residual_currency if line.currency_id else line.amount_residual
else:
from_currency = (line.currency_id and line.currency_id.with_context(date=line.date)) or line.company_id.currency_id.with_context(date=line.date)
residual += from_currency.compute(line.amount_residual, self.currency_id)
self.residual_company_signed = abs(residual_company_signed) * sign
self.residual_signed = abs(residual) * sign
self.residual = abs(residual)
digits_rounding_precision = self.currency_id.rounding
if float_is_zero(self.residual, precision_rounding=digits_rounding_precision):
self.reconciled = True
else:
self.reconciled = False

in Vendor Bills if in line account selected is payable then when confirming invoice, residual amount gets double. is there any solution that can fix this?




Ảnh đại diện
Huỷ bỏ

what's the purpose to pass payable/receivable account on line level

Tác giả Câu trả lời hay nhất

Actually, I found a workaround for this problem

@api.one
@api.depends(
'state', 'currency_id',
'move_id.line_ids.amount_residual',
# Fixes the fact that move_id.line_id.amount_residual, being not stored and old API, doesn't trigger recomputation
'move_id.line_ids.reconcile_id',
'move_id.line_ids.amount_residual_currency',
'move_id.line_ids.currency_id',
# 'move_id.line_ids.reconcile_partial_id.line_partial_ids.invoice.type',
)
# An invoice's residual amount is the sum of its unreconciled move lines and,
# for partially reconciled move lines, their residual amount divided by the
# number of times this reconciliation is used in an invoice (so we split
# the residual amount between all invoice)
def _compute_residual(self):
self.residual = 0.0
# Each partial reconciliation is considered only once for each invoice it appears into,
# and its residual amount is divided by this number of invoices
partial_reconciliations_done = []
residual = 0.00
for line in self.sudo().move_id.line_ids:

if line.account_id.id == self.account_id.id:
# Get the correct line residual amount
if line.currency_id == self.currency_id:
line_amount = line.currency_id and line.amount_residual_currency or line.amount_residual
else:
from_currency = line.company_id.currency_id.with_context(date=line.date)
line_amount = from_currency.compute(line.amount_residual, self.currency_id)
# For partially reconciled lines, split the residual amount
if line.reconcile_partial_id:
partial_reconciliation_invoices = set()
for pline in line.reconcile_partial_id.line_partial_ids:
if pline.invoice and self.type == pline.invoice.type:
partial_reconciliation_invoices.update([pline.invoice.id])
line_amount = self.currency_id.round(line_amount / len(partial_reconciliation_invoices))
partial_reconciliations_done.append(line.reconcile_partial_id.id)
residual += line_amount
self.residual = residual
Ảnh đại diện
Huỷ bỏ

Follow the statdards or else workflow will not work.

You can try like this.

@api.one

@api.depends(

'state', 'currency_id', 'invoice_line_ids.price_subtotal',

'move_id.line_ids.amount_residual',

'move_id.line_ids.currency_id')

def _compute_residual(self):

residual = 0.0

residual_company_signed = 0.0

sign = self.type in ['in_refund', 'out_refund'] and -1 or 1

for line in self.sudo().move_id.line_ids:

if line.account_id == self.account_id:

residual_company_signed += line.amount_residual

if line.currency_id == self.currency_id:

residual += line.amount_residual_currency if line.currency_id else line.amount_residual

else:

from_currency = (line.currency_id and line.currency_id.with_context(date=line.date)) or line.company_id.currency_id.with_context(date=line.date)

residual += from_currency.compute(line.amount_residual, self.currency_id)

self.residual_company_signed = abs(residual_company_signed) * sign

self.residual_signed = abs(residual) * sign

self.residual = abs(residual)

digits_rounding_precision = self.currency_id.rounding

if float_is_zero(self.residual, precision_rounding=digits_rounding_precision):

self.reconciled = True

else:

self.reconciled = False

Câu trả lời hay nhất

Yes, Odoo by default it will sum all payable and receivable amount_residual from invoice related Journal Entry.
You can't pass payable/receivable accounts on Line level.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 10 22
2753
0
thg 11 23
998
0
thg 2 21
2293
1
thg 12 19
6880
0
thg 3 20
1809