تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2807 أدوات العرض

I'm trying to create a product and its variant. Afterwards I want to add some quantity to stock (including price_unit), but it doesn't work like that. Seems like "env['stock.move'].create" doesn't take any effect.

What am I doing wrong?


Thanks!


Code example:

product_template = self.env["product.template"].create({'name': title,
"default_code": permalink,
"price": price,
"type": "product",
"weight": weight})

product_template.write({
'attribute_line_ids': [(0, 0, {
'attribute_id': 2,
'value_ids': [(6, 0, [156])],
})]
})

product_product = product_template.product_variant_id
product_product.write({
'name': title,
"default_code": sku,
"price": price,
"type": "product",
"weight": weight
})
move = self.env['stock.move'].create({
'name': 'test_move',
'product_id': product_product.id,
'product_uom': 1,
'product_uom_qty': quantity,
'price_unit': cost_price,
'location_id': 14,
'location_dest_id': 8,
})

move._action_confirm()
move._action_assign()
move.move_line_ids.write({'qty_done': quantity, 'product_uom_qty': 0})
move._action_done()


الصورة الرمزية
إهمال

do it with sudo it may be hep to create record

الكاتب

I need to do it in my odoo module, so that I'm using python to do this

المنشورات ذات الصلة الردود أدوات العرض النشاط
2
يوليو 24
1237
0
يناير 21
2117
0
مايو 25
12
4
أبريل 25
5746
2
يناير 25
2577