This question has been flagged
12 Replies
9747 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.

Avatar
Discard

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!

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

Gerald, which version do you use, now?

Is this issue resolved, for you?

Best Answer

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?


Regards,

Avatar
Discard
Best Answer

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

Avatar
Discard

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

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
Best Answer

(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', 
                   (production.id,))
        cr.execute('delete from mrp_production_workcenter_line where production_id=%s', 
                   (production.id,))
        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
        else:
            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)

mrp_production()

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
Avatar
Discard
Author

Thanks Ray! I shall try this out.

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.

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?

Where to place this code? Is a module?

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?