采购申请单完成操作优化
This commit is contained in:
@@ -8,12 +8,13 @@
|
||||
'category': 'purchase',
|
||||
'depends': ['sf_manufacturing', 'purchase_request'],
|
||||
'data': [
|
||||
'security/ir.model.access.csv',
|
||||
'views/sale_order_view.xml',
|
||||
'views/mrp_production.xml',
|
||||
'views/purchase_request_view.xml',
|
||||
'wizard/purchase_request_line_make_purchase_order_view.xml',
|
||||
'views/purchase_request_line_view.xml',
|
||||
'views/stock_picking_views.xml',
|
||||
'wizard/purchase_request_wizard_views.xml',
|
||||
],
|
||||
'assets': {
|
||||
'web.assets_backend': [
|
||||
|
||||
@@ -410,7 +410,7 @@ msgstr "显示名称"
|
||||
#: model_terms:ir.ui.view,arch_db:purchase_request.view_purchase_request_form
|
||||
#: model_terms:ir.ui.view,arch_db:purchase_request.view_purchase_request_search
|
||||
msgid "Done"
|
||||
msgstr "完成"
|
||||
msgstr "关闭"
|
||||
|
||||
#. module: purchase_request
|
||||
#: model:ir.model.fields,field_description:purchase_request.field_purchase_request_line__move_dest_ids
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import re
|
||||
import ast
|
||||
from odoo import models, fields, api
|
||||
from odoo import models, fields, api, _
|
||||
from itertools import groupby
|
||||
|
||||
|
||||
class PurchaseRequest(models.Model):
|
||||
@@ -29,6 +30,54 @@ class PurchaseRequest(models.Model):
|
||||
action['context'] = origin_context
|
||||
return action
|
||||
|
||||
def button_done(self):
|
||||
product_qty_map = {key: sum(line.product_qty for line in group) for key, group in
|
||||
groupby(self.line_ids, key=lambda x: x.product_id.id)}
|
||||
lines = self.mapped("line_ids.purchase_lines.order_id")
|
||||
# 采购单产品和数量
|
||||
product_summary = {}
|
||||
if lines:
|
||||
for line in lines:
|
||||
for line_item in line.order_line:
|
||||
product_id = line_item.product_id.id
|
||||
qty = line_item.product_qty
|
||||
if product_id in product_summary:
|
||||
product_summary[product_id] += qty
|
||||
else:
|
||||
product_summary[product_id] = qty
|
||||
|
||||
# 校验产品数量
|
||||
discrepancies = []
|
||||
for product_id, qty in product_qty_map.items():
|
||||
if product_id in product_summary:
|
||||
if product_summary[product_id] != qty:
|
||||
discrepancies.append((product_id, qty, product_summary[product_id]))
|
||||
else:
|
||||
discrepancies.append((product_id, qty, 0))
|
||||
|
||||
if discrepancies:
|
||||
# 弹出提示框
|
||||
message = "产品数量不一致:\n"
|
||||
for product_id, required_qty, order_qty in discrepancies:
|
||||
product_name = self.env['product.product'].browse(product_id).display_name # 获取产品名称
|
||||
message += f"产品 {product_name},需求数量 {required_qty},关联采购订单数量 {order_qty}(含询价状态)\n"
|
||||
# 添加确认框
|
||||
message += "确认关闭?"
|
||||
return {
|
||||
'name': _('采购申请'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'views': [(self.env.ref(
|
||||
'jikimo_purchase_request.purchase_request_wizard_wizard_form_view').id,
|
||||
'form')],
|
||||
'res_model': 'purchase.request.wizard',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_purchase_request_id': self.id,
|
||||
'default_message': message,
|
||||
}}
|
||||
return super(PurchaseRequest, self).button_done()
|
||||
|
||||
|
||||
class PurchaseRequestLine(models.Model):
|
||||
_inherit = 'purchase.request.line'
|
||||
_description = '采购申请明细'
|
||||
|
||||
2
jikimo_purchase_request/security/ir.model.access.csv
Normal file
2
jikimo_purchase_request/security/ir.model.access.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_purchase_request_wizard_group_user,purchase.request.wizard,model_purchase_request_wizard,base.group_user,1,1,1,1
|
||||
|
@@ -1,3 +1,4 @@
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)
|
||||
|
||||
from . import purchase_request_line_make_purchase_order
|
||||
from . import purchase_request_wizard
|
||||
|
||||
12
jikimo_purchase_request/wizard/purchase_request_wizard.py
Normal file
12
jikimo_purchase_request/wizard/purchase_request_wizard.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class PurchaseRequestWizard(models.TransientModel):
|
||||
_name = 'purchase.request.wizard'
|
||||
_description = '采购申请向导'
|
||||
|
||||
purchase_request_id = fields.Many2one('purchase.request', string='采购申请')
|
||||
message = fields.Char(string='提示', readonly=True)
|
||||
|
||||
def confirm(self):
|
||||
return self.purchase_request_id.write({"state": "done"})
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record model="ir.ui.view" id="purchase_request_wizard_wizard_form_view">
|
||||
<field name="name">purchase.request.wizard.form.view</field>
|
||||
<field name="model">purchase.request.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<sheet>
|
||||
<div>
|
||||
<div style="white-space: pre-wrap;">
|
||||
<field name="message"/>
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
<button string="确认" name="confirm" type="object" class="oe_highlight"/>
|
||||
<button string="取消" class="btn btn-secondary" special="cancel"/>
|
||||
</footer>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -133,6 +133,7 @@ class QualityCheck(models.Model):
|
||||
part_name = fields.Char('零件名称', related='product_id.part_name', readonly=False, store=True)
|
||||
part_number = fields.Char('零件图号', related='product_id.part_number', readonly=False, store=True)
|
||||
material_name = fields.Char('材料名称', compute='_compute_material_name')
|
||||
model_id = fields.Char('模型ID', related='product_id.model_id')
|
||||
|
||||
# # 总数量,值为调拨单_产品明细_数量
|
||||
# total_qty = fields.Float('总数量', compute='_compute_total_qty', readonly=True)
|
||||
|
||||
@@ -493,6 +493,9 @@
|
||||
<field name="picking_id"/>
|
||||
<field name="lot_id"/>
|
||||
<field name="team_id"/>
|
||||
<field name="part_number"/>
|
||||
<field name="part_name"/>
|
||||
<field name="model_id"/>
|
||||
<filter string="In Progress" name="progress" domain="[('quality_state', '=', 'none')]"/>
|
||||
<filter string="Passed" name="passed" domain="[('quality_state', '=', 'pass')]"/>
|
||||
<filter string="Failed" name="failed" domain="[('quality_state', '=', 'fail')]"/>
|
||||
|
||||
@@ -130,8 +130,14 @@ class ResMrpWorkOrder(models.Model):
|
||||
record.back_button_display = False
|
||||
else:
|
||||
next_workorder = sorted_workorders[position + 1]
|
||||
next_state = next_workorder.state
|
||||
if (next_state == 'ready' or (
|
||||
# 持续获取下一个工单,直到找到一个不是返工的工单
|
||||
while next_workorder and next_workorder.state == 'rework':
|
||||
position += 1
|
||||
if position + 1 < len(sorted_workorders):
|
||||
next_workorder = sorted_workorders[position + 1]
|
||||
else:
|
||||
next_workorder = None
|
||||
if next_workorder and (next_workorder.state == 'ready' or (
|
||||
next_workorder.state == 'waiting' and next_workorder.is_subcontract)) and cur_workorder.state == 'done':
|
||||
record.back_button_display = True
|
||||
else:
|
||||
|
||||
@@ -564,6 +564,13 @@ class StockPicking(models.Model):
|
||||
|
||||
part_numbers = fields.Char(string="零件图号", compute='_compute_part_info', store=True, index=True)
|
||||
part_names = fields.Char(string="零件名称", compute='_compute_part_info', store=True, index=True)
|
||||
model_id = fields.Char('模型ID', compute='_compute_model_id', store=True, index=True)
|
||||
|
||||
@api.depends('move_ids_without_package.model_id')
|
||||
def _compute_model_id(self):
|
||||
for picking in self:
|
||||
model_id = picking.move_ids_without_package.mapped('model_id')
|
||||
picking.model_id = ','.join(filter(None, model_id))
|
||||
|
||||
@api.depends('move_ids_without_package.part_number', 'move_ids_without_package.part_name')
|
||||
def _compute_part_info(self):
|
||||
@@ -839,6 +846,7 @@ class ReStockMove(models.Model):
|
||||
materiel_height = fields.Float(string='物料高度', digits=(16, 4))
|
||||
part_number = fields.Char(string='零件图号', compute='_compute_part_info', store=True)
|
||||
part_name = fields.Char(string='零件名称', compute='_compute_part_info', store=True)
|
||||
model_id = fields.Char('模型ID', related='product_id.model_id')
|
||||
|
||||
@api.depends('product_id')
|
||||
def _compute_part_info(self):
|
||||
|
||||
@@ -602,6 +602,7 @@
|
||||
<field name="part_number"/>
|
||||
<field name="sale_order_id"/>
|
||||
<field name="deadline_of_delivery" icon="fa-calendar" enable_counters="1" filter_domain="[('deadline_of_delivery', 'ilike', self)]"/>
|
||||
<field name="model_id"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='product_variant_attributes']" position="attributes">
|
||||
<attribute name="invisible">1</attribute>
|
||||
|
||||
@@ -677,8 +677,9 @@
|
||||
<field name="inherit_id" ref="mrp.view_mrp_production_work_order_search"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_id" position="after">
|
||||
<field name="part_number" string="成品零件图号"/>
|
||||
<field name="model_id" string="模型id"/>
|
||||
<field name="part_number" string="零件图号"/>
|
||||
<field name="part_name" string="零件名称"/>
|
||||
<field name="model_id" string="模型ID"/>
|
||||
</field>
|
||||
<xpath expr="//filter[@name='progress']" position="after">
|
||||
<filter string="待检测" name="state" domain="[('state','=','to be detected')]"/>
|
||||
|
||||
@@ -12,5 +12,18 @@
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="product_template_search_inherit_sf_manufacturing" model="ir.ui.view">
|
||||
<field name="name">product.template.search</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="product.product_template_search_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='categ_id']" position="after">
|
||||
<field name="part_number" string="零件图号"/>
|
||||
<field name="part_name" string="零件名称"/>
|
||||
<field name="model_id" string="模型ID"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -73,6 +73,7 @@
|
||||
<xpath expr="//field[@name='picking_type_id']" position="after">
|
||||
<field name="part_numbers" string="零件图号" filter_domain="[('part_numbers', 'ilike', self)]"/>
|
||||
<field name="part_names" string="零件名称" filter_domain="[('part_names', 'ilike', self)]"/>
|
||||
<field name="model_id" string="模型ID" filter_domain="[('model_id', 'ilike', self)]"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -15,6 +15,7 @@ class sf_production_plan(models.Model):
|
||||
# _order = 'state desc, write_date desc'
|
||||
part_name = fields.Char('零件名称', related='product_id.part_name', readonly=True)
|
||||
part_number = fields.Char('零件图号', related='product_id.part_number', readonly=True)
|
||||
model_id = fields.Char('模型ID', related='product_id.model_id')
|
||||
state = fields.Selection([
|
||||
('draft', '待排程'),
|
||||
('done', '已排程'),
|
||||
|
||||
@@ -170,6 +170,7 @@
|
||||
<field name="part_number"/>
|
||||
<field name="order_deadline" filter_domain="[('order_deadline', 'ilike', self)]"/>
|
||||
<field name="production_line_id"/>
|
||||
<field name="model_id"/>
|
||||
<filter string="待排程" name="draft" domain="[('state','=','draft')]"/>
|
||||
<filter string="已排程" name="done" domain="[('state','=','done')]"/>
|
||||
<filter string="加工中" name="processing" domain="[('state','=','processing')]"/>
|
||||
|
||||
Reference in New Issue
Block a user