diff --git a/rma_analytic/README.rst b/rma_analytic/README.rst index 428285f4..e6c5422e 100644 --- a/rma_analytic/README.rst +++ b/rma_analytic/README.rst @@ -26,9 +26,10 @@ Contributors ------------ * Aaron Henriquez +* Serpent Consulting Services Pvt. Ltd. Maintainer ---------- -This module is maintained by Eficent. \ No newline at end of file +This module is maintained by Eficent. diff --git a/rma_analytic/__manifest__.py b/rma_analytic/__manifest__.py index 5473444b..b573cd2e 100644 --- a/rma_analytic/__manifest__.py +++ b/rma_analytic/__manifest__.py @@ -10,7 +10,8 @@ "license": "LGPL-3", "website": "http://www.eficent.com", "category": "Analytic", - "depends": ["rma", "analytic", "procurement_analytic"], + "depends": ["rma", "analytic", "procurement_analytic", + 'stock_analytic_account'], "data": [ "views/rma_order_line_view.xml" ], diff --git a/rma_analytic/models/procurement.py b/rma_analytic/models/procurement.py index 022cf5d6..f3203d42 100644 --- a/rma_analytic/models/procurement.py +++ b/rma_analytic/models/procurement.py @@ -9,11 +9,11 @@ class ProcurementOrder(models.Model): _inherit = "procurement.order" - -@api.constrains('analytic_account_id') -def check_analytic(self): - for order in self: - if order.analytic_account_id != order.rma_line_id.analytic_account_id: - raise exceptions.ValidationError( - _("The analytic account in the procurement it's not the same" - " as in the rma line")) + @api.constrains('analytic_account_id') + def check_analytic(self): + for order in self: + if (order.analytic_account_id != + order.rma_line_id.analytic_account_id): + raise exceptions.ValidationError( + _("The analytic account in the procurement it's not the " + "same as in the rma line")) diff --git a/rma_analytic/models/rma_order_line.py b/rma_analytic/models/rma_order_line.py index 5e8706dd..3b9f20d0 100644 --- a/rma_analytic/models/rma_order_line.py +++ b/rma_analytic/models/rma_order_line.py @@ -10,6 +10,6 @@ class RmaOrderLine(models.Model): _inherit = "rma.order.line" analytic_account_id = fields.Many2one( - comodel_name='account.analytic', + comodel_name='account.analytic.account', string='Analytic Account', ) diff --git a/rma_analytic/tests/__init__.py b/rma_analytic/tests/__init__.py index 0acaa35f..02fc8a66 100644 --- a/rma_analytic/tests/__init__.py +++ b/rma_analytic/tests/__init__.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- +# © 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import test_rma_analytic diff --git a/rma_analytic/tests/test_rma_analytic.py b/rma_analytic/tests/test_rma_analytic.py index 7ddac0da..fdff1c61 100644 --- a/rma_analytic/tests/test_rma_analytic.py +++ b/rma_analytic/tests/test_rma_analytic.py @@ -2,7 +2,7 @@ # © 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) -from . import test_rma +from odoo.addons.rma.tests import test_rma class TestRmaAnalytic(test_rma.TestRma): @@ -11,20 +11,22 @@ class TestRmaAnalytic(test_rma.TestRma): super(TestRmaAnalytic, self).setUp() products2move = [(self.product_1, 3), (self.product_2, 5), (self.product_3, 2)] - self.rma_id = self._create_rma_from_move( + self.rma_ana_id = self._create_rma_from_move( products2move, 'supplier', self.env.ref('base.res_partner_1'), dropship=False) - self.analytic_1 = self.env['account.analytic.account'].create({ + + def _prepare_move(self, product, qty, src, dest, picking_in): + res = super(TestRmaAnalytic, self)._prepare_move( + product, qty, src, dest, picking_in) + analytic_1 = self.env['account.analytic.account'].create({ 'name': 'Test account #1', }) - - def _prepare_move(self, product, qty, src, dest): - res = super(TestRmaAnalytic, self)._prepare_move( - product, qty, src, dest) - res.update(analytic_account_id=self.analytic_1.id) + res.update({'analytic_account_id': analytic_1.id}) return res def test_analytic(self): - for line in self.rma_id.line_ids: - self.assertEqual(line.analytic_account_id, self.analytic_1, - "the analytic account is not propagated") + for line in self.rma_ana_id.rma_line_ids: + for move in line.move_ids: + self.assertEqual( + line.analytic_account_id, move.analytic_account_id, + "the analytic account is not propagated")