diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-06-20 10:41:12 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-06-20 10:41:12 +0700 |
| commit | 5b3145bc1b56c423629f579e4eab8997e48cb1ad (patch) | |
| tree | 41c4866e89daf35e6637d3de0c5dbb60dc5e845e | |
| parent | e819131a029681b10d5bafb2f4dc3948c429e776 (diff) | |
Fix bug fullfilment
| -rw-r--r-- | indoteknik_custom/models/report_stock_forecasted.py | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/indoteknik_custom/models/report_stock_forecasted.py b/indoteknik_custom/models/report_stock_forecasted.py index 8e92a9b8..d5e48fdc 100644 --- a/indoteknik_custom/models/report_stock_forecasted.py +++ b/indoteknik_custom/models/report_stock_forecasted.py @@ -11,9 +11,8 @@ class ReplenishmentReport(models.AbstractModel): for line in lines: document_out = line.get('document_out') - if "SO/" in document_out.name: - document_out = line.get('document_out') - order_id = document_out.id if document_out else None + if document_out and "SO/" in document_out.name: + order_id = document_out.id product_id = line.get('product', {}).get('id') query = [('product_id', '=', product_id)] @@ -22,17 +21,16 @@ class ReplenishmentReport(models.AbstractModel): quantity = line.get('quantity', 0) result_dict.setdefault(order_id, []).append((result, quantity)) - for order_id, results in result_dict.items(): - sales_order = self.env['sale.order'].browse(order_id) - - for result, quantity in results: - self.env['sales.order.fullfillment'].create({ - 'sales_order_id': sales_order.id, - 'product_id': product_id, - 'reserved_from': result, - 'qty_fullfillment': quantity, - }) + for order_id, results in result_dict.items(): + sales_order = self.env['sale.order'].browse(order_id) + for result, quantity in results: + self.env['sales.order.fullfillment'].create({ + 'sales_order_id': sales_order.id, + 'product_id': product_id, + 'reserved_from': result, + 'qty_fullfillment': quantity, + }) return lines |
