コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
5321 ビュー

Hi Odooers,

I am trying to create a record in the stock.move from my custom model. I am using Odoo version 12.0.

This is my code, I call this function from a button. But it shows a user error like this.

"The requested operation cannot be processed because of a programming error setting the `product_qty` field instead of the `product_uom_qty`."

As the error says, I haven't set product_qty but added product_uom_qty in my dictionary. What would be the reason for this error.?


Thanks in advance


@api.multi
def action_reproduction(self):
active_id = self._context.get('active_id', False)
scrap_id = self.env['stock.scrap'].browse(active_id)
if scrap_id:
dest_location_id = self.env.ref('stock_reproduction.stock_location_reproduction')
move_id = self.env['stock.move'].create({
'name': 'Reproduction from scrap(%s)' % scrap_id.name,
'location_id': scrap_id.scrap_location_id.id,
'location_dest_id': dest_location_id.id,
'product_id': scrap_id.product_id.id,
'product_uom': scrap_id.product_uom_id.id,
'product_uom_qty': self.product_qty,
})



Click here to see the error message
アバター
破棄
最善の回答

I quote a comment for method __set_product_qty(self):
""" The meaning of product_qty field changed lately and is now a functional field computing the quantity
in the default product UoM. This code has been added to raise an error if a write is made given a value
for `product_qty`, where the same write should set the `product_uom_qty` field instead, in order to
detect errors. """

アバター
破棄
著作者

I have referred this one. But I am not able to create the record as this docstring says.

What is your self? You have @api.multi and request to single record -> self.product_qty!

関連投稿 返信 ビュー 活動
3
9月 21
12383
0
4月 24
1578
2
1月 21
5290
1
6月 20
5070
2
4月 20
72903