mirror of
https://github.com/bringout/oca-ocb-mrp.git
synced 2026-04-26 19:52:00 +02:00
19.0 vanilla
This commit is contained in:
parent
accf5918df
commit
6e65e8c877
688 changed files with 225434 additions and 199401 deletions
|
|
@ -1,47 +1,53 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class ReplenishmentReport(models.AbstractModel):
|
||||
_inherit = 'report.stock.report_product_product_replenishment'
|
||||
class StockForecasted_Product_Product(models.AbstractModel):
|
||||
_inherit = 'stock.forecasted_product_product'
|
||||
|
||||
def _prepare_report_line(self, quantity, move_out=None, move_in=None, replenishment_filled=True, product=False, reserved_move=False, in_transit=False, read=True):
|
||||
line = super()._prepare_report_line(quantity, move_out, move_in, replenishment_filled, product, reserved_move, in_transit, read)
|
||||
|
||||
def _serialize_docs(self, docs, product_template_ids=False, product_variant_ids=False):
|
||||
res = super()._serialize_docs(docs, product_template_ids, product_variant_ids)
|
||||
for i, line in enumerate(docs['lines']):
|
||||
if not line['move_out'] or not line['move_out']['raw_material_production_id']:
|
||||
continue
|
||||
raw_material_production = line['move_out']['raw_material_production_id']
|
||||
res['lines'][i]['move_out']['raw_material_production_id'] = raw_material_production.read(fields=['id', 'unreserve_visible', 'reserve_visible', 'priority'])[0]
|
||||
return res
|
||||
if not move_out or not move_out.raw_material_production_id or not read:
|
||||
return line
|
||||
|
||||
def _move_draft_domain(self, product_template_ids, product_variant_ids, wh_location_ids):
|
||||
in_domain, out_domain = super()._move_draft_domain(product_template_ids, product_variant_ids, wh_location_ids)
|
||||
line['move_out']['raw_material_production_id'] = move_out.raw_material_production_id.read(fields=['id', 'unreserve_visible', 'reserve_visible', 'priority'])[0]
|
||||
return line
|
||||
|
||||
def _move_draft_domain(self, product_template_ids, product_ids, wh_location_ids):
|
||||
in_domain, out_domain = super()._move_draft_domain(product_template_ids, product_ids, wh_location_ids)
|
||||
in_domain += [('production_id', '=', False)]
|
||||
out_domain += [('raw_material_production_id', '=', False)]
|
||||
return in_domain, out_domain
|
||||
|
||||
def _compute_draft_quantity_count(self, product_template_ids, product_variant_ids, wh_location_ids):
|
||||
res = super()._compute_draft_quantity_count(product_template_ids, product_variant_ids, wh_location_ids)
|
||||
res['draft_production_qty'] = {}
|
||||
domain = self._product_domain(product_template_ids, product_variant_ids)
|
||||
def _get_report_header(self, product_template_ids, product_ids, wh_location_ids):
|
||||
res = super()._get_report_header(product_template_ids, product_ids, wh_location_ids)
|
||||
domain = self._product_domain(product_template_ids, product_ids)
|
||||
domain += [('state', '=', 'draft')]
|
||||
|
||||
# Pending incoming quantity.
|
||||
mo_domain = domain + [('location_dest_id', 'in', wh_location_ids)]
|
||||
grouped_mo = self.env['mrp.production'].read_group(mo_domain, ['product_qty:sum'], 'product_id')
|
||||
res['draft_production_qty']['in'] = sum(mo['product_qty'] for mo in grouped_mo)
|
||||
|
||||
# Pending outgoing quantity.
|
||||
move_domain = domain + [
|
||||
in_domain = domain + [('location_dest_id', 'in', wh_location_ids)] # Pending incoming quantity.
|
||||
out_domain = domain + [ # Pending outgoing quantity.
|
||||
('raw_material_production_id', '!=', False),
|
||||
('location_id', 'in', wh_location_ids),
|
||||
]
|
||||
grouped_moves = self.env['stock.move'].read_group(move_domain, ['product_qty:sum'], 'product_id')
|
||||
res['draft_production_qty']['out'] = sum(move['product_qty'] for move in grouped_moves)
|
||||
res['qty']['in'] += res['draft_production_qty']['in']
|
||||
res['qty']['out'] += res['draft_production_qty']['out']
|
||||
in_product_qty = {k.id: v for k, v in self.env['mrp.production']._read_group(in_domain, aggregates=['product_qty:sum'], groupby=['product_id'])}
|
||||
out_product_qty = {k.id: v for k, v in self.env['stock.move']._read_group(out_domain, aggregates=['product_qty:sum'], groupby=['product_id'])}
|
||||
|
||||
self._add_product_quantities(res, product_template_ids, product_ids, 'draft_production_qty', in_product_qty, out_product_qty)
|
||||
|
||||
return res
|
||||
|
||||
def _get_reservation_data(self, move):
|
||||
if move.production_id:
|
||||
m2o = 'production_id'
|
||||
elif move.raw_material_production_id:
|
||||
m2o = 'raw_material_production_id'
|
||||
else:
|
||||
return super()._get_reservation_data(move)
|
||||
return {
|
||||
'_name': move[m2o]._name,
|
||||
'name': move[m2o].name,
|
||||
'id': move[m2o].id
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue