mirror of
https://github.com/bringout/oca-mrp.git
synced 2026-04-26 23:52:04 +02:00
Initial commit: OCA Mrp packages (117 packages)
This commit is contained in:
commit
277e84fd7a
4403 changed files with 395154 additions and 0 deletions
|
|
@ -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
|
||||
|
|
@ -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"))
|
||||
)
|
||||
|
|
@ -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")
|
||||
|
|
@ -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()
|
||||
|
|
@ -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")
|
||||
|
|
@ -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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue