Skip to Content
Menu
This question has been flagged
1 Reply
4078 Views

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
Avatar
Discard
Best Answer

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. """

Avatar
Discard
Author

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!

Related Posts Replies Views Activity
3
Sep 21
10601
0
Apr 24
449
2
Jan 21
4116
1
Jun 20
4043
2
Apr 20
70274