From e5213d06aeb5d80cd8e7b405888271f7fc2ba72b Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Tue, 5 Sep 2023 10:40:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E5=88=B6=E9=80=A0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E6=97=B6=E5=90=8C=E6=AD=A5=E5=88=9B=E5=BB=BA=E6=8E=92?= =?UTF-8?q?=E7=A8=8B=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/stock.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 8b95c5af..783e1ea7 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -7,7 +7,7 @@ from odoo.exceptions import ValidationError, UserError import requests import json from re import findall as regex_findall -from datetime import datetime +from datetime import datetime, timedelta from re import split as regex_split from odoo import SUPERUSER_ID, _, api, fields, models from odoo.tools import float_compare @@ -154,6 +154,7 @@ class StockRule(models.Model): '''创建制造订单''' productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create( productions_values) + self.env['stock.move'].sudo().create(productions._get_moves_raw_values()) self.env['stock.move'].sudo().create(productions._get_moves_finished_values()) ''' @@ -188,6 +189,30 @@ class StockRule(models.Model): 'mail.message_origin_link', values={'self': production, 'origin': origin_production}, subtype_id=self.env.ref('mail.mt_note').id) + ''' + 创建生产计划 + ''' + # 工单耗时 + workorder_duration = 0 + for workorder in production.workorder_ids: + workorder_duration += workorder.duration_expected + + + sale_order = self.env['sale.order'].sudo().search([('name', '=', production.origin)]) + if sale_order: + bb = sale_order.deadline_of_delivery + productions = self.env['sf.production.plan'].with_user(SUPERUSER_ID).sudo().with_company(company_id).\ + create({ + 'name': production.name, + 'production_id': production.id, + 'date_planned_start': production.date_planned_start, + 'origin': production.origin, + 'product_qty': production.product_qty, + 'product_id': production.product_id.id, + 'state': 'draft', + }) + + return True