mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[IMP] The button to change standard price in product form now creates an inventory revaluation, instead of directly posting the journal entries.
This commit is contained in:
committed by
Jordi Ballester Alomar
parent
f4049e128d
commit
f6893e2b29
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user