From fb87f1e8fac3b521d81a37531fe75f53581a06f0 Mon Sep 17 00:00:00 2001 From: lreficent Date: Thu, 16 Mar 2017 11:52:48 +0100 Subject: [PATCH] [MIG] account_move_line_stock_info to v10 --- account_move_line_stock_info/README.rst | 5 +- account_move_line_stock_info/__openerp__.py | 2 +- .../models/__init__.py | 1 - .../models/account_move_line.py | 7 +-- .../models/stock_move.py | 11 +++- .../models/stock_quant.py | 18 ------- .../test_account_move_line_stock_move.py | 4 +- .../views/account_move_line_view.xml | 36 ++++++------- .../views/stock_move_view.xml | 52 +++++++++---------- 9 files changed, 63 insertions(+), 73 deletions(-) delete mode 100644 account_move_line_stock_info/models/stock_quant.py diff --git a/account_move_line_stock_info/README.rst b/account_move_line_stock_info/README.rst index b0021ad3f..ede6c70b6 100644 --- a/account_move_line_stock_info/README.rst +++ b/account_move_line_stock_info/README.rst @@ -8,7 +8,6 @@ Account Move Line Stock Move This module adds the stock move to the account move lines that it generates. - Usage ===== @@ -21,8 +20,7 @@ Reports > Stock moves'. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/153/8.0 - + :target: https://runbot.odoo-community.org/runbot/153/10.0 Bug Tracker =========== @@ -40,6 +38,7 @@ Credits Contributors ------------ * Jordi Ballester Alomar +* Lois Rilo Maintainer ---------- diff --git a/account_move_line_stock_info/__openerp__.py b/account_move_line_stock_info/__openerp__.py index ae3e3dc74..7eebb32c4 100644 --- a/account_move_line_stock_info/__openerp__.py +++ b/account_move_line_stock_info/__openerp__.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Account Move Line Stock Move", - "version": "9.0.1.0.0", + "version": "10.0.1.0.0", "depends": [ "stock_account" ], diff --git a/account_move_line_stock_info/models/__init__.py b/account_move_line_stock_info/models/__init__.py index 53b24cfec..587da6c6b 100644 --- a/account_move_line_stock_info/models/__init__.py +++ b/account_move_line_stock_info/models/__init__.py @@ -3,5 +3,4 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import account_move_line -from . import stock_quant from . import stock_move diff --git a/account_move_line_stock_info/models/account_move_line.py b/account_move_line_stock_info/models/account_move_line.py index 932fc0aa6..5f742b441 100644 --- a/account_move_line_stock_info/models/account_move_line.py +++ b/account_move_line_stock_info/models/account_move_line.py @@ -2,11 +2,12 @@ # © 2016 Eficent Business and IT Consulting Services S.L. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import fields, models +from odoo import fields, models class AccountMoveLine(models.Model): _inherit = 'account.move.line' - stock_move_id = fields.Many2one(comodel_name='stock.move', - string='Stock Move', copy=False) + stock_move_id = fields.Many2one( + comodel_name='stock.move', string='Stock Move', copy=False, + index=True) diff --git a/account_move_line_stock_info/models/stock_move.py b/account_move_line_stock_info/models/stock_move.py index b8de1067c..26fc47bf4 100644 --- a/account_move_line_stock_info/models/stock_move.py +++ b/account_move_line_stock_info/models/stock_move.py @@ -2,7 +2,7 @@ # © 2016 Eficent Business and IT Consulting Services S.L. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import fields, models +from odoo import api, fields, models class StockMove(models.Model): @@ -11,3 +11,12 @@ class StockMove(models.Model): account_move_line_ids = fields.One2many( comodel_name='account.move.line', inverse_name='stock_move_id', copy=False) + + @api.model + def _prepare_account_move_line(self, qty, cost, + credit_account_id, debit_account_id): + res = super(StockMove, self)._prepare_account_move_line( + qty, cost, credit_account_id, debit_account_id) + for line in res: + line[2]['stock_move_id'] = self.id + return res diff --git a/account_move_line_stock_info/models/stock_quant.py b/account_move_line_stock_info/models/stock_quant.py deleted file mode 100644 index 0204f0e36..000000000 --- a/account_move_line_stock_info/models/stock_quant.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from openerp import models, api - - -class StockQuant(models.Model): - _inherit = 'stock.quant' - - @api.model - def _prepare_account_move_line(self, move, qty, cost, - credit_account_id, debit_account_id): - res = super(StockQuant, self)._prepare_account_move_line( - move, qty, cost, credit_account_id, debit_account_id) - for line in res: - line[2]['stock_move_id'] = move.id - return res diff --git a/account_move_line_stock_info/tests/test_account_move_line_stock_move.py b/account_move_line_stock_info/tests/test_account_move_line_stock_move.py index 67244a18c..c7b405aec 100644 --- a/account_move_line_stock_info/tests/test_account_move_line_stock_move.py +++ b/account_move_line_stock_info/tests/test_account_move_line_stock_move.py @@ -2,10 +2,10 @@ # © 2015 Eficent Business and IT Consulting Services S.L. (www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from openerp.tests import common +from odoo.tests.common import TransactionCase -class TestAccountMoveLineStockInfo(common.TransactionCase): +class TestAccountMoveLineStockInfo(TransactionCase): def setUp(self): super(TestAccountMoveLineStockInfo, self).setUp() diff --git a/account_move_line_stock_info/views/account_move_line_view.xml b/account_move_line_stock_info/views/account_move_line_view.xml index 161fee8c8..beb05b94b 100644 --- a/account_move_line_stock_info/views/account_move_line_view.xml +++ b/account_move_line_stock_info/views/account_move_line_view.xml @@ -1,26 +1,26 @@ - - account.move.line.form - account.move.line - - - - - + + account.move.line.form + account.move.line + + + + - + + - - account.move.line.form2 - account.move.line - - - - - + + account.move.line.form2 + account.move.line + + + + - + + diff --git a/account_move_line_stock_info/views/stock_move_view.xml b/account_move_line_stock_info/views/stock_move_view.xml index f472a4412..9880ba05a 100644 --- a/account_move_line_stock_info/views/stock_move_view.xml +++ b/account_move_line_stock_info/views/stock_move_view.xml @@ -1,35 +1,35 @@ - - stock.move.form - stock.move - - - - - - + + stock.move.form + stock.move + + + + + - - + + + - - stock.move.form - stock.move - - - - - - + + stock.move.form + stock.move + + + + + - - + + +