clearcorp team mailing list archive
-
clearcorp team
-
Mailing list archive
-
Message #00534
[Merge] lp:~ss-dtic/openerp-ccorp-addons/6.1-bom-price-update into lp:openerp-ccorp-addons
Miguel Gutierrez has proposed merging lp:~ss-dtic/openerp-ccorp-addons/6.1-bom-price-update into lp:openerp-ccorp-addons.
Requested reviews:
CLEARCORP drivers (clearcorp-drivers)
For more details, see:
https://code.launchpad.net/~ss-dtic/openerp-ccorp-addons/6.1-bom-price-update/+merge/143353
--
https://code.launchpad.net/~ss-dtic/openerp-ccorp-addons/6.1-bom-price-update/+merge/143353
Your team CLEARCORP development team is subscribed to branch lp:openerp-ccorp-addons.
=== added directory 'bom_price_update'
=== added file 'bom_price_update/__init__.py'
--- bom_price_update/__init__.py 1970-01-01 00:00:00 +0000
+++ bom_price_update/__init__.py 2013-01-15 16:45:38 +0000
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Addons modules by SIESA
+# Copyright (C) 2009-TODAY Soluciones Industriales Electromecanicas S.A. (<http://siesacr.com>).
+#
+# 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/>.
+#
+##############################################################################
+
+import mrp
=== added file 'bom_price_update/__openerp__.py'
--- bom_price_update/__openerp__.py 1970-01-01 00:00:00 +0000
+++ bom_price_update/__openerp__.py 2013-01-15 16:45:38 +0000
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Addons modules by SIESA
+# Copyright (C) 2009-TODAY Soluciones Industriales Electromecanicas S.A. (<http://siesacr.com>).
+#
+# 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/>.
+#
+##############################################################################
+
+{
+ "name" : "MRP Bom Updater",
+ "version" : "1.0",
+ "author" : "SIESA",
+ "category" : "Generic Modules/Inventory Control",
+ "depends" : ["procurement", "stock", "resource", "purchase", "product","process","mrp"],
+ 'complexity': "easy",
+ "website" : "http://www.siesacr.com",
+ "description": """
+ This module update the price of 1 product when BOM is created.
+ """,
+ 'update_xml': [
+
+ ],
+ 'installable': True,
+ 'active': False,
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== added file 'bom_price_update/mrp.py'
--- bom_price_update/mrp.py 1970-01-01 00:00:00 +0000
+++ bom_price_update/mrp.py 2013-01-15 16:45:38 +0000
@@ -0,0 +1,79 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Addons modules by SIESA
+# Copyright (C) 2009-TODAY Soluciones Industriales Electromecanicas S.A. (<http://siesacr.com>).
+#
+# 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 osv, fields
+import decimal_precision as dp
+import math
+import logging
+import re
+from tools.translate import _
+
+class mrp_bom(osv.osv):
+ _inherit ='mrp.bom'
+ def create(self, cr, uid, vals, context=None):
+ res = super(mrp_bom, self).create(cr, uid, vals, context)
+ part_obj = self.pool.get('res.partner')
+ bom = self.pool.get('mrp.bom').browse(cr, uid, res, context=context)
+ product = bom.product_id
+ standard_price = 0
+ list_price = 0
+
+ for line in bom.bom_lines:
+ standard_price = standard_price + line.product_id.standard_price * line.product_qty
+ list_price = list_price + line.product_id.list_price * line.product_qty
+ standard_price = standard_price / bom.product_qty
+ list_price = list_price / bom.product_qty
+
+ if standard_price >0 and list_price >0:
+ product.write({'standard_price': standard_price}, context=context)
+ product.write({'list_price': list_price}, context=context)
+
+ return res
+
+ def write(self, cr, uid, ids, vals, context=None):
+ res = super(mrp_bom, self).write(cr, uid, ids, vals, context=context)
+ bom_obj = self.pool.get('mrp.bom')
+ prod_obj = self.pool.get('mrp.production')
+ list_bom = self.pool.get('mrp.bom').browse(cr, uid, ids, context=context)
+ prods_ids = prod_obj.search(cr, uid, [('bom_id','in',ids),('state','in',['confirmed','ready','in_production'])], context=context)
+ standard_price = 0
+ list_price = 0
+
+
+ for bom in list_bom:
+ new_prods = []
+ product = bom.product_id
+
+ for line in bom.bom_lines:
+ standard_price = standard_price + line.product_id.standard_price * line.product_qty
+ list_price = list_price + line.product_id.list_price * line.product_qty
+ standard_price = standard_price / bom.product_qty
+ list_price = list_price / bom.product_qty
+
+ if standard_price >0 and list_price >0:
+ product.write({'standard_price': standard_price}, context=context)
+ product.write({'list_price': list_price}, context=context)
+
+
+ return res
+
+mrp_bom()
Follow ups