콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
4960 화면

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?

아바타
취소
베스트 답변

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


아바타
취소
작성자 베스트 답변

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

아바타
취소
관련 게시물 답글 화면 활동
Cost Break Up 해결 완료
2
5월 24
1212
3
1월 24
1486
0
9월 23
1596
1
5월 23
2497
0
7월 19
2642