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,2 @@
from . import mrp_production
from . import stock_rule

View file

@ -0,0 +1,20 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
class MrpProduction(models.Model):
_inherit = "mrp.production"
lot_producing_id = fields.Many2one(
compute="_compute_lot_producing_id", store=True, readonly=False
)
@api.depends("move_finished_ids.restrict_lot_id")
def _compute_lot_producing_id(self):
for order in self:
finish_move_lot = order.move_finished_ids.filtered(
lambda m: m.product_id == order.product_id
).restrict_lot_id
if finish_move_lot:
order.lot_producing_id = finish_move_lot

View file

@ -0,0 +1,43 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models
class StockRule(models.Model):
_inherit = "stock.rule"
def _prepare_mo_vals(
self,
product_id,
product_qty,
product_uom,
location_dest_id,
name,
origin,
company_id,
values,
bom,
):
vals = super()._prepare_mo_vals(
product_id,
product_qty,
product_uom,
location_dest_id,
name,
origin,
company_id,
values,
bom,
)
lot_id = values.get("restrict_lot_id")
if lot_id:
vals["lot_producing_id"] = lot_id
lot = self.env["stock.lot"].browse(lot_id)
mo_name = lot.name
existing_mo = self.env["mrp.production"].search(
[("lot_producing_id", "=", lot_id)]
)
if existing_mo:
mo_name = "%s-%s" % (mo_name, len(existing_mo))
vals["name"] = mo_name
return vals