[12.0][FIX] account_spread_cost_revenue: convert total amount to spread currency
This commit is contained in:
parent
f8133b25ad
commit
27494b106d
@ -170,15 +170,28 @@ class AccountSpread(models.Model):
|
||||
})
|
||||
|
||||
@api.depends(
|
||||
'estimated_amount', 'invoice_line_id.price_subtotal',
|
||||
'line_ids.move_id.amount', 'line_ids.move_id.state')
|
||||
"estimated_amount",
|
||||
"currency_id",
|
||||
"company_id",
|
||||
"invoice_line_id.price_subtotal",
|
||||
"invoice_line_id.currency_id",
|
||||
"line_ids.amount",
|
||||
"line_ids.move_id.state",
|
||||
)
|
||||
def _compute_amounts(self):
|
||||
for spread in self:
|
||||
moves_amount = 0.0
|
||||
posted_amount = 0.0
|
||||
total_amount = spread.estimated_amount
|
||||
if spread.invoice_line_id:
|
||||
total_amount = spread.invoice_line_id.price_subtotal
|
||||
invoice = spread.invoice_line_id.invoice_id
|
||||
total_amount = spread.invoice_line_id.currency_id._convert(
|
||||
spread.invoice_line_id.price_subtotal,
|
||||
spread.currency_id,
|
||||
spread.company_id,
|
||||
invoice._get_currency_rate_date() or fields.Date.today()
|
||||
)
|
||||
|
||||
for spread_line in spread.line_ids:
|
||||
if spread_line.move_id:
|
||||
moves_amount += spread_line.amount
|
||||
|
@ -34,7 +34,8 @@ class AccountSpreadTemplate(models.Model):
|
||||
exp_rev_account_id = fields.Many2one(
|
||||
'account.account',
|
||||
string='Expense/Revenue Account',
|
||||
help="Optional account to overwrite the existing expense/revenue account")
|
||||
help="Optional account to overwrite the existing expense/revenue "
|
||||
"account")
|
||||
period_number = fields.Integer(
|
||||
string='Number of Repetitions',
|
||||
help="Define the number of spread lines")
|
||||
|
@ -71,7 +71,8 @@ class AccountSpreadInvoiceLineLinkWizard(models.TransientModel):
|
||||
exp_rev_account_id = fields.Many2one(
|
||||
'account.account',
|
||||
string='Expense/revenue account',
|
||||
help="Optional account to overwrite the existing expense/revenue account")
|
||||
help="Optional account to overwrite the existing expense/revenue "
|
||||
"account")
|
||||
spread_journal_id = fields.Many2one(
|
||||
'account.journal',
|
||||
string='Spread Journal',
|
||||
@ -152,6 +153,7 @@ class AccountSpreadInvoiceLineLinkWizard(models.TransientModel):
|
||||
analytic_account = self.invoice_line_id.account_analytic_id
|
||||
analytic_tags = self.invoice_line_id.analytic_tag_ids
|
||||
date_invoice = self.invoice_id.date_invoice or fields.Date.today()
|
||||
use_il_account = self.use_invoice_line_account
|
||||
|
||||
return {
|
||||
'name': _('New Spread Board'),
|
||||
@ -165,7 +167,7 @@ class AccountSpreadInvoiceLineLinkWizard(models.TransientModel):
|
||||
'default_name': self.invoice_line_id.name,
|
||||
'default_invoice_type': self.invoice_type,
|
||||
'default_invoice_line_id': self.invoice_line_id.id,
|
||||
'default_use_invoice_line_account': self.use_invoice_line_account,
|
||||
'default_use_invoice_line_account': use_il_account,
|
||||
'default_debit_account_id': debit_account.id,
|
||||
'default_credit_account_id': credit_account.id,
|
||||
'default_journal_id': self.spread_journal_id.id,
|
||||
|
Loading…
x
Reference in New Issue
Block a user