新增主生产计划模块

This commit is contained in:
qihao.gong@jikimo.com
2023-08-15 10:36:04 +08:00
parent 4a5fb0c6e4
commit 1533ef7be9
72 changed files with 25769 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
# -*- encoding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import mrp_mps_forecast_details

View File

@@ -0,0 +1,62 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
class MrpMpsForecastDetails(models.TransientModel):
_name = "mrp.mps.forecast.details"
_description = "Forecast Demand Details"
move_ids = fields.Many2many('stock.move', readonly=True)
purchase_order_line_ids = fields.Many2many('purchase.order.line', readonly=True)
rfq_qty = fields.Integer('Quantity from RFQ', compute='_compute_quantity')
moves_qty = fields.Integer('Quantity from Incoming Moves',
compute='_compute_quantity')
manufacture_qty = fields.Integer('Quantity from Manufacturing Order',
compute='_compute_quantity')
total_qty = fields.Integer('Actual Replenishment', compute='_compute_quantity')
@api.depends('move_ids', 'purchase_order_line_ids')
def _compute_quantity(self):
for mps in self:
mps.moves_qty = sum(mps.move_ids.filtered(lambda m: m.picking_id).mapped('product_qty'))
mps.manufacture_qty = sum(mps.move_ids.filtered(lambda m: m.production_id).mapped('product_qty'))
mps.rfq_qty = sum([l.product_uom._compute_quantity(l.product_qty, l.product_id.uom_id) for l in mps.purchase_order_line_ids])
mps.total_qty = mps.moves_qty + mps.manufacture_qty + mps.rfq_qty
def action_open_rfq_details(self):
return {
'type': 'ir.actions.act_window',
'res_model': 'purchase.order',
'views': [(False, 'list'), (False, 'form')],
'view_mode': 'list,form',
'target': 'current',
'name': self.env.context.get('action_name'),
'domain': [('id', 'in', self.purchase_order_line_ids.mapped('order_id').ids)],
'context': {
'quotation_only': True,
}
}
def action_open_mo_details(self):
return {
'type': 'ir.actions.act_window',
'res_model': 'mrp.production',
'views': [(False, 'list'), (False, 'form')],
'view_mode': 'list,form',
'target': 'current',
'name': self.env.context.get('action_name'),
'domain': [('id', 'in', self.move_ids.mapped('production_id').ids)],
}
def action_open_incoming_moves_details(self):
return {
'type': 'ir.actions.act_window',
'res_model': 'stock.picking',
'views': [(False, 'list'), (False, 'form')],
'view_mode': 'list,form',
'target': 'current',
'name': self.env.context.get('action_name'),
'domain': [('id', 'in', self.move_ids.mapped('picking_id').ids)],
}

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="mrp_mps_forecast_details_form_view" model="ir.ui.view">
<field name="name">mrp.mps.forecast.details.form</field>
<field name="model">mrp.mps.forecast.details</field>
<field name="arch" type="xml">
<form>
<field name="move_ids" invisible="1"/>
<field name="purchase_order_line_ids" invisible="1"/>
<div class="row">
<div class="d-grid col-md-4">
<button type="object"
name="action_open_rfq_details"
class="btn btn-primary">
<field name="rfq_qty" widget="statinfo" string="Requests for quotation"/>
</button>
</div>
<div class="d-grid col-md-4">
<button type="object"
name="action_open_incoming_moves_details"
class="btn btn-primary">
<field name="moves_qty" widget="statinfo" string="Receipts"/>
</button>
</div>
<div class="d-grid col-md-4">
<button type="object"
name="action_open_mo_details"
class="btn btn-primary">
<field name="manufacture_qty" widget="statinfo" string="Manufacturing Orders"/>
</button>
</div>
</div>
<footer>
<button string="Close" class="btn btn-secondary" special="cancel" data-hotkey="z"/>
</footer>
</form>
</field>
</record>
</odoo>