diff --git a/addons/account/models/account_analytic_line.py b/addons/account/models/account_analytic_line.py index 83faccaa15c..c5c0d5ed746 100644 --- a/addons/account/models/account_analytic_line.py +++ b/addons/account/models/account_analytic_line.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from openerp import api, fields, models, _ +from math import copysign class AccountAnalyticLine(models.Model): @@ -20,8 +21,12 @@ class AccountAnalyticLine(models.Model): help='Utility field to express amount currency') currency_id = fields.Many2one('res.currency', related='move_id.currency_id', string='Account Currency', store=True, help="The related account currency if not equal to the company one.", readonly=True) amount_currency = fields.Monetary(related='move_id.amount_currency', store=True, help="The amount expressed in the related account currency if not equal to the company one.", readonly=True) + analytic_amount_currency = fields.Monetary(string='Amount Currency', compute="_get_analytic_amount_currency", help="The amount expressed in the related account currency if not equal to the company one.", readonly=True) partner_id = fields.Many2one('res.partner', related='account_id.partner_id', string='Partner', store=True, readonly=True) + def _get_analytic_amount_currency(self): + self.analytic_amount_currency = abs(self.amount_currency) * copysign(1, self.amount) + @api.v8 @api.onchange('product_id', 'product_uom_id', 'unit_amount', 'currency_id') def on_change_unit_amount(self): diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 3606cc8500c..21881e22e9f 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -1254,7 +1254,7 @@ class AccountMoveLine(models.Model): """ Prepare the values used to create() an account.analytic.line upon validation of an account.move.line having an analytic account. This method is intended to be extended in other modules. """ - amount = (self.debit or 0.0) - (self.credit or 0.0) + amount = (self.credit or 0.0) - (self.debit or 0.0) return { 'name': self.name, 'date': self.date, diff --git a/addons/account/views/account_analytic_view.xml b/addons/account/views/account_analytic_view.xml index f28115eedce..4c002c3a3fd 100644 --- a/addons/account/views/account_analytic_view.xml +++ b/addons/account/views/account_analytic_view.xml @@ -15,7 +15,8 @@ - + + diff --git a/addons/stock/views/stock_picking_views.xml b/addons/stock/views/stock_picking_views.xml index da4132b803c..f5881179cc5 100644 --- a/addons/stock/views/stock_picking_views.xml +++ b/addons/stock/views/stock_picking_views.xml @@ -202,6 +202,7 @@