Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
4954 Vizualizări

Hi


I have written a module which creates a product an then a bom an adds the bom to the product. On my development environment everything works fine but not on the productive server, both V8 installations.

Here some parts of the code.

class product_product_wizard(osv.osv):
_inherit = 'product.product'


def create(self, cr, uid, data, context=None):
# some code which fills all data for the new product
# after that I create the product with this line
id = super(product_product_wizard, self).create(cr, uid, data, context)

# now I create the bom
     product = self.browse(cr, uid, id)
     bom_obj = self.pool.get('mrp.bom')
     bom_line_obj = self.pool.get('mrp.bom.line')
parent_bom_id = bom_obj.create(cr, uid, {'name': product.name,
'code': data['default_code'],
'product_uom': product.product_tmpl_id.uom_id.id,
'product_tmpl_id': product.id})

But creating the bom gets me this error:

migration_debug openerp.sql_db: bad query: INSERT INTO "mrp_bom" ("id", "product_rounding", "code", "name", "product_uom", "company_id", "product_tmpl_id", "product_qty", "active", "product_efficiency", "type", "create_uid", "write_uid", "create_date", "write_date") VALUES(nextval('mrp_bom_id_seq'), 0.0, 'Test123', 'A4', 1, 1, 47342, '1.000', true, 1.0, 'normal', 1, 1, (now() at time zone 'UTC'), (now() at time zone 'UTC')) RETURNING id
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 234, in execute
res = self._obj.execute(query, params)
IntegrityError: insert or update on table "mrp_bom" violates foreign key constraint "mrp_bom_product_tmpl_id_fkey"
DETAIL: Key (product_tmpl_id)=(47342) is not present in table "product_template".

It looks like the product is not created yet. I debugged the code, the id after creating the product is set. I don't get why on one installation this is working an not on the other.

Do you guys have any idea?

Imagine profil
Abandonează
Cel mai bun răspuns

because the product id is not the product template id: product_tmpl_id': product.id}) ?
regards,
Sven


Imagine profil
Abandonează
Autor Cel mai bun răspuns

Anyone? I rewrote the module using v8 api, same error.

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
mai 24
1205
3
ian. 24
1475
0
sept. 23
1586
1
mai 23
2483
0
iul. 19
2638