diff --git a/jikimo_purchase_request/__manifest__.py b/jikimo_purchase_request/__manifest__.py
index 2c8bb641..24b28f13 100644
--- a/jikimo_purchase_request/__manifest__.py
+++ b/jikimo_purchase_request/__manifest__.py
@@ -8,18 +8,19 @@
'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': [
- 'jikimo_purchase_request/static/src/**/*'
- ],
- },
+ 'web.assets_backend': [
+ 'jikimo_purchase_request/static/src/**/*'
+ ],
+ },
'application': True,
'installable': True,
'auto_install': False,
diff --git a/jikimo_purchase_request/i18n/zh_CN.po b/jikimo_purchase_request/i18n/zh_CN.po
index 5a43c3a2..c6a51f5c 100644
--- a/jikimo_purchase_request/i18n/zh_CN.po
+++ b/jikimo_purchase_request/i18n/zh_CN.po
@@ -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
diff --git a/jikimo_purchase_request/models/purchase_request.py b/jikimo_purchase_request/models/purchase_request.py
index 7bd6eea5..f50631bc 100644
--- a/jikimo_purchase_request/models/purchase_request.py
+++ b/jikimo_purchase_request/models/purchase_request.py
@@ -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 = '采购申请明细'
diff --git a/jikimo_purchase_request/security/ir.model.access.csv b/jikimo_purchase_request/security/ir.model.access.csv
new file mode 100644
index 00000000..7258fb23
--- /dev/null
+++ b/jikimo_purchase_request/security/ir.model.access.csv
@@ -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
\ No newline at end of file
diff --git a/jikimo_purchase_request/views/purchase_request_view.xml b/jikimo_purchase_request/views/purchase_request_view.xml
index 9976b52a..65a03d6e 100644
--- a/jikimo_purchase_request/views/purchase_request_view.xml
+++ b/jikimo_purchase_request/views/purchase_request_view.xml
@@ -15,6 +15,12 @@
+
+
+
+
+ oe_highlight
+
diff --git a/jikimo_purchase_request/wizard/__init__.py b/jikimo_purchase_request/wizard/__init__.py
index 0a2ad149..f19f8340 100644
--- a/jikimo_purchase_request/wizard/__init__.py
+++ b/jikimo_purchase_request/wizard/__init__.py
@@ -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
diff --git a/jikimo_purchase_request/wizard/purchase_request_wizard.py b/jikimo_purchase_request/wizard/purchase_request_wizard.py
new file mode 100644
index 00000000..94bf327a
--- /dev/null
+++ b/jikimo_purchase_request/wizard/purchase_request_wizard.py
@@ -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"})
diff --git a/jikimo_purchase_request/wizard/purchase_request_wizard_views.xml b/jikimo_purchase_request/wizard/purchase_request_wizard_views.xml
new file mode 100644
index 00000000..6430a314
--- /dev/null
+++ b/jikimo_purchase_request/wizard/purchase_request_wizard_views.xml
@@ -0,0 +1,22 @@
+
+
+
+ purchase.request.wizard.form.view
+ purchase.request.wizard
+
+
+
+
+
\ No newline at end of file
diff --git a/quality_control/models/quality.py b/quality_control/models/quality.py
index dbf4f0b4..76024d28 100644
--- a/quality_control/models/quality.py
+++ b/quality_control/models/quality.py
@@ -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)
diff --git a/quality_control/views/quality_views.xml b/quality_control/views/quality_views.xml
index beed759e..9e1aa961 100644
--- a/quality_control/views/quality_views.xml
+++ b/quality_control/views/quality_views.xml
@@ -493,6 +493,9 @@
+
+
+
diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py
index e0449176..4cc1dae6 100644
--- a/sf_manufacturing/models/mrp_workorder.py
+++ b/sf_manufacturing/models/mrp_workorder.py
@@ -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:
diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py
index d8629eec..e947b373 100644
--- a/sf_manufacturing/models/stock.py
+++ b/sf_manufacturing/models/stock.py
@@ -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):
diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml
index 89c92117..3efd6906 100644
--- a/sf_manufacturing/views/mrp_production_addional_change.xml
+++ b/sf_manufacturing/views/mrp_production_addional_change.xml
@@ -602,6 +602,7 @@
+
1
diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml
index f388ace0..4c4bfc2b 100644
--- a/sf_manufacturing/views/mrp_workorder_view.xml
+++ b/sf_manufacturing/views/mrp_workorder_view.xml
@@ -677,8 +677,9 @@
-
-
+
+
+
diff --git a/sf_manufacturing/views/product_template_views.xml b/sf_manufacturing/views/product_template_views.xml
index 4781c00b..33ac3986 100644
--- a/sf_manufacturing/views/product_template_views.xml
+++ b/sf_manufacturing/views/product_template_views.xml
@@ -12,5 +12,18 @@
+
+
+ product.template.search
+ product.template
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sf_manufacturing/views/stock_picking_view.xml b/sf_manufacturing/views/stock_picking_view.xml
index cc3c1585..35960452 100644
--- a/sf_manufacturing/views/stock_picking_view.xml
+++ b/sf_manufacturing/views/stock_picking_view.xml
@@ -73,6 +73,7 @@
+
diff --git a/sf_plan/models/custom_plan.py b/sf_plan/models/custom_plan.py
index 9e323a7f..1c23def6 100644
--- a/sf_plan/models/custom_plan.py
+++ b/sf_plan/models/custom_plan.py
@@ -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', '已排程'),
diff --git a/sf_plan/views/view.xml b/sf_plan/views/view.xml
index 082cb582..5988549f 100644
--- a/sf_plan/views/view.xml
+++ b/sf_plan/views/view.xml
@@ -170,6 +170,7 @@
+