mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-19 23:12:03 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1,50 @@
|
|||
# Copyright 2016-20 ForgeFlow S.L. (http://www.forgeflow.com)
|
||||
# Copyright 2016 Aleph Objects, Inc. (https://www.alephobjects.com/)
|
||||
# Copyright 2018 Camptocamp SA https://www.camptocamp.com
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class ProcurementGroup(models.Model):
|
||||
_inherit = "procurement.group"
|
||||
|
||||
# UOM: (stock_orderpoint_uom):
|
||||
@api.model
|
||||
def run(self, procurements, raise_user_error=True):
|
||||
Proc = self.env["procurement.group"].Procurement
|
||||
indexes_to_pop = []
|
||||
new_procs = []
|
||||
for i, procurement in enumerate(procurements):
|
||||
if "buffer_id" in procurement.values:
|
||||
buffer = procurement.values.get("buffer_id")
|
||||
if (
|
||||
buffer.procure_uom_id
|
||||
and procurement.product_uom != buffer.procure_uom_id
|
||||
):
|
||||
new_product_qty = procurement.product_uom._compute_quantity(
|
||||
procurement.product_qty, buffer.procure_uom_id
|
||||
)
|
||||
new_product_uom = buffer.procure_uom_id
|
||||
new_procs.append(
|
||||
Proc(
|
||||
procurement.product_id,
|
||||
new_product_qty,
|
||||
new_product_uom,
|
||||
procurement.location_id,
|
||||
procurement.name,
|
||||
procurement.origin,
|
||||
procurement.company_id,
|
||||
procurement.values,
|
||||
)
|
||||
)
|
||||
indexes_to_pop.append(i)
|
||||
if new_procs:
|
||||
indexes_to_pop.reverse()
|
||||
for index in indexes_to_pop:
|
||||
procurements.pop(index)
|
||||
procurements.extend(new_procs)
|
||||
|
||||
return super(ProcurementGroup, self).run(
|
||||
procurements, raise_user_error=raise_user_error
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue