Odoo Help


How do I to update the quantity for finished goods?

Gerald Ngui
on 4/3/13, 1:52 PM 3,549 views

Upon completion of a manufacturing process, the quantities of finished goods completed are more than what was planned for in the manufacturing order.

The manufacturing order does not allow me to change the quantity of the finished goods once I have started the production process. Also could not put the quantities earlier because the exact quantities produced are not known until the completion.

Seeking advice on what is the right way to update the right quantity of finished goods into OpenERP.

Could someone help advise? Thanks in advance.

Gerald, I'm in the exact same situation. Have you figured out a work around or best practice for this situation? Your help would be greatly appreciated. I installed the code below of Ray Carnes, but that function executes before Raw materials are even selected for production. Please help if you can!

tim diamond
on 11/8/14, 5:10 PM

Hi everyone I have the same situation, where to put the code below?? i get error "No handler found" I'm not technical. Help if anybody resolved this issue. Regards

Dritan Meminaj
on 11/9/14, 5:48 PM
On 6/3/15, 11:56 AM

in Odoo 8, is it possible to change quantities of finished products and consumed products in the Manufacturing order because not the same as in the BoM?


On 6/8/14, 5:03 PM

I replaced the original code with your code, I get an error:

Client Traceback (most recent call last): File "/opt/openerp/server/openerp/addons/web/http.py", line 204, in dispatch response["result"] = method(self, **self.params) File "/opt/openerp/server/openerp/addons/web/controllers/main.py", line 1139, in exec_workflow return req.session.exec_workflow(model, id, signal) File "/opt/openerp/server/openerp/addons/web/session.py", line 147, in exec_workflow r = self.proxy('object').exec_workflow(self._db, self._uid, self._password, model, signal, id) File "/opt/openerp/server/openerp/addons/web/session.py", line 30, in proxy_method result = self.session.send(self.service_name, method, *args) File "/opt/openerp/server/openerp/addons/web/session.py", line 103, in send raise xmlrpclib.Fault(openerp.tools.ustr(e), formatted_info) Server Traceback (most recent call last): File "/opt/openerp/server/openerp/addons/web/session.py", line 89, in send return openerp.netsvc.dispatch_rpc(service_name, method, args) File "/opt/openerp/server/openerp/netsvc.py", line 292, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/opt/openerp/server/openerp/service/web_services.py", line 626, in dispatch res = fn(db, uid, *params) File "/opt/openerp/server/openerp/osv/osv.py", line 131, in wrapper return f(self, dbname, *args, **kwargs) File "/opt/openerp/server/openerp/osv/osv.py", line 220, in exec_workflow res = self.exec_workflow_cr(cr, uid, obj, signal, *args) File "/opt/openerp/server/openerp/osv/osv.py", line 213, in exec_workflow_cr return object._workflow_signal(cr, uid, [res_id], signal)[res_id] File "/opt/openerp/server/openerp/osv/orm.py", line 3942, in _workflow_signal result[res_id] = wf_service.trg_validate(uid, self._name, res_id, signal, cr) File "/opt/openerp/server/openerp/workflow/wkf_service.py", line 119, in trg_validate res2 = instance.validate(cr, id, ident, signal) File "/opt/openerp/server/openerp/workflow/instance.py", line 43, in validate workitem.process(cr, witem, ident, signal, force_running, stack=stack) File "/opt/openerp/server/openerp/workflow/workitem.py", line 60, in process ok = _split_test(cr, workitem, activity['split_mode'], ident, signal, stack) File "/opt/openerp/server/openerp/workflow/workitem.py", line 157, in _split_test if wkf_expr.check(cr, workitem, ident, transition,signal): File "/opt/openerp/server/openerp/workflow/wkf_expr.py", line 80, in check return _eval_expr(cr, ident, workitem, transition['condition']) File "/opt/openerp/server/openerp/workflow/wkf_expr.py", line 57, in _eval_expr ret = eval(line, env, nocopy=True) File "/opt/openerp/server/openerp/tools/safe_eval.py", line 241, in safe_eval return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict) File "", line 1, in <module> NameError: name 'test_if_product' is not defined


thx for help

sorry this message for Ray Carnes

Hi, has anybody resolved this issue, I have the same situation the finished goods are not the same with the planned(ordered) quantities on Production Order, we have a change of +1% ore -1% on produced quantities versus confirmed. Is there any solution, workaround or any advice how to do this producing more or les than the confirmed quantinty? Where to place the code gived by Ray Carnes? is this code a module? Please could someone help me? Regards

Dritan Meminaj
on 10/21/14, 6:24 PM

Did you find a solution for this probleme

Le 21 oct. 2014 22:24, "Dritan Meminaj" <dritan.meminaj@gmail.com> a écrit :

Hi, has anybody resolved this issue, I have the same situation the finished goods are not the same with the planned(ordered) quantities on Production Order, we have a change of +1% ore -1% on produced quantities versus confirmed. Is there any solution, workaround or any advice how to do this producing more or les than the confirmed quantinty? Where to place the code gived by Ray Carnes? is this code a module? Please could someone help me? Regards

Dritan Meminaj
Sent by OpenERP S.A. using Odoo about Forum Post False
on 10/21/14, 6:33 PM

Ray Carnes

--Ray Carnes--
| 9 7 9
Greater Los Angeles, United States
--Ray Carnes--

Senior Odoo Analyst

OpenERP 6.1, 7.0; Odoo 8.0, 9.0, 10.0.

Completed Odoo Functional and Technical Training.

Major Skills:

  • User Needs and GAP Analysis;

  • Functional and Technical Design;

  • Prototyping and Proof of Concepts;

  • Requirements Specifications;

  • Agile Implementation;

  • Data Migration;

  • Configuration & Customization (UI and code);

  • Integration - Odoo and non Odoo Applications and Services;

  • Training and Knowledge Transfer;

  • Go Live Support;

  • Helpdesk;

  • Version Upgrades and Migration.

  • Accounting Expert.

I have over 20 years of experience empowering and enabling users with enterprise information systems that make a real and measurable difference in their ability to proactively manage their businesses and organizations. 

I am a skilled Communicator and I only take the serious things seriously!

Ray Carnes
On 7/30/13, 2:10 PM

(This answer courtesy Martin Collins)

The following code overrides mrp_production.action_compute(). Pass the raw_product_id and raw_qty via the context.

# -*- coding: utf-8 -*-

from osv import osv, fields

class mrp_production(osv.osv):
"""Production Order"""
_inherit = 'mrp.production'

def action_compute(self, cr, uid, ids, properties=[], context={}):
    """ Does not modify raw_qty according to product_qty, unlike original
    @param properties: List containing dictionaries of properties.
    @return: No. of products.
    bom_obj = self.pool.get('mrp.bom')
    uom_obj = self.pool.get('product.uom')
    prod_line_obj = self.pool.get('mrp.production.product.line')
    workcenter_line_obj = self.pool.get('mrp.production.workcenter.line')
    products = []

    for production in self.browse(cr, uid, ids):
        cr.execute('delete from mrp_production_product_line where production_id=%s', 
        cr.execute('delete from mrp_production_workcenter_line where production_id=%s', 
        bom_point = production.bom_id
        bom_id = production.bom_id.id
        if not bom_point:
            bom_id = bom_obj._bom_find(cr, uid, production.product_id.id, 
                       production.product_uom.id, properties)
            if bom_id:
                bom_point = bom_obj.browse(cr, uid, bom_id)
                routing_id = bom_point.routing_id.id or False
                self.write(cr, uid, [production.id], {'bom_id': bom_id, 
                     'routing_id': routing_id})

        if not bom_id:
            raise osv.except_osv('Error', "Couldn't find a BoM for this product.")

        if context.get('raw_product_id'):
            factor = 1.0
            factor = uom_obj._compute_qty(cr, uid, production.product_uom.id, 
                 production.product_qty, bom_point.product_uom.id)

        products, work_centers = bom_obj._bom_explode(cr, uid, bom_point,  
          factor / bom_point.product_qty, properties, routing_id=production.routing_id.id)

        for line in products:
            line['production_id'] = production.id
            if line['product_id'] == context.get('raw_product_id'):    # always one
                line['product_qty'] = context.get('raw_qty')
            prod_line_obj.create(cr, uid, line)
        for line in work_centers:
            line['production_id'] = production.id
            workcenter_line_obj.create(cr, uid, line)
    return len(products)


# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

Thanks Ray! I shall try this out.

Cornerstone Infoware, Gerald Ngui
on 7/30/13, 3:46 PM

really? you have to add/change code in order to update actual produced quantities? I guess in 99.95% of any production process the actual quantities do not match what was planned. That is just a reality of production. I think it is very surprising that an ERP application would have no GUI solution for such an everyday scenario. Actually it is hard to believe that.

on 6/9/14, 7:40 PM

sorry I am not technical at all. I think what you have posted is code that you suggest to add to a module right? If I am not on a wrong track here this adds functionality (which I feel is badly needed) to this. So why wouldn't that be added officially to the modules code (then it would be better, right)? Maybe I don't understand the way how Odoo is being developed. Would anyone mind to explain?

on 6/9/14, 7:45 PM

Where to place this code? Is a module?

Dritan Meminaj
on 10/21/14, 8:02 PM

I tried this code. This code executes after hitting the button "Confirm Production". After this gets executed, the materials to be used in production are populated. SO this code does not solve the issue from the OP. The problem is not with the Raw materials, the problem is that for a given number of raw materials, we have an output that varies. We can't be exected to make a new bill of materials every time a production process is run. We need the ability to alter the produced quantities of production. Has anyone solved this problem?

tim diamond
on 11/8/14, 4:58 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

3 follower(s)


Asked: 4/3/13, 1:52 PM
Seen: 3549 times
Last updated: 6/8/16, 4:28 PM