diff --git a/stock_inventory_revaluation/README.rst b/stock_inventory_revaluation/README.rst index b41fa5e45..b87245140 100644 --- a/stock_inventory_revaluation/README.rst +++ b/stock_inventory_revaluation/README.rst @@ -38,7 +38,9 @@ Usage ===== * Go to *Inventory / Inventory Control / Inventory Revaluation / Products* - to create a new Inventory Revaluation. + to create a new Inventory Revaluation. For products set with average or + standard price and real-time valuation, go to the Product form and use the + link to change the standard price. * In order to post the inventory revaluation for multiple items at once, select the records in the tree view and go to diff --git a/stock_inventory_revaluation/__openerp__.py b/stock_inventory_revaluation/__openerp__.py index 2ec2494cd..75e67d7f3 100644 --- a/stock_inventory_revaluation/__openerp__.py +++ b/stock_inventory_revaluation/__openerp__.py @@ -12,7 +12,7 @@ "Odoo Community Association (OCA)", "website": "http://www.eficent.com", "category": "Warehouse", - "depends": ["stock_account"], + "depends": ["stock_account", "product"], "license": "AGPL-3", "data": [ "wizards/stock_inventory_revaluation_get_quants_view.xml", diff --git a/stock_inventory_revaluation/models/product.py b/stock_inventory_revaluation/models/product.py index ece98eb99..f2910a001 100644 --- a/stock_inventory_revaluation/models/product.py +++ b/stock_inventory_revaluation/models/product.py @@ -2,7 +2,7 @@ # © 2015 Eficent Business and IT Consulting Services S.L. # - Jordi Ballester Alomar # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from openerp import fields, models +from openerp import api, fields, models class ProductCategory(models.Model): @@ -24,3 +24,33 @@ class ProductCategory(models.Model): "account in the transaction created by the revaluation. " "The Valuation Decrease Account is used when the inventory value " "is decreased.") + + +class ProductTemplate(models.Model): + + _inherit = 'product.template' + + @api.multi + def do_change_standard_price(self, new_price): + """Override standard method, as it was not suitable.""" + reval_model = self.env["stock.inventory.revaluation"] + for product_template in self: + increase_account_id = \ + product_template.categ_id.\ + property_inventory_revaluation_increase_account_categ.id \ + or False + decrease_account_id = \ + product_template.categ_id.\ + property_inventory_revaluation_decrease_account_categ.id \ + or False + + reval = reval_model.create({ + 'revaluation_type': 'price_change', + 'product_template_id': product_template.id, + 'new_cost': new_price, + 'increase_account_id': increase_account_id, + 'decrease_account_id': decrease_account_id + }) + reval.post() + return True +