diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-02-22 14:48:01 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-02-22 14:48:01 +0700 |
| commit | 6850fd6f86a0fbba3156e59f9ac5836052f019ce (patch) | |
| tree | 2263d3ae64518ed8ae4cb2b2f802772cde1db458 /indoteknik_custom/models/report_stock_forecasted.py | |
| parent | ff33c441cd031b47bcc381f1163633cf6e8586d0 (diff) | |
master data commision % and reserved from by forcasted
Diffstat (limited to 'indoteknik_custom/models/report_stock_forecasted.py')
| -rw-r--r-- | indoteknik_custom/models/report_stock_forecasted.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/indoteknik_custom/models/report_stock_forecasted.py b/indoteknik_custom/models/report_stock_forecasted.py new file mode 100644 index 00000000..48a17095 --- /dev/null +++ b/indoteknik_custom/models/report_stock_forecasted.py @@ -0,0 +1,45 @@ +from odoo import api, models + +class ReplenishmentReport(models.AbstractModel): + _inherit = 'report.stock.report_product_product_replenishment' + + @api.model + def _get_report_lines(self, product_template_ids, product_variant_ids, wh_location_ids): + lines = super(ReplenishmentReport, self)._get_report_lines(product_template_ids, product_variant_ids, wh_location_ids) + + result_dict = {} + + for line in lines: + product_id = line.get('product', {}).get('id') + query = [('product_id', '=', product_id)] + document_out = line.get('document_out') + order_id = document_out.id if document_out else None + + if order_id: + result = self._calculate_result(line) + result_dict.setdefault(order_id, []).append(result) + + for order_id, results in result_dict.items(): + sale_order_lines = self.env['sale.order.line'].search([('order_id', '=', order_id)]) + + concatenated_result = ' ,'.join(results) + + for sale_order_line in sale_order_lines: + sale_order_line.reserved_from = concatenated_result + + return lines + + def _calculate_result(self, line): + if line['document_in']: + return str(line["document_in"].name) + elif line['reservation'] and not line['document_in']: + return 'Reserved from stock' + elif line['replenishment_filled']: + if line['document_out']: + return 'Inventory On Hand' + else: + return 'Free Stock' + else: + return 'Not Available' + + |
