Initial commit: OCA Mrp packages (117 packages)

This commit is contained in:
Ernad Husremovic 2025-08-29 15:43:05 +02:00
commit 277e84fd7a
4403 changed files with 395154 additions and 0 deletions

View file

@ -0,0 +1,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import product_product
from . import product_supplierinfo
from . import purchase_order
from . import stock_location_route
from . import stock_move

View file

@ -0,0 +1,14 @@
# Copyright 2022 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models
class ProductProduct(models.Model):
_inherit = "product.product"
def _prepare_sellers(self, params):
res = super()._prepare_sellers(params)
return res.filtered(
lambda x: x.subcontracting_inhibit
== bool(self.env.context.get("subcontracting_inhibit"))
)

View file

@ -0,0 +1,9 @@
# Copyright 2022 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
class ProductSupplierinfo(models.Model):
_inherit = "product.supplierinfo"
subcontracting_inhibit = fields.Boolean(string="Subcontracting inhibited")

View file

@ -0,0 +1,39 @@
# Copyright 2022 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
class PurchaseOrderLine(models.Model):
_inherit = "purchase.order.line"
subcontracting_inhibit = fields.Boolean(string="Inhibit subcontracting")
@api.model
def _prepare_purchase_order_line_from_procurement(
self, product_id, product_qty, product_uom, company_id, values, po
):
"""We need to inject the context to set the right price"""
subcontracting_inhibit_value = False
if values.get("route_ids"):
subcontracting_inhibit_value = any(
values.get("route_ids").mapped("subcontracting_inhibit")
)
product_id = product_id.with_context(
subcontracting_inhibit=subcontracting_inhibit_value
)
res = super()._prepare_purchase_order_line_from_procurement(
product_id, product_qty, product_uom, company_id, values, po
)
res.update({"subcontracting_inhibit": subcontracting_inhibit_value})
return res
@api.onchange("subcontracting_inhibit")
def _onchange_subcontracting_inhibit(self):
return self._onchange_quantity()
def _onchange_quantity(self):
"""We need to inject the context to set the right price"""
_self = self.with_context(subcontracting_inhibit=self.subcontracting_inhibit)
return super(
PurchaseOrderLine, _self
)._compute_price_unit_and_date_planned_and_name()

View file

@ -0,0 +1,9 @@
# Copyright 2022 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
class StockLocationRoute(models.Model):
_inherit = "stock.route"
subcontracting_inhibit = fields.Boolean(string="Inhibit subcontracting")

View file

@ -0,0 +1,14 @@
# Copyright 2022 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models
class StockMove(models.Model):
_inherit = "stock.move"
def _get_subcontract_bom(self):
"""Hack to simulate that there is no subcontracting BoM."""
self.ensure_one()
if self.purchase_line_id.subcontracting_inhibit:
return False
return super()._get_subcontract_bom()