I have something like this in V17,
class StockPickingType(models.Model):
_inherit = 'stock.picking'
@api.onchange('picking_type_id', 'partner_id')
def _onchange_picking_type_id(self):
res = super()._onchange_picking_type_id()
...
self.move_ids.unlink()
product_ids = self.env['product.product'].sudo().search([('categ_id', 'in', [5,6])])
move_lines=[]
for product_id in product_ids:
data = (0, 0, { 'product_id': product_id.id})
move_lines.append(data)
if move_lines:
self.move_ids.write(move_lines)
...
return res
1. The problem is the write operation does not work. If i do a print statement right after the write operation (print(self.move_ids)), there is no stock.move record. I feel its something to do with creating a new picking from kanban view. Any help would be appreciated. I have been on this for sometime now.
2. Also if I add some items in the picking manually and I change the operation type (you have to make it visible first), the items I added are removed from the list. Where in the code base does this happen?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- إدارة علاقات العملاء
- e-Commerce
- المحاسبة
- المخزون
- PoS
- Project
- MRP
لقد تم الإبلاغ عن هذا السؤال
1
الرد
1103
أدوات العرض
Hi,
Please try by using the latest x2many operations for creating record
eg:
move_lines = [fields.Command.create({
'product_id': product_id.id,
})for product_id in product_ids]
Hope it helps
هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!
أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!
تسجيلالمنشورات ذات الصلة | الردود | أدوات العرض | النشاط | |
---|---|---|---|---|
|
0
يوليو 24
|
1008 | ||
Out of Stock
تم الحل
|
|
4
فبراير 24
|
3903 | |
|
1
يوليو 23
|
1795 | ||
|
1
مايو 23
|
2459 | ||
|
1
مايو 25
|
1782 |
Hi , can you describe your use case, what is the specific reason why you need to change the move_lines sir?
Hi. So its more of a productivity reason and to prevent mistakes. I would like to prefill transfers with products from a certain category depending on the operation type selected. All the products entered will have zero quantity, so the only job of the user is to adjust the quantity on those that are to be tansferred and validate
My second question is just out of curiosity as I could not find how it was implemented