diff --git a/stock_inventory_line_price/README.rst b/stock_inventory_line_price/README.rst index cd3499f10c69..777c798243b4 100644 --- a/stock_inventory_line_price/README.rst +++ b/stock_inventory_line_price/README.rst @@ -10,7 +10,7 @@ Standard price at inventory level .. 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/9.0 + :target: https://runbot.odoo-community.org/runbot/153/10.0 Bug Tracker =========== diff --git a/stock_inventory_line_price/__openerp__.py b/stock_inventory_line_price/__manifest__.py similarity index 94% rename from stock_inventory_line_price/__openerp__.py rename to stock_inventory_line_price/__manifest__.py index b848de601427..03b9e8422c06 100644 --- a/stock_inventory_line_price/__openerp__.py +++ b/stock_inventory_line_price/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Standard price at inventory level", - "version": "9.0.1.0.0", + "version": "10.0.1.0.0", "category": "Generic Modules", "author": "OdooMRP team, " "AvanzOSC, " diff --git a/stock_inventory_line_price/models/stock_inventory.py b/stock_inventory_line_price/models/stock_inventory.py index 5998f0f929ac..6f091a43c2a3 100644 --- a/stock_inventory_line_price/models/stock_inventory.py +++ b/stock_inventory_line_price/models/stock_inventory.py @@ -2,15 +2,15 @@ # (c) 2016 Esther Martín - AvanzOSC # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import api, models +from odoo import api, models class StockInventory(models.Model): _inherit = 'stock.inventory' - @api.model - def _get_inventory_lines(self, inventory): - vals = super(StockInventory, self)._get_inventory_lines(inventory) + @api.multi + def _get_inventory_lines_values(self): + vals = super(StockInventory, self)._get_inventory_lines_values() for line in vals: product = self.env['product.product'].browse(line['product_id']) line.update({'theoretical_std_price': product.standard_price, diff --git a/stock_inventory_line_price/models/stock_inventory_line.py b/stock_inventory_line_price/models/stock_inventory_line.py index f4742a1bcf0a..66bcef460f1f 100644 --- a/stock_inventory_line_price/models/stock_inventory_line.py +++ b/stock_inventory_line_price/models/stock_inventory_line.py @@ -2,8 +2,8 @@ # (c) 2016 Esther Martín - AvanzOSC # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import api, fields, models -import openerp.addons.decimal_precision as dp +from odoo import api, fields, models +import odoo.addons.decimal_precision as dp class StockInventoryLine(models.Model): @@ -19,21 +19,28 @@ class StockInventoryLine(models.Model): digits=dp.get_precision('Product Price'), ) - @api.model - def _resolve_inventory_line(self, inventory_line): + @api.multi + def _generate_moves(self): - super_method = super(StockInventoryLine, self)._resolve_inventory_line - theoretical_price = inventory_line.theoretical_std_price - standard_price = inventory_line.standard_price + moves = self.env['stock.move'] - if theoretical_price == standard_price: - return super_method(inventory_line) + for inventory_line in self: - inventory_line.product_id.standard_price = standard_price - move_id = super_method(inventory_line) + super_method = super(StockInventoryLine, record)._generate_moves + theoretical_price = inventory_line.theoretical_std_price + standard_price = inventory_line.standard_price - if move_id: - move = self.env['stock.move'].browse(move_id) - move.price_unit = standard_price + if theoretical_price == standard_price: + moves += super_method() + continue - return move_id + inventory_line.product_id.standard_price = standard_price + super_moves = super_method() + + if super_moves: + super_moves.write({ + 'price_unit': standard_price, + }) + moves += super_moves + + return moves diff --git a/stock_inventory_line_price/tests/test_stock_inventory_line_price.py b/stock_inventory_line_price/tests/test_stock_inventory_line_price.py index 119001a6da4b..1d39c89c3cf5 100644 --- a/stock_inventory_line_price/tests/test_stock_inventory_line_price.py +++ b/stock_inventory_line_price/tests/test_stock_inventory_line_price.py @@ -2,7 +2,7 @@ # © 2016 Esther Martín - AvanzOSC # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -import openerp.tests.common as common +import odoo.tests.common as common class TestStockInventoryLinePrice(common.TransactionCase):