Odoo Help

Welcome!

This community 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.

0

Problem when I try to duplicate a bom

By
Tajjajt
on 4/9/13, 2:22 PM 2,289 views

Hello,

My problem is that when I try to "Duplicate" my BOM I have this error :

Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/netsvc.py", line 489, in dispatch
    result = ExportService.getService(service_name).dispatch(method, auth, params)
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/service/web_services.py", line 599, in dispatch
    res = fn(db, uid, *params)
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/osv/osv.py", line 122, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/osv/osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/osv/osv.py", line 167, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/osv/orm.py", line 4187, in copy
    data = self.copy_data(cr, uid, id, default, context)
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/addons/mrp.zip/mrp/mrp.py", line 361, in copy_data
    return super(mrp_bom, self).copy_data(cr, uid, id, default, context=context)
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/osv/orm.py", line 4107, in copy_data
    d = rel.copy_data(cr, uid, rel_id, context=context)
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/addons/mrp.zip/mrp/mrp.py", line 360, in copy_data
    default.update({'name': bom_data['name'] + ' ' + _('Copy'), 'bom_id':False})
TypeError: unsupported operand type(s) for +: 'bool' and 'str'

I can't figure out the source of the problem?? help plz !

1

Naresh Soni (nch)

--Naresh Soni (nch)--
Tiny ERP Pvt Ltd
http://www.odoo.com
1281
| 2 2 4
India
--Naresh Soni (nch)--

Team Lead, Odoo(Formerly OpenERP) Support & OPW

Naresh Soni (nch)
On 4/9/13, 2:28 PM

Hi Tajjat,

TypeError: unsupported operand type(s) for +: 'bool' and 'str'

This means that you are trying to join a Boolean(True/False) with string value. It seems in your case bom_data['name'] is having a value of either False/True.

you can try to replace the code by

default.update({'name': bom_data.get('name','') + ' ' + _('Copy'), 'bom_id':False})

Or try to see why you are getting the value of bom_data['name'] to False/True.

Thanks

which code to replace by : default.update({'name': bom_data.get('name','') + ' ' + _('Copy'), 'bom_id':False})?????

Tajjajt
on 4/9/13, 3:00 PM

File "/usr/local/lib/python2.6/dist-packages/openerp-server/addons/mrp.zip/mrp/mrp.py", line 360, in copy_data default.update({'name': bom_data['name'] + ' ' + _('Copy'), 'bom_id':False})

Naresh Soni (nch)
on 4/10/13, 3:39 AM

I create an inherite module that modify the function "copy_data", but i have this erreur

Traceback (most recent call last):
  File "netsvc.pyo", line 489, in dispatch
  File "service\web_services.pyo", line 599, in dispatch
  File "osv\osv.pyo", line 122, in wrapper
  File "osv\osv.pyo", line 176, in execute
  File "osv\osv.pyo", line 167, in execute_cr
  File "osv\orm.pyo", line 4187, in copy
  File "C:\Program Files\OpenERP 6.0\Server\addons\mrp_copy4\bom.py", line 35, in copy_data
KeyError: ('name', ' ')
Tajjajt
on 4/10/13, 10:58 AM

Tajjat, whatever you do just be sure bom_data dict has a key 'name' with a non boolean value

Naresh Soni (nch)
on 4/10/13, 11:32 AM

I modify the function, here my code

class mrp_bom(osv.osv):

    _inherit = "mrp.bom"

    def copy_data(self, cr, uid, id, default=None, context=None):
        if default:
            default.update({
            'name': self.pool.get('ir.sequence').get(cr, uid, 'mrp.bom'),
        })
        return super(mrp_bom, self).copy_data(cr, uid, id, default, context)

    _columns = {
         }

mrp_bom()

But stil have the error :

Traceback (most recent call last):   File "/usr/local/lib/python2.6/dist-packages/openerp-server/netsvc.py", line 489, in dispatch
Tajjajt
on 4/10/13, 1:20 PM

File "/usr/local/lib/python2.6/dist-packages/openerp-server/addons/mrp_copy.zip/mrp_copy/bom.py", line 35, in copy_data return super(mrp_bom, self).copy_data(cr, uid, id, default, context) File "/usr/local/lib/python2.6/dist-packages/openerp-server/addons/mrp.zip/mrp/mrp.py", line 360, in copy_data default.update({'name': bom_data['name'] + ' ' + _('Copy'), 'bom_id':False}) TypeError: unsupported operand type(s) for +: 'bool' and 'str'

Tajjajt
on 4/10/13, 1:20 PM

Tajjajt ! Your inheritence doesn't make anything new ! :) Instead you should make sure the BOM you are duplicating is having a 'name' as Francesco said. just provide a name to the BOM and you want need any inheritence.

Naresh Soni (nch)
on 4/10/13, 1:47 PM

the bom have a name, it's a required field !

Tajjajt
on 4/10/13, 1:52 PM

OK ! then you should debug the original copy_data method defined in mrp.py why this read is not returning the name in bom_data. "bom_data = self.read(cr, uid, id, [], context=context)"

Naresh Soni (nch)
on 4/10/13, 1:55 PM

however i add some fields.boolean to bom, I wonder if that the source of the problem?

Tajjajt
on 4/10/13, 2:06 PM

I can't guess what exactly you have done. But the root cause is clear you are trying to concatenate a Boolean with a string.

Naresh Soni (nch)
on 4/10/13, 2:09 PM

I didn't undersand ur comment : OK ! then you should debug the original copy_data method defined in mrp.py why this read is not returning the name in bom_data. "bom_data = self.read(cr, uid, id, [], context=context)"

Tajjajt
on 4/10/13, 2:26 PM

By this I meant is you should go to /usr/local/lib/python2.6/dist-packages/openerp-server/addons/mrp.zip/mrp/mrp.py and in the copy_data method there is a read statement executed on the id you are copying but that returns a Boolean in the name field. try to debug over there

Naresh Soni (nch)
on 4/10/13, 2:34 PM

I can't understand what you mean by "there is a read statement executed on the id you are copying but that returns a Boolean in the name field. try to debug over there" can you explan me more plz that is urgent

Tajjajt
on 4/10/13, 3:27 PM

I have no idea how to solve this problem?????! help me plz

Tajjajt
on 4/12/13, 3:45 PM

any help??!!!!

Tajjajt
on 4/15/13, 7:11 AM

Tajjajt, you have to be a bit technical to fix this.

Naresh Soni (nch)
on 4/15/13, 7:27 AM

Can you help me?

Tajjajt
on 4/17/13, 12:52 PM

Tajjat, Go to the path:/usr/local/lib/python2.6/dist-packages/openerp-server/addons/mrp.zip/mrp/mrp.py open this file at line no 360 in method copy_data: replace this line :default.update({'name': bom_data['name'] + ' ' + _('Copy'), 'bom_id':False}) by default.update({'name': bom_data.get('name','') + ' ' + _('Copy'), 'bom_id':False}) then just save the file and restart your server. It should be fixed.

Naresh Soni (nch)
on 4/18/13, 4:37 AM

I have no acces to source file, I try to do that with a inherited module : class mrp_bom(osv.osv):

    _inherit = "mrp.bom"

    def copy_data(self, cr, uid, id, default=None, context=None):
        if default:
            default.update({'name': bom_data.get('name','') + ' ' + _('Copy'), 'bom_id':False})
        return super(mrp_bom, self).copy_data(cr, uid, id, default, context)

mrp_bom()

But I have the same error

Tajjajt
on 4/18/13, 7:43 AM

if you are doing it in an inherited module that is good. then you should not call the super i.e the parent class method. "super(mrp_bom, self).copy_data(cr, uid, id, default, context)" instead just do the stuff in your new module and don't call super.

Naresh Soni (nch)
on 4/18/13, 7:45 AM

I try this but still have no resultat

   class mrp_bom(osv.osv):

        _inherit = "mrp.bom"

        def copy_data(self, cr, uid, id, default=None, context=None):
            if default:
                default.update({'name': bom_data.get('name','') + ' ' + _('Copy'), 'bom_id':False})
                return True
    mrp_bom()
Tajjajt
on 4/18/13, 8:02 AM

Tajjat ! you need to reimplement the logic of copy_data in your inherited module. i.e just copy the whole method in your inherited one and just replace the line default.update.... and call super of osv.

Naresh Soni (nch)
on 4/18/13, 8:12 AM

That is do this def copy_data(self, cr, uid, id, default=None, context=None): if default is None: default = {} bom_data = self.read(cr, uid, id, [], context=context) default.update({'name': bom_data.get('name','') + ' ' + _('Copy'), 'bom_id':False}) return super(osv.osv, self).copy_data(cr, uid, id, default, context)

Naresh Soni (nch)
on 4/18/13, 8:13 AM

Thank u Naresh Soni It works :) finally ...Thank u and Have a good day :)

Tajjajt
on 4/18/13, 8:52 AM

Thank God :-D

Naresh Soni (nch)
on 4/18/13, 8:54 AM

Of course :)

Tajjajt
on 4/18/13, 8:56 AM
0

Francesco OpenCode

--Francesco OpenCode--
3608
| 5 7 9
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo (OpenERP) Modules Developer LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode
On 4/9/13, 2:25 PM

Maybe the bom you are copying has not a name. Insert a name an try to copy again.

Here

bom_data['name'] + ' ' + _('Copy')

python are trying to add a boolean (maybe bom_data['name']) and string ' '

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 4/9/13, 2:22 PM
Seen: 2289 times
Last updated: 3/16/15, 8:10 AM