[IMP] purchase_mrp: Buy route for BoM overview
Add support for "buy" route recognition in the BoM overview report, as well as calculating receipt delay for this kind of route Task-2628323 Part-of: odoo/odoo#93194
This commit is contained in:
@@ -2,3 +2,4 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import models
|
||||
from . import report
|
||||
|
||||
@@ -21,5 +21,10 @@ from purchase order.
|
||||
'depends': ['mrp', 'purchase_stock'],
|
||||
'installable': True,
|
||||
'auto_install': True,
|
||||
'assets': {
|
||||
'web.assets_backend': [
|
||||
'mrp/static/src/**/*.js',
|
||||
],
|
||||
},
|
||||
'license': 'LGPL-3',
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import mrp_report_bom_structure
|
||||
@@ -0,0 +1,35 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
class ReportBomStructure(models.AbstractModel):
|
||||
_inherit = 'report.mrp.report_bom_structure'
|
||||
|
||||
@api.model
|
||||
def _format_route_info(self, rules, rules_delay, warehouse, product, bom, quantity):
|
||||
res = super()._format_route_info(rules, rules_delay, warehouse, product, bom, quantity)
|
||||
if self._is_buy_route(rules, product, bom):
|
||||
buy_rules = [rule for rule in rules if rule.action == 'buy']
|
||||
supplier = product._select_seller(quantity=quantity, uom_id=product.uom_id)
|
||||
if supplier:
|
||||
return {
|
||||
'route_type': 'buy',
|
||||
'route_name': buy_rules[0].route_id.display_name,
|
||||
'route_detail': supplier.display_name,
|
||||
'lead_time': supplier.delay + rules_delay,
|
||||
'supplier_delay': supplier.delay + rules_delay,
|
||||
'supplier': supplier,
|
||||
}
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def _is_buy_route(self, rules, product, bom):
|
||||
return any(rule for rule in rules if rule.action == 'buy' and product.seller_ids)
|
||||
|
||||
@api.model
|
||||
def _get_resupply_availability(self, route_info, components):
|
||||
if route_info.get('route_type') == 'buy':
|
||||
supplier_delay = route_info.get('supplier_delay', 0)
|
||||
return ('estimated', supplier_delay)
|
||||
return super()._get_resupply_availability(route_info, components)
|
||||
@@ -0,0 +1,16 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
import { BomOverviewLine } from "@mrp/components/bom_overview_line/mrp_bom_overview_line";
|
||||
|
||||
patch(BomOverviewLine.prototype, "purchase_mrp", {
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
async goToRoute(routeType) {
|
||||
if (routeType == "buy") {
|
||||
return this.goToAction(this.data.link_id, this.data.link_model);
|
||||
}
|
||||
return this._super(...arguments);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user