-
Notifications
You must be signed in to change notification settings - Fork 108
10.0 17012018 #95
base: 10.0
Are you sure you want to change the base?
10.0 17012018 #95
Conversation
|
|
||
| journal = self.env.ref(journal_ref) | ||
|
|
||
| currency_id = currency and self.env['res.currency'].search([('name', '=', currency)], limit=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a way to use different currency names, e.g.
RUB
РУБ
рублей
рубля
рубль
руб
руб.
р.
| currency_ids = all_currencies_line_ids.mapped('currency_id') | ||
| for currency_id in currency_ids: | ||
| balance += sum(all_currencies_line_ids.filtered(lambda r: r.currency_id == currency_id).mapped('balance')) * currency_id.rate | ||
| balance += self.get_currency_balance(currency=base_currency) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
base_currency might not have rate 1, so you need to dived after computing sum,
e.g
base_currency = RUB, rate = 0.017
EUR = 1.2
USD = 1
Then without dividing you will get sum in USD rather than in base_currency
…ls then search in aliases
|
@yelizariev , done |
| for currency_id in currency_ids: | ||
| balance += sum(all_currencies_line_ids.filtered(lambda r: r.currency_id == currency_id).mapped('balance')) * currency_id.rate | ||
| rate = self.env['res.currency']._get_conversion_rate(base_currency, currency_id) | ||
| balance += sum(all_currencies_line_ids.filtered(lambda r: r.currency_id == currency_id).mapped('balance')) * rate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
| class Currency(models.Model): | ||
| _inherit = "res.currency" | ||
|
|
||
| alias_ids = fields.One2many('res.currency.alias', 'currency_id', string='Aliases') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
| journal = self.env.ref(journal_ref) | ||
|
|
||
| currency_id = currency and self.env['res.currency'].search([('name', '=', currency)], limit=1) | ||
| currency_alias = currency and self.env['res.currency.alias'].sudo().search([('name', '=', currency)], limit=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should not make search if currency_id is already known
|
@yelizariev , done |
| currency_alias = currency and self.env['res.currency.alias'].sudo().search([('name', '=', currency)], limit=1) | ||
| currency_id = currency_id or currency_alias and currency_alias.currency_id | ||
| currency_id = currency and (self.env['res.currency'].search([('name', '=', currency)], limit=1) \ | ||
| or self.env['res.currency.alias'].sudo().search([('name', '=', currency)], limit=1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currency_id is res.currency or res.currency.alias?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
…no currency found
…t.move.line - all lines without currency_id are concidered as in base currency
No description provided.