[MERGE] lp: 747056 (removal of do_change_standard_price in mrp/product.py, as we don't want the system to automatically impact the price of product based of change of raw material cost (see https://bugs.launchpad.net/openobject-addons/+bug/702288/comments/21 for further details) + also removed mrp_change_standard_price wizard which was meaningless now)
bzr revid: qdp-launchpad@openerp.com-20111018132202-19f7uaw4zij9jq9w
This commit is contained in:
@@ -75,7 +75,6 @@ Dashboard provided by this module:
|
||||
'wizard/change_production_qty_view.xml',
|
||||
'wizard/mrp_price_view.xml',
|
||||
'wizard/mrp_workcenter_load_view.xml',
|
||||
'wizard/mrp_change_standard_price_view.xml',
|
||||
'mrp_view.xml',
|
||||
'mrp_report.xml',
|
||||
'company_view.xml',
|
||||
|
||||
+2
-36
@@ -53,42 +53,8 @@ class product_product(osv.osv):
|
||||
_columns = {
|
||||
"bom_ids": fields.one2many('mrp.bom', 'product_id','Bill of Materials'),
|
||||
}
|
||||
|
||||
def do_change_standard_price(self, cr, uid, ids, datas, context=None):
|
||||
""" Changes the Standard Price of Product and parent products and creates an account move accordingly.
|
||||
@param datas: dict. contain default datas like new_price, stock_output_account, stock_input_account, stock_journal
|
||||
@param context: A standard dictionary
|
||||
@return:
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
res = super(product_product, self).do_change_standard_price(cr, uid, ids, datas, context=context)
|
||||
bom_obj = self.pool.get('mrp.bom')
|
||||
change = context.get('change_parent_price', False)
|
||||
def _compute_price(bom):
|
||||
price = 0.0
|
||||
if bom.bom_id and change:
|
||||
if bom.bom_id.bom_lines:
|
||||
for bom_line in bom.bom_id.bom_lines:
|
||||
prod_price = self.read(cr, uid, bom_line.product_id.id, ['standard_price'])['standard_price']
|
||||
price += bom_line.product_qty * prod_price
|
||||
|
||||
accounts = self.get_product_accounts(cr, uid, bom.bom_id.product_id.id, context)
|
||||
|
||||
datas = {
|
||||
'new_price': price,
|
||||
'stock_output_account': accounts['stock_account_output'],
|
||||
'stock_input_account': accounts['stock_account_input'],
|
||||
'stock_journal': accounts['stock_journal']
|
||||
}
|
||||
super(product_product, self).do_change_standard_price(cr, uid, [bom.bom_id.product_id.id], datas, context)
|
||||
_compute_price(bom.bom_id)
|
||||
return price
|
||||
|
||||
bom_ids = bom_obj.search(cr, uid, [('product_id', 'in', ids)])
|
||||
|
||||
for bom in bom_obj.browse(cr, uid, bom_ids, context=context):
|
||||
_compute_price(bom)
|
||||
|
||||
# Removed do_change_standard_price for the fix of lp:747056
|
||||
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
if not default:
|
||||
|
||||
@@ -23,7 +23,7 @@ import mrp_product_produce
|
||||
import mrp_price
|
||||
import mrp_workcenter_load
|
||||
import change_production_qty
|
||||
import mrp_change_standard_price
|
||||
#import mrp_change_standard_price
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import fields, osv
|
||||
|
||||
class change_standard_price(osv.osv_memory):
|
||||
_inherit = "stock.change.standard.price"
|
||||
_description = "Change Standard Price"
|
||||
|
||||
_columns = {
|
||||
'change_parent_price': fields.boolean('Change Parent Price', help="This will change the price of parent products also "
|
||||
"according to the BoM structure specified for the product."),
|
||||
}
|
||||
|
||||
|
||||
def change_price(self, cr, uid, ids, context=None):
|
||||
""" Changes the Standard Price of Parent Product according to BoM
|
||||
only when the field 'change_parent_price' is True.
|
||||
And creates an account move accordingly.
|
||||
@param self: The object pointer.
|
||||
@param cr: A database cursor
|
||||
@param uid: ID of the user currently logged in
|
||||
@param ids: List of IDs selected
|
||||
@param context: A standard dictionary
|
||||
@return:
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
res = self.browse(cr, uid, ids, context=context)
|
||||
context.update({'change_parent_price': res[0].change_parent_price})
|
||||
return super(change_standard_price, self).change_price(cr, uid, ids, context=context)
|
||||
|
||||
change_standard_price()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_change_standard_price_inherit" model="ir.ui.view">
|
||||
<field name="name">Change Standard Price (Inherit)</field>
|
||||
<field name="model">stock.change.standard.price</field>
|
||||
<field name="inherit_id" ref="stock.view_change_standard_price"/>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="new_price" position="after">
|
||||
<field name="change_parent_price"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user