Add oca-purchase submodule with 96 purchase modules moved from oca-workflow-process

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ernad Husremovic 2025-08-30 18:00:40 +02:00
parent b0628ee8ea
commit 7378b233e9
3994 changed files with 334316 additions and 0 deletions

View file

@ -0,0 +1,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import purchase_order_line
from . import stock_rule

View file

@ -0,0 +1,76 @@
# Copyright (C) 2022 Akretion (<http://www.akretion.com>).
# @author David BEAL <david.beal@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class PurchaseOrderLine(models.Model):
_inherit = "purchase.order.line"
tracking = fields.Selection(related="product_id.tracking")
lot_id = fields.Many2one(
"stock.lot",
string="Serial Number",
copy=False,
compute="_compute_lot_id",
store=True,
readonly=False,
)
@api.depends("move_dest_ids.restrict_lot_id", "move_ids.restrict_lot_id")
def _compute_lot_id(self):
for line in self:
line.lot_id = (
line.move_dest_ids.restrict_lot_id | line.move_ids.restrict_lot_id
)
@api.model
def _prepare_purchase_order_line_from_procurement(
self, product_id, product_qty, product_uom, company_id, values, po
):
vals = super()._prepare_purchase_order_line_from_procurement(
product_id, product_qty, product_uom, company_id, values, po
)
lot_id = values.get("restrict_lot_id")
if lot_id:
vals["lot_id"] = lot_id
return vals
def _prepare_stock_move_vals(
self, picking, price_unit, product_uom_qty, product_uom
):
vals = super()._prepare_stock_move_vals(
picking, price_unit, product_uom_qty, product_uom
)
if self.lot_id:
vals["restrict_lot_id"] = self.lot_id.id
return vals
def _find_candidate(
self,
product_id,
product_qty,
product_uom,
location_id,
name,
origin,
company_id,
values,
):
lot_id = values.get("restrict_lot_id", False)
moves_dest = values.get("move_dest_ids", False)
if lot_id:
self = self.filtered(lambda l: l.lot_id.id == lot_id)
elif self.product_id.tracking != "none" and moves_dest:
self = self.filtered(lambda l: moves_dest in l.move_dest_ids)
return super()._find_candidate(
product_id,
product_qty,
product_uom,
location_id,
name,
origin,
company_id,
values,
)

View file

@ -0,0 +1,16 @@
# Copyright (C) 2022 Akretion (<http://www.akretion.com>).
# @author David BEAL <david.beal@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, models
class StockRule(models.Model):
_inherit = "stock.rule"
@api.model
def _get_procurements_to_merge_groupby(self, procurement):
return (
procurement.values.get("move_dest_ids"),
super()._get_procurements_to_merge_groupby(procurement),
)