From 02b4f763269a8e2bf9691aea0cb37b22a64f6c3a Mon Sep 17 00:00:00 2001 From: guanhuan Date: Tue, 24 Jun 2025 11:17:41 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E6=96=99=E9=9C=80=E6=B1=82=E8=AE=A1?= =?UTF-8?q?=E5=88=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_demand_plan/__manifest__.py | 1 + sf_demand_plan/models/__init__.py | 2 +- sf_demand_plan/models/sale_order.py | 3 ++ sf_demand_plan/models/sf_demand_plan.py | 15 ++++++- .../models/sf_production_demand_plan.py | 10 +++++ sf_demand_plan/security/ir.model.access.csv | 4 ++ sf_demand_plan/views/demand_plan.xml | 2 + sf_demand_plan/views/demand_plan_info.xml | 40 +++++++++++++++++++ 8 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 sf_demand_plan/views/demand_plan_info.xml diff --git a/sf_demand_plan/__manifest__.py b/sf_demand_plan/__manifest__.py index e65fdca7..dc772ab2 100644 --- a/sf_demand_plan/__manifest__.py +++ b/sf_demand_plan/__manifest__.py @@ -13,6 +13,7 @@ 'depends': ['sf_plan','jikimo_printing'], 'data': [ 'security/ir.model.access.csv', + 'views/demand_plan_info.xml.xml', 'views/demand_plan.xml', 'wizard/sf_demand_plan_print_wizard_view.xml', ], diff --git a/sf_demand_plan/models/__init__.py b/sf_demand_plan/models/__init__.py index acf4ad1e..544214d3 100644 --- a/sf_demand_plan/models/__init__.py +++ b/sf_demand_plan/models/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- +from . import sf_demand_plan from . import sf_production_demand_plan from . import sale_order -from . import sf_demand_plan diff --git a/sf_demand_plan/models/sale_order.py b/sf_demand_plan/models/sale_order.py index 27e5c603..620bc3b3 100644 --- a/sf_demand_plan/models/sale_order.py +++ b/sf_demand_plan/models/sale_order.py @@ -16,7 +16,10 @@ class ReSaleOrder(models.Model): 'sale_order_id': ret.order_id.id, 'sale_order_line_id': ret.id, } + demand_plan_info = self.env['sf.demand.plan'].sudo().create(vals) + vals.update({'demand_plan_id': demand_plan_info.id}) demand_plan = self.env['sf.production.demand.plan'].sudo().create(vals) + demand_plan_info.write({'line_ids': demand_plan.id}) if demand_plan.product_id.machining_drawings_name: filename_url = demand_plan.product_id.machining_drawings_name.rsplit('.', 1)[0] wizard_vals = { diff --git a/sf_demand_plan/models/sf_demand_plan.py b/sf_demand_plan/models/sf_demand_plan.py index abf8cd41..14c6a9de 100644 --- a/sf_demand_plan/models/sf_demand_plan.py +++ b/sf_demand_plan/models/sf_demand_plan.py @@ -12,7 +12,15 @@ class SfDemandPlan(models.Model): list = [(m.sync_id, m.name) for m in machinings] return list - line_ids = fields.One2many('sf.production.demand.plan', 'demand_plan_id', string="需求计划", copy=True) + state = fields.Selection([ + ('10', '草稿'), + ('20', '待工艺设计'), + ('30', '部分下达'), + ('40', '已下达'), + ], string='状态') + + line_ids = fields.One2many(comodel_name='sf.production.demand.plan', + inverse_name='demand_plan_id', string="需求计划", copy=True) sale_order_id = fields.Many2one(comodel_name="sale.order", string="销售订单", readonly=True) @@ -35,6 +43,9 @@ class SfDemandPlan(models.Model): # product_uom_qty = fields.Float( # string="待计划", # related='sale_order_line_id.product_uom_qty', store=True) + # product_uom_qty = fields.Float( + # string="已计划", + # related='sale_order_line_id.product_uom_qty', store=True) model_id = fields.Char('模型ID', related='product_id.model_id') customer_name = fields.Char('客户', related='sale_order_id.customer_name') product_uom_qty = fields.Float( @@ -65,6 +76,8 @@ class SfDemandPlan(models.Model): ('4', '低'), ], string='优先级', default='3') + remark = fields.Char('备注') + @api.depends('product_id.part_number', 'product_id.model_name') def _compute_part_number(self): for line in self: diff --git a/sf_demand_plan/models/sf_production_demand_plan.py b/sf_demand_plan/models/sf_production_demand_plan.py index afc40275..6c745f3b 100644 --- a/sf_demand_plan/models/sf_production_demand_plan.py +++ b/sf_demand_plan/models/sf_production_demand_plan.py @@ -270,6 +270,16 @@ class SfProductionDemandPlan(models.Model): pro_plan_list.date_planned_start = date_planned_start self._do_production_schedule(pro_plan_list) + def edit_button(self): + return { + 'res_model': 'sf.demand.plan', + 'type': 'ir.actions.act_window', + 'name': _("需求计划"), + 'domain': [('line_ids', 'in', self.demand_plan_id.ids)], + 'views': [[self.env.ref('sf_demand_plan.view_sf_demand_plan_list').id, 'list']], + 'target': 'new', + } + def _do_production_schedule(self, pro_plan_list): for pro_plan in pro_plan_list: pro_plan.do_production_schedule() diff --git a/sf_demand_plan/security/ir.model.access.csv b/sf_demand_plan/security/ir.model.access.csv index 56e8e247..106f6fc9 100644 --- a/sf_demand_plan/security/ir.model.access.csv +++ b/sf_demand_plan/security/ir.model.access.csv @@ -4,3 +4,7 @@ access_sf_production_demand_plan_for_dispatch,sf.production.demand.plan for disp access_sf_demand_plan_print_wizard,sf.demand.plan.print.wizard,model_sf_demand_plan_print_wizard,base.group_user,1,0,0,0 access_sf_demand_plan_print_wizard_for_dispatch,sf.demand.plan.print.wizard for dispatch,model_sf_demand_plan_print_wizard,sf_base.group_plan_dispatch,1,1,0,0 + + +access_sf_demand_plan,sf.demand.plan,model_sf_demand_plan,base.group_user,1,0,0,0 +access_sf_demand_plan_for_dispatch,sf.demand.plan for dispatch,model_sf_demand_plan,sf_base.group_plan_dispatch,1,1,0,0 diff --git a/sf_demand_plan/views/demand_plan.xml b/sf_demand_plan/views/demand_plan.xml index 24a2707e..b4c643ce 100644 --- a/sf_demand_plan/views/demand_plan.xml +++ b/sf_demand_plan/views/demand_plan.xml @@ -69,6 +69,8 @@