I want to related amount line with currency for create analytic entries.
@api.multi
def action_test(self):
for order in self:
for line in order.order_line:
amount = (self.credit or 0.0) - (self.debit or 0.0)
if line.account_analytic_id:
vals_line= {
'name': line.name,
'date': order.date_order,
'account_id': line.account_analytic_id.id,
'tag_ids': [(6, 0, line.analytic_tag_ids.ids)],
'unit_amount': line.product_qty,
'product_id': line.product_id and line.product_id.id or False,
'amount': order.company_currency_id.with_context(date=order.date_order or fields.Date.context_today(self)).compute(amount, line.account_analytic_id.currency_id) if line.account_analytic_id.currency_id else amount,
#'general_account_id': self.account_id.id,
#'ref': order.ref,
'move_id': line.id,
#'user_id': order.invoice_id.user_id.id or self._uid,
}
self.env['account.analytic.line'].create(vals_line)
If you want return amount then add a blank field(float or integer) similar to amount field and try that:
vals_line = {
'amount' : line.amount
}