工单优化更新
This commit is contained in:
@@ -248,6 +248,7 @@ class CuttingToolType(models.Model):
|
|||||||
remark = fields.Text('备注')
|
remark = fields.Text('备注')
|
||||||
active = fields.Boolean('有效', default=True)
|
active = fields.Boolean('有效', default=True)
|
||||||
|
|
||||||
|
|
||||||
class CNCprocessing(models.Model):
|
class CNCprocessing(models.Model):
|
||||||
_name = 'cnc.processing'
|
_name = 'cnc.processing'
|
||||||
_description = "CNC加工"
|
_description = "CNC加工"
|
||||||
|
|||||||
@@ -297,7 +297,7 @@
|
|||||||
<field name="name" string="名称" filter_domain="[('name','ilike',self)]"/>
|
<field name="name" string="名称" filter_domain="[('name','ilike',self)]"/>
|
||||||
<field name="code" string="编码" filter_domain="[('code','ilike',self)]"/>
|
<field name="code" string="编码" filter_domain="[('code','ilike',self)]"/>
|
||||||
<group string="分组">
|
<group string="分组">
|
||||||
<filter name="state" string="状态" domain="[]" context="{'group_by': 'state'}"/>
|
<filter name="state" string="状态" domain="[]" context="{'group_by': 'state'}"/>
|
||||||
</group>
|
</group>
|
||||||
</search>
|
</search>
|
||||||
|
|
||||||
@@ -337,5 +337,6 @@
|
|||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -13,6 +13,8 @@
|
|||||||
'depends': ['mrp'],
|
'depends': ['mrp'],
|
||||||
'data': [
|
'data': [
|
||||||
'views/sf_production.xml',
|
'views/sf_production.xml',
|
||||||
|
|
||||||
|
|
||||||
],
|
],
|
||||||
'demo': [
|
'demo': [
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
from . import sf_production
|
from . import sf_production
|
||||||
from . import mrp_workorder
|
from . import mrp_workorder
|
||||||
|
|
||||||
|
|||||||
@@ -203,115 +203,51 @@ class StockRule(models.Model):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# @api.model
|
@api.model
|
||||||
# def _run_manufacture(self, procurements):
|
def _run_manufacture(self, procurements):
|
||||||
# productions_values_by_company = defaultdict(list)
|
productions_values_by_company = defaultdict(list)
|
||||||
# errors = []
|
errors = []
|
||||||
# for procurement, rule in procurements:
|
for procurement, rule in procurements:
|
||||||
# if float_compare(procurement.product_qty, 0, precision_rounding=procurement.product_uom.rounding) <= 0:
|
if float_compare(procurement.product_qty, 0, precision_rounding=procurement.product_uom.rounding) <= 0:
|
||||||
# # If procurement contains negative quantity, don't create a MO that would be for a negative value.
|
# If procurement contains negative quantity, don't create a MO that would be for a negative value.
|
||||||
# continue
|
continue
|
||||||
# bom = rule._get_matching_bom(procurement.product_id, procurement.company_id, procurement.values)
|
bom = rule._get_matching_bom(procurement.product_id, procurement.company_id, procurement.values)
|
||||||
#
|
|
||||||
# product = self.env['product.template'].search(
|
productions_values_by_company[procurement.company_id.id].append(rule._prepare_mo_vals(*procurement, bom))
|
||||||
# ["&", ("id", '=', procurement.product_id.id), ('single_manufacturing', '!=', False)])
|
|
||||||
# if not product:
|
if errors:
|
||||||
# productions_values_by_company[procurement.company_id.id].append(
|
raise ProcurementException(errors)
|
||||||
# rule._prepare_mo_vals1(*procurement, bom))
|
|
||||||
# else:
|
for company_id, productions_values in productions_values_by_company.items():
|
||||||
# orders_vals = rule._prepare_mo_vals(*procurement, bom)
|
# create the MO as SUPERUSER because the current user may not have the rights to do it (mto product launched by a sale for example)
|
||||||
#
|
productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create(
|
||||||
# if isinstance(orders_vals, list):
|
productions_values)
|
||||||
# for vals in orders_vals:
|
self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
||||||
# productions_values_by_company[procurement.company_id.id].append(vals)
|
self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
||||||
# else:
|
productions._create_workorder()
|
||||||
# productions_values_by_company[procurement.company_id.id].append(orders_vals)
|
productions.lot_producing_id._get_next_serial(productions.company_id,productions.product_id)
|
||||||
#
|
productions.action_generate_serial()
|
||||||
# if errors:
|
productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
|
||||||
# raise ProcurementException(errors)
|
(
|
||||||
#
|
p.move_dest_ids.procure_method != 'make_to_order' and not p.move_raw_ids and not p.workorder_ids)).action_confirm()
|
||||||
# for company_id, productions_values in productions_values_by_company.items():
|
|
||||||
# # create the MO as SUPERUSER because the current user may not have the rights to do it (mto product launched by a sale for example)
|
for production in productions:
|
||||||
# productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create(
|
origin_production = production.move_dest_ids and production.move_dest_ids[
|
||||||
# productions_values)
|
0].raw_material_production_id or False
|
||||||
# a = self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
orderpoint = production.orderpoint_id
|
||||||
# b = self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
if orderpoint and orderpoint.create_uid.id == SUPERUSER_ID and orderpoint.trigger == 'manual':
|
||||||
# c = productions._create_workorder()
|
production.message_post(
|
||||||
# productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
|
body=_('This production order has been created from Replenishment Report.'),
|
||||||
# (
|
message_type='comment',
|
||||||
# p.move_dest_ids.procure_method != 'make_to_order' and not p.move_raw_ids and not p.workorder_ids)).action_confirm()
|
subtype_xmlid='mail.mt_note')
|
||||||
#
|
elif orderpoint:
|
||||||
# for production in productions:
|
production.message_post_with_view(
|
||||||
# origin_production = production.move_dest_ids and production.move_dest_ids[
|
'mail.message_origin_link',
|
||||||
# 0].raw_material_production_id or False
|
values={'self': production, 'origin': orderpoint},
|
||||||
# orderpoint = production.orderpoint_id
|
subtype_id=self.env.ref('mail.mt_note').id)
|
||||||
# if orderpoint and orderpoint.create_uid.id == SUPERUSER_ID and orderpoint.trigger == 'manual':
|
elif origin_production:
|
||||||
# production.message_post(
|
production.message_post_with_view(
|
||||||
# body=_('This production order has been created from Replenishment Report.'),
|
'mail.message_origin_link',
|
||||||
# message_type='comment',
|
values={'self': production, 'origin': origin_production},
|
||||||
# subtype_xmlid='mail.mt_note')
|
subtype_id=self.env.ref('mail.mt_note').id)
|
||||||
# elif orderpoint:
|
return True
|
||||||
# production.message_post_with_view(
|
|
||||||
# 'mail.message_origin_link',
|
|
||||||
# values={'self': production, 'origin': orderpoint},
|
|
||||||
# subtype_id=self.env.ref('mail.mt_note').id)
|
|
||||||
# elif origin_production:
|
|
||||||
# production.message_post_with_view(
|
|
||||||
# 'mail.message_origin_link',
|
|
||||||
# values={'self': production, 'origin': origin_production},
|
|
||||||
# subtype_id=self.env.ref('mail.mt_note').id)
|
|
||||||
# return True
|
|
||||||
#
|
|
||||||
# def _prepare_mo_vals1(self, product_id, product_qty, product_uom, location_id, name, origin, company_id, values,
|
|
||||||
# bom):
|
|
||||||
# date_planned = self._get_date_planned(product_id, company_id, values)
|
|
||||||
# date_deadline = values.get('date_deadline') or date_planned + relativedelta(
|
|
||||||
# days=company_id.manufacturing_lead) + relativedelta(days=product_id.produce_delay)
|
|
||||||
# mo_values = {
|
|
||||||
# 'origin': origin,
|
|
||||||
# 'product_id': product_id.id,
|
|
||||||
# 'product_description_variants': values.get('product_description_variants'),
|
|
||||||
# 'product_qty': product_qty,
|
|
||||||
# 'product_uom_id': product_uom.id,
|
|
||||||
# 'location_src_id': self.location_src_id.id or self.picking_type_id.default_location_src_id.id or location_id.id,
|
|
||||||
# 'location_dest_id': location_id.id,
|
|
||||||
# 'bom_id': bom.id,
|
|
||||||
# 'date_deadline': date_deadline,
|
|
||||||
# 'date_planned_start': date_planned,
|
|
||||||
# 'date_planned_finished': fields.Datetime.from_string(values['date_planned']),
|
|
||||||
# 'procurement_group_id': False,
|
|
||||||
# 'propagate_cancel': self.propagate_cancel,
|
|
||||||
# 'orderpoint_id': values.get('orderpoint_id', False) and values.get('orderpoint_id').id,
|
|
||||||
# 'picking_type_id': self.picking_type_id.id or values['warehouse_id'].manu_type_id.id,
|
|
||||||
# 'company_id': company_id.id,
|
|
||||||
# 'move_dest_ids': values.get('move_dest_ids') and [(4, x.id) for x in values['move_dest_ids']] or False,
|
|
||||||
# 'user_id': False,
|
|
||||||
# }
|
|
||||||
# # Use the procurement group created in _run_pull mrp override
|
|
||||||
# # Preserve the origin from the original stock move, if available
|
|
||||||
# if location_id.warehouse_id.manufacture_steps == 'pbm_sam' and values.get('move_dest_ids') and values.get(
|
|
||||||
# 'group_id') and values['move_dest_ids'][0].origin != values['group_id'].name:
|
|
||||||
# origin = values['move_dest_ids'][0].origin
|
|
||||||
# mo_values.update({
|
|
||||||
# 'name': values['group_id'].name,
|
|
||||||
# 'procurement_group_id': values['group_id'].id,
|
|
||||||
# 'origin': origin,
|
|
||||||
# })
|
|
||||||
# return mo_values
|
|
||||||
#
|
|
||||||
# def _prepare_mo_vals(self, product_id, product_qty, product_uom, location_id, name, origin, company_id, values,
|
|
||||||
# bom):
|
|
||||||
#
|
|
||||||
# mo_lists = []
|
|
||||||
# for num in range(1, int(product_qty) + 1):
|
|
||||||
# vals = super(StockRule, self)._prepare_mo_vals(product_id, 1.0, product_uom, location_id, name, origin,
|
|
||||||
# company_id, values,
|
|
||||||
# bom)
|
|
||||||
# vals.update({
|
|
||||||
# # 'name': values['group_id'].name,
|
|
||||||
# 'procurement_group_id': values['group_id'].id,
|
|
||||||
# # 'origin': origin,
|
|
||||||
# })
|
|
||||||
# mo_lists.append(vals)
|
|
||||||
#
|
|
||||||
# return mo_lists
|
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
""",
|
""",
|
||||||
'category': 'YZ',
|
'category': 'YZ',
|
||||||
'website': 'https://www.sf.cs.jikimo.com',
|
'website': 'https://www.sf.cs.jikimo.com',
|
||||||
'depends': ['mrp', 'sf_base','hr_holidays'],
|
'depends': ['mrp', 'sf_base', 'hr_holidays'],
|
||||||
'data': [
|
'data': [
|
||||||
'views/sf_tray_view.xml',
|
'views/sf_tray_view.xml',
|
||||||
'views/sf_workorder.xml',
|
'views/sf_workorder.xml',
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
# -*-coding:utf-8-*-
|
# -*-coding:utf-8-*-
|
||||||
from . import workcenter
|
from . import workcenter
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import math
|
|||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from odoo import api, fields, models, SUPERUSER_ID
|
from odoo import api, fields, models, SUPERUSER_ID
|
||||||
from pystrich.code128 import Code128Encoder
|
from pystrich.code128 import Code128Encoder
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -122,14 +123,6 @@ class MrpWorkOrder(models.Model):
|
|||||||
Y10_axis = fields.Float(string='Uz10', default=0)
|
Y10_axis = fields.Float(string='Uz10', default=0)
|
||||||
Z10_axis = fields.Float(string='Uz10', default=0)
|
Z10_axis = fields.Float(string='Uz10', default=0)
|
||||||
|
|
||||||
# 扫码绑定托盘方法
|
|
||||||
def gettray(self):
|
|
||||||
return ""
|
|
||||||
|
|
||||||
# 解除托盘绑定
|
|
||||||
def unbindtray(self):
|
|
||||||
return ""
|
|
||||||
|
|
||||||
# 计算配料中心点和与x轴倾斜度方法
|
# 计算配料中心点和与x轴倾斜度方法
|
||||||
def getcenter(self):
|
def getcenter(self):
|
||||||
x1 = self.X1_axis
|
x1 = self.X1_axis
|
||||||
@@ -173,30 +166,50 @@ class MrpWorkOrder(models.Model):
|
|||||||
|
|
||||||
cnc_ids = fields.One2many("cnc.processing", 'workorder_id', string="CNC加工")
|
cnc_ids = fields.One2many("cnc.processing", 'workorder_id', string="CNC加工")
|
||||||
|
|
||||||
tray_code = fields.Char( string="托盘",compute='updateTrayState')
|
tray_code = fields.Char(string="托盘")
|
||||||
|
|
||||||
|
# 扫码绑定托盘方法
|
||||||
|
def gettray(self):
|
||||||
|
if self.tray_code != False:
|
||||||
|
values = self.env['sf.tray'].search([("code", "=", self.tray_code)])
|
||||||
|
if values:
|
||||||
|
if values.state == "占用":
|
||||||
|
raise ValidationError('该托盘已占用')
|
||||||
|
if values.state == "报损":
|
||||||
|
raise ValidationError('该托盘已损坏')
|
||||||
|
else:
|
||||||
|
values.update({
|
||||||
|
'workorder_id': self,
|
||||||
|
'production_id': self.production_id,
|
||||||
|
'state': '占用',
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
raise ValidationError('该托盘编码已失效')
|
||||||
|
else:return ""
|
||||||
|
|
||||||
|
|
||||||
@api.depends('tray_code')
|
# 解除托盘绑定
|
||||||
def updateTrayState(self):
|
def unbindtray(self):
|
||||||
tray = self.env['sf.tray'].search([("code",'=',self.tray_code)])
|
tray = self.env['sf.tray'].search([("production_id", "=", self.production_id.id)])
|
||||||
if tray:
|
if tray:
|
||||||
tray.workorder_id = self
|
tray.unclamp()
|
||||||
else:
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def recreateManufacturing(self):
|
def recreateManufacturing(self):
|
||||||
"""
|
"""
|
||||||
重新生成制造订单
|
重新生成制造订单
|
||||||
"""
|
"""
|
||||||
values = self.env['mrp.production'].create_production1_values(self.production_id)
|
values = self.env['mrp.production'].create_production1_values(self.production_id)
|
||||||
productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(self.production_id.company_id).create(
|
productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(
|
||||||
|
self.production_id.company_id).create(
|
||||||
values)
|
values)
|
||||||
self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
||||||
self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
||||||
productions._create_workorder()
|
productions._create_workorder()
|
||||||
productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
|
productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
|
||||||
(
|
(
|
||||||
p.move_dest_ids.procure_method != 'make_to_order' and not p.move_raw_ids and not p.workorder_ids)).action_confirm()
|
p.move_dest_ids.procure_method != 'make_to_order' and not p.move_raw_ids and not p.workorder_ids)).action_confirm()
|
||||||
|
|
||||||
for production in productions:
|
for production in productions:
|
||||||
origin_production = production.move_dest_ids and production.move_dest_ids[
|
origin_production = production.move_dest_ids and production.move_dest_ids[
|
||||||
@@ -231,8 +244,6 @@ class MrpWorkOrder(models.Model):
|
|||||||
productions.create_workorder1(self.processing_panel)
|
productions.create_workorder1(self.processing_panel)
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def fetchCNC(self):
|
def fetchCNC(self):
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
@@ -247,8 +258,6 @@ class MrpProduction(models.Model):
|
|||||||
_description = "制造订单"
|
_description = "制造订单"
|
||||||
tray_ids = fields.One2many('sf.tray', 'production_id', string="托盘")
|
tray_ids = fields.One2many('sf.tray', 'production_id', string="托盘")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def create_production1_values(self, production):
|
def create_production1_values(self, production):
|
||||||
production_values_str = {'origin': production.origin,
|
production_values_str = {'origin': production.origin,
|
||||||
'product_id': production.product_id.id,
|
'product_id': production.product_id.id,
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
<field name="processing_panel" readonly = "1" />
|
<field name="processing_panel" readonly = "1" />
|
||||||
<field name="tray_code"/>
|
<field name="tray_code"/>
|
||||||
<div class="col-12 col-lg-6 o_setting_box">
|
<div class="col-12 col-lg-6 o_setting_box">
|
||||||
<button type="object" class="oe_highlight" name="gettray" string="扫描托盘"
|
<button type="object" class="oe_highlight" name="gettray" string="绑定托盘"
|
||||||
attrs='{"invisible": [("production_id","=",False)]}'
|
attrs='{"invisible": [("production_id","=",False)]}'
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -159,7 +159,7 @@
|
|||||||
|
|
||||||
<field name="cnc_ids" widget="one2many">
|
<field name="cnc_ids" widget="one2many">
|
||||||
<tree>
|
<tree>
|
||||||
<field name="cnc_id" />
|
<field name="cnc_id"/>
|
||||||
<field name="FNo" />
|
<field name="FNo" />
|
||||||
<field name="FPGName" />
|
<field name="FPGName" />
|
||||||
<field name="FKnifeName" />
|
<field name="FKnifeName" />
|
||||||
@@ -176,8 +176,6 @@
|
|||||||
|
|
||||||
</field>
|
</field>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</page>
|
</page>
|
||||||
|
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|||||||
Reference in New Issue
Block a user