Skip to content

Commit

Permalink
[MIG] stock_inventory_line_price: Upgrade to v10
Browse files Browse the repository at this point in the history
* Rename manifest
* Bump versions
* Openerp references to Odoo
* Upgrade _resolve_inventory_lines to v10 _generate_moves
* Upgrade _get_inventory_lines to v10 _get_inventory_lines_values
  • Loading branch information
lasley committed Apr 22, 2017
1 parent c48e8c9 commit 97dd49d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion stock_inventory_line_price/README.rst
Expand Up @@ -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
===========
Expand Down
Expand Up @@ -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, "
Expand Down
8 changes: 4 additions & 4 deletions stock_inventory_line_price/models/stock_inventory.py
Expand Up @@ -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,
Expand Down
37 changes: 22 additions & 15 deletions stock_inventory_line_price/models/stock_inventory_line.py
Expand Up @@ -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):
Expand All @@ -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
Expand Up @@ -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):
Expand Down

0 comments on commit 97dd49d

Please sign in to comment.