Merge branch 'develop' into feature/sf品牌页面表格样式的修改

This commit is contained in:
WEB许何哲\xuhez
2023-09-05 16:45:32 +08:00
26 changed files with 997 additions and 259 deletions

View File

@@ -339,7 +339,7 @@ class MrpProduction(models.Model):
current_sequence += 1
if work.name == '获取CNC加工程序':
work.button_start()
#work.fetchCNC()
# work.fetchCNC()
# 创建工单并进行排序
def _create_workorder(self):

View File

@@ -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
@@ -472,3 +497,22 @@ class ReStockMove(models.Model):
item.product_id.write({'register_state': '注册失败'})
except Exception as e:
raise UserError("注册刀具到云端失败,请联系管理员!")
class ReStockQuant(models.Model):
_inherit = 'stock.quant'
def action_apply_inventory(self):
inventory_diff_quantity = self.inventory_diff_quantity
super(ReStockQuant, self).action_apply_inventory()
if inventory_diff_quantity >= 1:
stock = self.env['stock.move'].search([('product_id', '=', self.product_id.id), ('is_inventory', '=', True),
('reference', '=', '更新的产品数量'), ('state', '=', 'done')],
limit=1, order='id desc')
if self.product_id.categ_type == '夹具':
stock._register_fixture()
elif self.product_id.categ_type == '刀具':
stock._register_cutting_tool()
return True