Compare commits
84 Commits
feature/cu
...
feature/sa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
281f3c67c3 | ||
|
|
64eb66c334 | ||
|
|
9e5dbc0104 | ||
|
|
c57918736d | ||
|
|
78a456849c | ||
|
|
1816f1a497 | ||
|
|
da815c8ea1 | ||
|
|
32e3c2f79f | ||
|
|
c478b72e04 | ||
|
|
78b0529809 | ||
|
|
17ffac63cb | ||
|
|
acee32cc39 | ||
|
|
b36cf745c2 | ||
|
|
a24279f6e6 | ||
|
|
68b89999a9 | ||
|
|
7c38c7f643 | ||
|
|
4937c3a812 | ||
|
|
05469c71b8 | ||
|
|
210eea3b0b | ||
|
|
f58d1058f7 | ||
|
|
0622d7525f | ||
|
|
7556c09ac2 | ||
|
|
5344e97b7e | ||
|
|
1b10b7bb53 | ||
|
|
9ab164f0fe | ||
|
|
3b07b26303 | ||
|
|
29a32be8d2 | ||
|
|
3620412a13 | ||
|
|
5e72e3d1dd | ||
|
|
4137b304f3 | ||
|
|
caac651ab4 | ||
|
|
30e496442f | ||
|
|
c28c00a47b | ||
|
|
4f4fdeecb5 | ||
|
|
8742f9b98b | ||
|
|
d7ce69f474 | ||
|
|
cf46cff7e5 | ||
|
|
c124e2962c | ||
|
|
f4312c4d4e | ||
|
|
5928456ffe | ||
|
|
305ea9dff7 | ||
|
|
bdfc393099 | ||
|
|
1e1bd63acf | ||
|
|
fa20bb6eb5 | ||
|
|
c82db7159d | ||
|
|
89d6752012 | ||
|
|
3060b35ab2 | ||
|
|
17ad976a32 | ||
|
|
9f3b351544 | ||
|
|
5dc7dc8e0a | ||
|
|
f1868168af | ||
|
|
f084b5d765 | ||
|
|
854c3ceef2 | ||
|
|
4269ce58db | ||
|
|
3555be86c6 | ||
|
|
764472111f | ||
|
|
ce4fc8b8ab | ||
|
|
67f4917491 | ||
|
|
ad885f1e39 | ||
|
|
993d720c40 | ||
|
|
da75a8cd35 | ||
|
|
b35f842915 | ||
|
|
4e7993d035 | ||
|
|
946f02003e | ||
|
|
435315a166 | ||
|
|
676f8eb7eb | ||
|
|
6e9f66506a | ||
|
|
f3e08f5ccc | ||
|
|
c9d7d70d3c | ||
|
|
ee6e457bbd | ||
|
|
ab5b4c477f | ||
|
|
9330be3753 | ||
|
|
a3a2c96d00 | ||
|
|
31187755b9 | ||
|
|
178f538997 | ||
|
|
304f6ad5ba | ||
|
|
8b40714dad | ||
|
|
cb8e415e60 | ||
|
|
889049b107 | ||
|
|
610028c5f4 | ||
|
|
abfac28094 | ||
|
|
24d8d37e0a | ||
|
|
6780d4e758 | ||
|
|
675fb54d37 |
@@ -139,6 +139,7 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', {
|
||||
owl.onMounted(() => {
|
||||
this.activeElement = this.uiService.activeElement;
|
||||
this.setRequired()
|
||||
// this.listherHeaderBodyNum()
|
||||
})
|
||||
return this._super(...arguments);
|
||||
},
|
||||
@@ -165,6 +166,26 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', {
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
listherHeaderBodyNum() {
|
||||
const dom = this.tableRef.el
|
||||
try {
|
||||
const thead = $(dom).children('thead')
|
||||
const tbody = $(dom).children('tbody')
|
||||
const thead_tr = thead.children().eq(0)
|
||||
const tbody_tr = tbody.children().eq(0)
|
||||
const thead_th_num = thead_tr.children().length
|
||||
const tbody_tr_num = tbody_tr.children().length
|
||||
const num = thead_th_num - tbody_tr_num
|
||||
if(num == -1) {
|
||||
tbody.children('tr').each(function () {
|
||||
$(this).children('td').eq(0).remove()
|
||||
})
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
'version': '0.1',
|
||||
|
||||
# any module necessary for this one to work correctly
|
||||
'depends': ['purchase', 'base_tier_validation', 'documents'],
|
||||
'depends': ['purchase', 'base_tier_validation', 'documents', 'purchase_request', 'account'],
|
||||
|
||||
# always loaded
|
||||
'data': [
|
||||
@@ -33,4 +33,10 @@
|
||||
'demo': [
|
||||
'demo/demo.xml',
|
||||
],
|
||||
|
||||
'assets': {
|
||||
'web.assets_backend': [
|
||||
'jikimo_purchase_tier_validation/static/src/js/ir_model_extend.js',
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ _logger = logging.getLogger(__name__)
|
||||
class jikimo_purchase_tier_validation(models.Model):
|
||||
_name = 'purchase.order'
|
||||
_inherit = ['purchase.order', 'tier.validation']
|
||||
_description = "采购订单"
|
||||
|
||||
_tier_validation_buttons_xpath = "/form/header/button[@id='draft_confirm'][1]"
|
||||
|
||||
@@ -21,7 +22,7 @@ class jikimo_purchase_tier_validation(models.Model):
|
||||
def button_confirm(self):
|
||||
for record in self:
|
||||
if record.need_validation and record.validation_status != 'validated':
|
||||
raise ValidationError(_('请先完成审批!'))
|
||||
raise ValidationError(_('此操作需要至少对一条记录进行审批。\n请发起审批申请。'))
|
||||
return super().button_confirm()
|
||||
|
||||
# def button_confirm(self):
|
||||
@@ -63,6 +64,15 @@ class jikimo_purchase_tier_validation(models.Model):
|
||||
if error_messages:
|
||||
raise ValidationError('\n'.join(error_messages))
|
||||
|
||||
# 添加通知消息
|
||||
if hasattr(record, 'message_post'):
|
||||
current_user = self.env.user.name
|
||||
record.message_post(
|
||||
body=f"<strong>{current_user}</strong> 提交审批",
|
||||
message_type='notification',
|
||||
subtype_xmlid='mail.mt_note'
|
||||
)
|
||||
|
||||
return super(jikimo_purchase_tier_validation, self).request_validation()
|
||||
|
||||
# 上传合同文件
|
||||
@@ -152,3 +162,18 @@ class jikimo_purchase_tier_validation(models.Model):
|
||||
'sticky': False,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class jikimo_purchase_request(models.Model):
|
||||
_inherit = 'purchase.request'
|
||||
_description = "采购申请"
|
||||
|
||||
|
||||
class jikimo_account_payment(models.Model):
|
||||
_inherit = 'account.payment'
|
||||
_description = "付款单"
|
||||
|
||||
|
||||
class jikimo_account_move(models.Model):
|
||||
_inherit = 'account.move'
|
||||
_description = "发票账单"
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import {registerPatch} from "@mail/model/model_core";
|
||||
|
||||
registerPatch({
|
||||
name: "ir.model.review",
|
||||
fields: {
|
||||
availableWebViews: {
|
||||
compute() {
|
||||
return ["list", "form", "activity"];
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -8,6 +8,10 @@
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//header/button[@name='button_cancel']" position="replace">
|
||||
</xpath>
|
||||
<xpath expr="//header/field[@name='state']" position="replace">
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,sent,to approve, approved, purchase" readonly="1"/>
|
||||
</xpath>
|
||||
|
||||
|
||||
<xpath expr="//header/button[last()]" position="after">
|
||||
<button name="button_cancel" states="draft,to approve,sent,purchase" string="取消" type="object" data-hotkey="x" />
|
||||
@@ -16,7 +20,7 @@
|
||||
<xpath expr="//header/button[@name='action_rfq_send'][1]" position="before">
|
||||
<field name="validation_status" invisible="1"/>
|
||||
<field name="is_upload_contract_file" invisible="1"/>
|
||||
<button name="upload_contract_file" string="上传合同" type="object" class="oe_highlight" attrs="{'invisible': ['|', ('validation_status', '!=', 'no'), ('is_upload_contract_file', '=', True)]}"/>
|
||||
<button name="upload_contract_file" string="上传合同" type="object" class="oe_highlight" attrs="{'invisible': ['|', '|', ('validation_status', '!=', 'no'), ('is_upload_contract_file', '=', True), ('state', 'not in', ['draft', 'sent'])]}"/>]}"/>
|
||||
<button name="delete_contract_file" string="删除合同" type="object" class="oe_highlight" attrs="{'invisible': ['|', ('validation_status', '!=', 'no'), ('is_upload_contract_file', '=', False)]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//notebook/page[1]" position="before">
|
||||
|
||||
@@ -23,4 +23,4 @@ class ProductTemplate(models.Model):
|
||||
self.is_bfm = product_template_id.is_bfm
|
||||
self.is_manual_processing = product_template_id.is_manual_processing
|
||||
# 复制 seller_ids
|
||||
self.seller_ids = [(0, 0, {'partner_id': seller.partner_id.id, 'delay': 1.0}) for seller in product_template_id.seller_ids]
|
||||
self.seller_ids = [(0, 0, {'partner_id': seller.partner_id.id, 'delay': 1.0, 'price': seller.price}) for seller in product_template_id.seller_ids]
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
'sequence': 120,
|
||||
'summary': 'Control the quality of your products',
|
||||
'website': 'https://www.odoo.com/app/quality',
|
||||
'depends': ['quality'],
|
||||
'depends': ['quality', 'sf_manufacturing'],
|
||||
'description': """
|
||||
Quality Control
|
||||
===============
|
||||
|
||||
@@ -159,6 +159,34 @@ class QualityCheck(models.Model):
|
||||
is_lot_tested_fractionally = fields.Boolean(related='point_id.is_lot_tested_fractionally')
|
||||
testing_percentage_within_lot = fields.Float(related="point_id.testing_percentage_within_lot")
|
||||
product_tracking = fields.Selection(related='product_id.tracking')
|
||||
quality_check_type = fields.Selection([
|
||||
('采购入库检', '采购入库检'),
|
||||
('客供料入库检', '客供料入库检'),
|
||||
('退货入库检', '退货入库检'),
|
||||
('生产入库检', '生产入库检'),
|
||||
('外协入库检', '外协入库检'),
|
||||
('成品发货检', '成品发货检'),
|
||||
('工序外协发货检', '工序外协发货检'),
|
||||
('委外坯料发货检', '委外坯料发货检')], string='类型', compute='_compute_quality_check_type', store=True)
|
||||
|
||||
@api.depends('picking_id')
|
||||
def _compute_quality_check_type(self):
|
||||
for check in self:
|
||||
if check.picking_id:
|
||||
picking_type = check.picking_id.picking_type_id.sequence_code
|
||||
type_mapping = {
|
||||
'IN': '采购入库检',
|
||||
'DL': '客供料入库检',
|
||||
'RET': '退货入库检',
|
||||
'SFP': '生产入库检',
|
||||
'OCIN': '外协入库检',
|
||||
'OUT': '成品发货检',
|
||||
'OCOUT': '工序外协发货检',
|
||||
'RES': '委外坯料发货检',
|
||||
}
|
||||
check.quality_check_type = type_mapping.get(picking_type, False)
|
||||
else:
|
||||
check.quality_check_type = False
|
||||
|
||||
@api.depends('measure_success')
|
||||
def _compute_warning_message(self):
|
||||
@@ -301,6 +329,19 @@ class QualityAlert(models.Model):
|
||||
_inherit = "quality.alert"
|
||||
|
||||
title = fields.Char('Title')
|
||||
part_number = fields.Char(string='零件图号', compute='_compute_part_info', store=True)
|
||||
part_name = fields.Char(string='零件名称', compute='_compute_part_info', store=True)
|
||||
|
||||
@api.depends('product_id', 'picking_id')
|
||||
def _compute_part_info(self):
|
||||
for alert in self:
|
||||
if alert.product_tmpl_id.categ_id.name == '成品':
|
||||
alert.part_number = alert.product_id.part_number
|
||||
alert.part_name = alert.product_id.part_name
|
||||
elif alert.product_id.categ_id.name == '坯料':
|
||||
if alert.picking_id.move_ids_without_package:
|
||||
alert.part_number = alert.picking_id.move_ids_without_package[0].part_number
|
||||
alert.part_name = alert.picking_id.move_ids_without_package[0].part_name
|
||||
|
||||
def action_see_check(self):
|
||||
return {
|
||||
|
||||
@@ -90,6 +90,8 @@
|
||||
<field name="lot_id" context="{'default_product_id': product_id}"
|
||||
groups="stock.group_production_lot"/>
|
||||
<field name="picking_id"/>
|
||||
<field name="part_name"/>
|
||||
<field name="part_number"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="team_id"/>
|
||||
@@ -150,6 +152,10 @@
|
||||
<field name="date_assign" position="after">
|
||||
<field name="company_id" groups="base.main_company"/>
|
||||
</field>
|
||||
<field name="product_tmpl_id" position="after">
|
||||
<field name="part_name" optional="show"/>
|
||||
<field name="part_number" optional="show"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -260,6 +266,8 @@
|
||||
<field name="company_id" invisible="1"/>
|
||||
<field name="product_id" attrs="{'invisible' : [('measure_on', '=', 'operation')]}"/>
|
||||
<field name="measure_on" attrs="{'readonly': [('point_id', '!=', False)]}"/>
|
||||
<field name="part_name"/>
|
||||
<field name="part_number"/>
|
||||
<field name="show_lot_text" invisible="1"/>
|
||||
<field name="move_line_id" invisible="1"/>
|
||||
<field name="product_tracking" invisible="1"/>
|
||||
@@ -448,6 +456,10 @@
|
||||
<filter string="Control Point" name="groupby_point_id" context="{'group_by': 'point_id'}"/>
|
||||
<filter string="Team" name="groupby_team_id" context="{'group_by': 'team_id'}"/>
|
||||
</group>
|
||||
<searchpanel>
|
||||
<field name="quality_check_type" icon="fa-filter" enable_counters="1"/>
|
||||
<field name="quality_state" icon="fa-filter" enable_counters="1"/>
|
||||
</searchpanel>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
# 只有它被屏蔽了
|
||||
# 'views/SfWorkOrderBarcodes.xml',
|
||||
'views/WorkCenterBarcodes.xml',
|
||||
'views/Stock_picking_Barcodes.xml',
|
||||
# 'views/Stock_picking_Barcodes.xml',
|
||||
'views/machine_monitor.xml',
|
||||
'views/machine_info_present.xml',
|
||||
'views/delivery_record.xml',
|
||||
|
||||
21
sf_manufacturing/i18n/zh_CN.po
Normal file
21
sf_manufacturing/i18n/zh_CN.po
Normal file
@@ -0,0 +1,21 @@
|
||||
#. module: sf_manufacturing
|
||||
#. odoo-python
|
||||
#: code:addons/sf_manufacturing/models/mrp_production.py:0
|
||||
#, python-format
|
||||
msgid "You must enter a serial number for %s"
|
||||
msgstr "您必须为%s输入一个序列号。"
|
||||
|
||||
|
||||
#. module: sf_manufacturing
|
||||
#. odoo-python
|
||||
#: code:addons/sf_manufacturing/models/mrp_production.py:0
|
||||
#, python-format
|
||||
msgid "You must enter a serial number for each line of %s"
|
||||
msgstr "您必须为以下各%s行输入序列号"
|
||||
|
||||
#. module: sf_manufacturing
|
||||
#. odoo-python
|
||||
#: code:addons/sf_manufacturing/models/mrp_production.py:0
|
||||
#, python-format
|
||||
msgid "You have %s incomplete supplies: %s"
|
||||
msgstr "您有%s补给未完成: %s"
|
||||
@@ -783,26 +783,28 @@ class MrpProduction(models.Model):
|
||||
workorder.duration_expected = workorder._get_duration_expected()
|
||||
|
||||
# 外协出入库单处理
|
||||
def get_subcontract_pick_purchase(self):
|
||||
def get_subcontract_pick_purchase(self, special_design_workorder):
|
||||
production_all = self.sorted(lambda x: x.id)
|
||||
product_id_to_production_names = {}
|
||||
grouped_product_ids = {k: list(g) for k, g in
|
||||
groupby(production_all, key=lambda x: x.product_id.id)}
|
||||
for product_id, pd in grouped_product_ids.items():
|
||||
product_id_to_production_names[product_id] = [p.name for p in pd]
|
||||
sorted_workorders = None
|
||||
for production in production_all:
|
||||
proc_workorders = []
|
||||
process_parameter_workorder = self.env['mrp.workorder'].search(
|
||||
[('surface_technics_parameters_id', '!=', False), ('production_id', '=', production.id),
|
||||
('is_subcontract', '=', True), ('state', '!=', 'cancel')], order='sequence asc')
|
||||
if process_parameter_workorder:
|
||||
# 将这些特殊表面工艺工单的采购单与调拨单置为失效
|
||||
for workorder in process_parameter_workorder:
|
||||
workorder._get_surface_technics_purchase_ids().write({'state': 'cancel'})
|
||||
workorder.move_subcontract_workorder_ids.write({'state': 'cancel'})
|
||||
workorder.move_subcontract_workorder_ids.picking_id.write({'state': 'cancel'})
|
||||
# proc_workorders = []
|
||||
# process_parameter_workorder = self.env['mrp.workorder'].search(
|
||||
# [('surface_technics_parameters_id', '!=', False), ('production_id', '=', production.id),
|
||||
# ('is_subcontract', '=', True), ('state', '!=', 'cancel')], order='sequence asc')
|
||||
# need_delete_workorder = process_parameter_workorder - special_design_workorder
|
||||
# for workorder in need_delete_workorder:
|
||||
# workorder._get_surface_technics_purchase_ids().write({'active': False})
|
||||
# workorder.move_subcontract_workorder_ids.write({'state': 'cancel'})
|
||||
# workorder.move_subcontract_workorder_ids.picking_id.write({'active': False})
|
||||
|
||||
if special_design_workorder:
|
||||
consecutive_workorders = []
|
||||
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.sequence)
|
||||
sorted_workorders = sorted(special_design_workorder, key=lambda w: w.sequence)
|
||||
# for i, workorder in enumerate(sorted_workorders):
|
||||
# # 检查当前工作订单和下一个工作订单是否连续,并且供应商相同
|
||||
# if i == 0:
|
||||
@@ -841,6 +843,8 @@ class MrpProduction(models.Model):
|
||||
# self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production)
|
||||
# self.env['purchase.order'].get_purchase_order(consecutive_workorders, production,
|
||||
# product_id_to_production_names)
|
||||
if not sorted_workorders:
|
||||
return
|
||||
for workorders in reversed(sorted_workorders):
|
||||
self.env['stock.picking'].create_outcontract_picking(workorders, production, sorted_workorders)
|
||||
self.env['purchase.order'].get_purchase_order(workorders, production, product_id_to_production_names)
|
||||
@@ -1615,6 +1619,26 @@ class MrpProduction(models.Model):
|
||||
})
|
||||
return action
|
||||
|
||||
def _subcontract_sanity_check(self):
|
||||
for production in self:
|
||||
if production.product_tracking != 'none' and not self.lot_producing_id:
|
||||
raise UserError(_('You must enter a serial number for %s') % production.product_id.name)
|
||||
for sml in production.move_raw_ids.move_line_ids:
|
||||
if sml.tracking != 'none' and not sml.lot_id:
|
||||
picking_ids = production.picking_ids.filtered(
|
||||
lambda p: p.state not in ['done', 'cancel'])
|
||||
picking_num = len(picking_ids)
|
||||
picking_info = ', '.join(
|
||||
['%s:%s' % (picking.picking_type_id.name, picking.name) for picking in picking_ids]
|
||||
)
|
||||
if picking_info:
|
||||
raise UserError(_('You have %s incomplete supplies: %s') % (
|
||||
picking_num, picking_info))
|
||||
else:
|
||||
raise UserError(
|
||||
_('You must enter a serial number for each line of %s') % sml.product_id.display_name)
|
||||
return True
|
||||
|
||||
|
||||
class sf_detection_result(models.Model):
|
||||
_name = 'sf.detection.result'
|
||||
|
||||
@@ -1456,6 +1456,9 @@ class ResMrpWorkOrder(models.Model):
|
||||
|
||||
# 解绑托盘
|
||||
def unbind_tray(self):
|
||||
for item in self:
|
||||
self.env['stock.lot'].sudo().search([('rfid', '=', item.rfid_code)]).write(
|
||||
{'tool_material_status': '可用'})
|
||||
self.production_id.workorder_ids.write({
|
||||
'rfid_code': False,
|
||||
'tray_serial_number': False,
|
||||
|
||||
@@ -10,9 +10,42 @@ from odoo.tools import OrderedSet
|
||||
# _get_surface_technics_purchase_ids
|
||||
class PurchaseOrder(models.Model):
|
||||
_inherit = 'purchase.order'
|
||||
production_count = fields.Integer(
|
||||
"关联制造订单",
|
||||
compute='_compute_workorder_count',
|
||||
)
|
||||
|
||||
def action_view_production(self):
|
||||
origins = [order.name for order in self.picking_ids]
|
||||
production_id = self.env['mrp.production'].search([('origin', 'in', origins)])
|
||||
if not production_id:
|
||||
return
|
||||
action = {
|
||||
'res_model': 'mrp.production',
|
||||
'type': 'ir.actions.act_window',
|
||||
}
|
||||
if len(production_id) == 1:
|
||||
action.update({
|
||||
'view_mode': 'form',
|
||||
'res_id': production_id.id,
|
||||
})
|
||||
else:
|
||||
action.update({
|
||||
'name': _("制造订单列表"),
|
||||
'domain': [('id', 'in', production_id.ids)],
|
||||
'view_mode': 'tree,form',
|
||||
})
|
||||
return action
|
||||
|
||||
|
||||
def _compute_workorder_count(self):
|
||||
for purchase in self:
|
||||
origins = [order.name for order in purchase.picking_ids]
|
||||
production_id = self.env['mrp.production'].search([('origin', 'in', origins)])
|
||||
purchase.production_count = len(production_id)
|
||||
def button_confirm(self):
|
||||
super().button_confirm()
|
||||
workorders = self.env['mrp.workorder'].search([('purchase_id', '=', self.id)])
|
||||
workorders = self.env['mrp.workorder'].search([('purchase_id', '=', self.id),('state', '!=', 'cancel')])
|
||||
for workorder in workorders:
|
||||
if workorder.routing_type == '表面工艺' and workorder.is_subcontract is True:
|
||||
move_out = workorder.move_subcontract_workorder_ids[1]
|
||||
|
||||
@@ -36,7 +36,6 @@ class sf_technology_design(models.Model):
|
||||
return workorders_values_str
|
||||
|
||||
def write(self, vals):
|
||||
print('qwfojkqwfkio')
|
||||
return super(sf_technology_design, self).write(vals)
|
||||
def unlink_technology_design(self):
|
||||
self.active = False
|
||||
|
||||
@@ -588,40 +588,34 @@ class StockPicking(models.Model):
|
||||
address_of_delivery = fields.Char('联系地址', compute='_compute_move_ids', store=True)
|
||||
|
||||
retrospect_ref = fields.Char('追溯参考', compute='_compute_move_ids', store=True)
|
||||
|
||||
sale_order_id = fields.Many2one('sale.order', '销售单号', compute='_compute_move_ids', store=True)
|
||||
picking_type_sequence_code = fields.Char(related='picking_type_id.sequence_code')
|
||||
|
||||
@api.depends('move_ids', 'move_ids.product_id')
|
||||
def _compute_move_ids(self):
|
||||
for item in self:
|
||||
if item.move_ids:
|
||||
if item.picking_type_id.sequence_code == 'DL':
|
||||
sale_name = item.move_ids[0].product_id.name.split('-')[1]
|
||||
if 'S' in sale_name:
|
||||
sale_id = self.env['sale.order'].sudo().search([('name', '=', sale_name)])
|
||||
item.person_of_delivery = sale_id.person_of_delivery
|
||||
item.telephone_of_delivery = sale_id.telephone_of_delivery
|
||||
item.address_of_delivery = sale_id.address_of_delivery
|
||||
product_id = item.move_ids[0].product_id
|
||||
if product_id:
|
||||
sale_info = None
|
||||
if product_id.categ_id.type == '坯料' and product_id.name.startswith('R-S'):
|
||||
parts = product_id.name.split('-')
|
||||
if len(parts) >= 3:
|
||||
sale_name = parts[1]
|
||||
sale_info = self.env['sale.order'].sudo().search(
|
||||
[('name', '=', sale_name)])
|
||||
else:
|
||||
raise ValidationError('坯料名称格式错误,正确格式为[R-S???-?]!!!')
|
||||
move_ids = []
|
||||
for move_id in item.move_ids:
|
||||
move_ids.append(move_id.product_id.id)
|
||||
boms = self.env['mrp.bom'].sudo().search([('bom_line_ids.product_id', 'in', move_ids)])
|
||||
if boms:
|
||||
codes_list = []
|
||||
for bom in boms:
|
||||
if bom.product_tmpl_id.default_code:
|
||||
code_list = bom.product_tmpl_id.default_code.split('-')
|
||||
if len(code_list) >= 4:
|
||||
code = '-'.join(code_list[:4])
|
||||
if code not in codes_list:
|
||||
codes_list.append(code)
|
||||
else:
|
||||
raise ValidationError('坯料成品的内部参考值格式错误')
|
||||
item.retrospect_ref = ','.join(codes_list)
|
||||
elif item.picking_type_id.sequence_code in ['INT', 'PC']:
|
||||
pass
|
||||
production_list = self.env['mrp.production'].sudo().search(
|
||||
[('product_id', '=', product_id.id)])
|
||||
if production_list:
|
||||
sale_info = production_list[0].sale_order_id
|
||||
if sale_info:
|
||||
item.sale_order_id = sale_info.id
|
||||
item.retrospect_ref = sale_info.order_code
|
||||
if item.picking_type_id.sequence_code == 'DL':
|
||||
item.person_of_delivery = sale_info.person_of_delivery
|
||||
item.telephone_of_delivery = sale_info.telephone_of_delivery
|
||||
item.address_of_delivery = sale_info.address_of_delivery
|
||||
|
||||
# 设置外协出入单的名称
|
||||
def _get_name_Res(self, rescode):
|
||||
@@ -657,52 +651,58 @@ class StockPicking(models.Model):
|
||||
if move_out:
|
||||
workorder = move_out.subcontract_workorder_id
|
||||
workorder.button_start()
|
||||
if self.location_id.name == '成品存货区' and self.location_dest_id.name == '客户':
|
||||
sale_id = self.env['sale.order'].sudo().search(
|
||||
[('name', '=', self.origin)])
|
||||
if sale_id and res:
|
||||
sale_id.write({'state': 'delivered'})
|
||||
return res
|
||||
|
||||
# 创建 外协出库入单
|
||||
def create_outcontract_picking(self, workorders, item, sorted_workorders):
|
||||
for workorder in workorders:
|
||||
if workorder.move_subcontract_workorder_ids:
|
||||
workorder.move_subcontract_workorder_ids.write({'state': 'waiting'})
|
||||
workorder.move_subcontract_workorder_ids.picking_id.write({'state': 'waiting'})
|
||||
workorder.move_subcontract_workorder_ids.write({'state': 'cancel'})
|
||||
workorder.move_subcontract_workorder_ids.picking_id.write({'state': 'cancel'})
|
||||
# 创建一个新的补货组
|
||||
procurement_group_id = self.env['procurement.group'].create({
|
||||
'name': workorder.name,
|
||||
'partner_id': self.partner_id.id,
|
||||
})
|
||||
move_dest_id = False
|
||||
# 如果当前工单是是制造订单的最后一个工艺外协工单
|
||||
if workorder == next((workorder for workorder in reversed(sorted_workorders) if workorder.is_subcontract),
|
||||
None):
|
||||
move_dest_id = item.move_raw_ids[0].id
|
||||
else:
|
||||
# 创建一个新的补货组
|
||||
procurement_group_id = self.env['procurement.group'].create({
|
||||
'name': workorder.name,
|
||||
'partner_id': self.partner_id.id,
|
||||
})
|
||||
move_dest_id = False
|
||||
# 如果当前工单是是制造订单的最后一个工艺外协工单
|
||||
if workorder == next((workorder for workorder in reversed(item.workorder_ids) if workorder.is_subcontract), None):
|
||||
move_dest_id = item.move_raw_ids[0].id
|
||||
else:
|
||||
# 从sorted_workorders中找到上一工单的move
|
||||
if len(sorted_workorders) > 1:
|
||||
move_dest_id = sorted_workorders[sorted_workorders.index(workorder)+1].move_subcontract_workorder_ids[1].id
|
||||
new_picking = True
|
||||
outcontract_picking_type_in = self.env.ref(
|
||||
'sf_manufacturing.outcontract_picking_in').id,
|
||||
outcontract_picking_type_out = self.env.ref(
|
||||
'sf_manufacturing.outcontract_picking_out').id,
|
||||
moves_in = self.env['stock.move'].sudo().create(
|
||||
self.env['stock.move']._get_stock_move_values_Res(item, outcontract_picking_type_in,
|
||||
procurement_group_id.id, move_dest_id))
|
||||
picking_in = self.create(
|
||||
moves_in._get_new_picking_values_Res(item, workorder, 'WH/OCIN/'))
|
||||
# pick_ids.append(picking_in.id)
|
||||
moves_in.write(
|
||||
{'picking_id': picking_in.id, 'state': 'waiting'})
|
||||
moves_in._assign_picking_post_process(new=new_picking)
|
||||
moves_out = self.env['stock.move'].sudo().create(
|
||||
self.env['stock.move']._get_stock_move_values_Res(item, outcontract_picking_type_out,
|
||||
procurement_group_id.id, moves_in.id))
|
||||
workorder.write({'move_subcontract_workorder_ids': [(6, 0, [moves_in.id, moves_out.id])]})
|
||||
picking_out = self.create(
|
||||
moves_out._get_new_picking_values_Res(item, workorder, 'WH/OCOUT/'))
|
||||
# pick_ids.append(picking_out.id)
|
||||
moves_out.write(
|
||||
{'picking_id': picking_out.id, 'state': 'waiting'})
|
||||
moves_out._assign_picking_post_process(new=new_picking)
|
||||
# 从sorted_workorders中找到上一工单的move
|
||||
if len(sorted_workorders) > 1:
|
||||
move_dest_id = \
|
||||
sorted_workorders[sorted_workorders.index(workorder) + 1].move_subcontract_workorder_ids[1].id
|
||||
new_picking = True
|
||||
outcontract_picking_type_in = self.env.ref(
|
||||
'sf_manufacturing.outcontract_picking_in').id,
|
||||
outcontract_picking_type_out = self.env.ref(
|
||||
'sf_manufacturing.outcontract_picking_out').id,
|
||||
moves_in = self.env['stock.move'].sudo().create(
|
||||
self.env['stock.move']._get_stock_move_values_Res(item, outcontract_picking_type_in,
|
||||
procurement_group_id.id, move_dest_id))
|
||||
picking_in = self.create(
|
||||
moves_in._get_new_picking_values_Res(item, workorder, 'WH/OCIN/'))
|
||||
# pick_ids.append(picking_in.id)
|
||||
moves_in.write(
|
||||
{'picking_id': picking_in.id, 'state': 'waiting'})
|
||||
moves_in._assign_picking_post_process(new=new_picking)
|
||||
moves_out = self.env['stock.move'].sudo().create(
|
||||
self.env['stock.move']._get_stock_move_values_Res(item, outcontract_picking_type_out,
|
||||
procurement_group_id.id, moves_in.id))
|
||||
workorder.write({'move_subcontract_workorder_ids': [(6, 0, [moves_in.id, moves_out.id])]})
|
||||
picking_out = self.create(
|
||||
moves_out._get_new_picking_values_Res(item, workorder, 'WH/OCOUT/'))
|
||||
# pick_ids.append(picking_out.id)
|
||||
moves_out.write(
|
||||
{'picking_id': picking_out.id, 'state': 'waiting'})
|
||||
moves_out._assign_picking_post_process(new=new_picking)
|
||||
|
||||
@api.depends('move_type', 'immediate_transfer', 'move_ids.state', 'move_ids.picking_id')
|
||||
def _compute_state(self):
|
||||
@@ -726,6 +726,34 @@ class ReStockMove(models.Model):
|
||||
materiel_length = fields.Float(string='物料长度', digits=(16, 4))
|
||||
materiel_width = fields.Float(string='物料宽度', digits=(16, 4))
|
||||
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)
|
||||
|
||||
@api.depends('product_id')
|
||||
def _compute_part_info(self):
|
||||
for move in self:
|
||||
if move.product_id.categ_id.type == '成品':
|
||||
move.part_number = move.product_id.part_number
|
||||
move.part_name = move.product_id.part_name
|
||||
elif move.product_id.categ_id.type == '坯料':
|
||||
if move.origin:
|
||||
origin = move.origin.split(',')[0] if ',' in move.origin else move.origin
|
||||
mrp_productio_info = self.env['mrp.production'].sudo().search(
|
||||
[('name', '=', origin)])
|
||||
if mrp_productio_info:
|
||||
move.part_number = mrp_productio_info.part_number
|
||||
move.part_name = mrp_productio_info.part_name
|
||||
else:
|
||||
purchase_order_info = self.env['purchase.order'].sudo().search(
|
||||
[('name', '=', origin)])
|
||||
if purchase_order_info:
|
||||
mrp_production_ids = purchase_order_info._get_mrp_productions().ids
|
||||
if mrp_production_ids:
|
||||
mrp_productio_info = self.env['mrp.production'].sudo().search(
|
||||
[('id', '=', mrp_production_ids[0])])
|
||||
if mrp_productio_info:
|
||||
move.part_number = mrp_productio_info.part_number
|
||||
move.part_name = mrp_productio_info.part_name
|
||||
|
||||
def _get_stock_move_values_Res(self, item, picking_type_id, group_id, move_dest_ids=False):
|
||||
route_id = self.env.ref('sf_manufacturing.route_surface_technology_outsourcing').id
|
||||
|
||||
@@ -10,6 +10,18 @@
|
||||
<field name="related_product" optional="show"/>
|
||||
<field name="part_number" optional="show"/>
|
||||
</xpath>
|
||||
<xpath expr="//sheet//div[@class='oe_button_box']" position="inside">
|
||||
<button class="oe_stat_button" name="action_view_production" type="object" icon="fa-wrench"
|
||||
attrs="{'invisible': [('production_count', '=', 0)]}"
|
||||
>
|
||||
<div class="o_field_widget o_stat_info">
|
||||
<span class="o_stat_value">
|
||||
<field name="production_count"/>
|
||||
</span>
|
||||
<span class="o_stat_text">制造订单</span>
|
||||
</div>
|
||||
</button>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
|
||||
@@ -17,6 +17,12 @@
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='backorder_id']" position="after">
|
||||
<field name="retrospect_ref"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='origin']" position="after">
|
||||
<field name="sale_order_id"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='user_id']" position="after">
|
||||
<field name="picking_type_sequence_code" invisible="1"/>
|
||||
<field name="retrospect_ref"
|
||||
@@ -26,6 +32,10 @@
|
||||
attrs="{'invisible':[('picking_type_sequence_code','!=','DL')]}"/>
|
||||
<field name="address_of_delivery" attrs="{'invisible':[('picking_type_sequence_code','!=','DL')]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='product_id']" position="after">
|
||||
<field name="part_number" optional="show"/>
|
||||
<field name="part_name" optional="show"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -34,6 +44,9 @@
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.vpicktree"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='origin']" position="before">
|
||||
<field name="sale_order_id" string="销售单号"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='origin']" position="after">
|
||||
<field name="retrospect_ref"/>
|
||||
</xpath>
|
||||
@@ -45,8 +58,13 @@
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_internal_search"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='name']" position="replace">
|
||||
<field name="name"/>
|
||||
<field name="retrospect_ref"/>
|
||||
<field name="sale_order_id" string="销售单号"/>
|
||||
</xpath>
|
||||
<xpath expr="//filter[@name='picking_type']" position="after">
|
||||
<filter string="追溯参考" name="retrospect_ref" domain="[]"
|
||||
<filter string="追溯参考" name="retrospect" domain="[]"
|
||||
context="{'group_by': 'retrospect_ref'}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
@@ -57,6 +57,7 @@ class ProductionTechnologyWizard(models.TransientModel):
|
||||
# td_upd = self.env['sf.technology.design'].sudo().search(domain)
|
||||
# if td_upd:
|
||||
# ro.write({'sequence': td_upd.sequence, 'active': td_upd.active})
|
||||
# 特殊表面工艺
|
||||
special_design = self.env['sf.technology.design'].sudo().search(
|
||||
[('routing_tag', '=', 'special'), ('production_id', '=', production.id),
|
||||
('is_auto', '=', False), ('active', 'in', [True, False])])
|
||||
@@ -112,7 +113,9 @@ class ProductionTechnologyWizard(models.TransientModel):
|
||||
workorder.blocked_by_workorder_ids = blocked_by_workorder_ids[0]
|
||||
productions._create_workorder(False)
|
||||
if self.production_id.product_id.categ_id.type == '成品':
|
||||
productions.get_subcontract_pick_purchase()
|
||||
special_design_workorder = self.env['mrp.workorder'].search(
|
||||
[('technology_design_id', 'in', special_design.ids), ('production_id', '=', special.production_id.id), ('state', '!=', 'cancel')])
|
||||
productions.get_subcontract_pick_purchase(special_design_workorder)
|
||||
productions.is_adjust = False
|
||||
for item in productions:
|
||||
workorder = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
|
||||
|
||||
@@ -28,7 +28,7 @@ class SFMessagePlan(models.Model):
|
||||
'{{number}}', str(production_num)).replace(
|
||||
'{{request_url}}', url)
|
||||
contents.append(content)
|
||||
return contents
|
||||
return contents, message_queue_ids
|
||||
|
||||
def get_request_url(self):
|
||||
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
|
||||
@@ -292,6 +292,9 @@ class RePurchaseOrder(models.Model):
|
||||
# 合同概况
|
||||
contract_summary = fields.Text(string='合同概况')
|
||||
|
||||
# 选择是否为紧急采购
|
||||
urgent_purchase = fields.Selection([('no', '否'), ('yes', '是')], string='紧急采购', default='no')
|
||||
|
||||
@api.depends('origin')
|
||||
def _compute_purchase_type(self):
|
||||
for purchase in self:
|
||||
@@ -360,7 +363,7 @@ class RePurchaseOrder(models.Model):
|
||||
server_product_process = []
|
||||
purchase_order = pp._get_surface_technics_purchase_ids()
|
||||
if purchase_order:
|
||||
purchase_order.write({'state': 'draft'})
|
||||
pp.purchase_id = [(6, 0, [purchase_order.id])]
|
||||
else:
|
||||
server_template = self.env['product.template'].search(
|
||||
[('server_product_process_parameters_id', '=', pp.surface_technics_parameters_id.id),
|
||||
@@ -370,12 +373,16 @@ class RePurchaseOrder(models.Model):
|
||||
'product_qty': 1,
|
||||
'product_uom': server_template.uom_id.id
|
||||
}))
|
||||
# 获取服务商品最后一个供应商的采购员
|
||||
purchase_user_id = server_template.seller_ids[-1].partner_id.purchase_user_id
|
||||
purchase_order = self.env['purchase.order'].sudo().create({
|
||||
'partner_id': server_template.seller_ids[0].partner_id.id,
|
||||
'origin': production.name,
|
||||
'state': 'draft',
|
||||
'purchase_type': 'consignment',
|
||||
'order_line': server_product_process})
|
||||
'order_line': server_product_process,
|
||||
'user_id': purchase_user_id.id
|
||||
})
|
||||
pp.purchase_id = [(6, 0, [purchase_order.id])]
|
||||
# self.env.cr.commit()
|
||||
|
||||
|
||||
@@ -9,12 +9,16 @@
|
||||
<xpath expr="//header/button[@name='action_view_picking']" position="attributes">
|
||||
<attribute name="invisible">1</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//header/button[@name='button_confirm']" position="replace">
|
||||
</xpath>
|
||||
<xpath expr="//header/button[@name='button_confirm']" position="replace">
|
||||
</xpath>
|
||||
<xpath expr="//header/button[@name='action_rfq_send'][1]" position="before">
|
||||
<button name="button_confirm" type="object" states="sent" string="Confirm Order"
|
||||
context="{'validate_analytic': True}" class="oe_highlight" id="bid_confirm"
|
||||
data-hotkey="v"/>
|
||||
<button name="button_confirm" type="object" states="draft" context="{'validate_analytic': True}"
|
||||
string="Confirm Order" id="draft_confirm"/>
|
||||
<button name="button_confirm" type="object" string="确认订单"
|
||||
context="{'validate_analytic': True}" class="oe_highlight" id="draft_confirm"
|
||||
groups="sf_base.group_purchase,sf_base.group_purchase_director"
|
||||
attrs="{'invisible': [('state', 'in', ['purchase', 'done', 'cancel'])]}"
|
||||
/>
|
||||
<button name="action_view_picking"
|
||||
string="接收产品" class="oe_highlight" type="object"
|
||||
attrs="{'invisible': ['|', '|' , ('is_shipped', '=', True), ('state','not in', ('purchase','done')), ('incoming_picking_count', '=', 0)]}"
|
||||
@@ -25,11 +29,11 @@
|
||||
<xpath expr="//header/button[@name='button_cancel'][2]" position="attributes">
|
||||
<attribute name="invisible">1</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//header/button[@name='button_confirm'][3]" position="attributes">
|
||||
<attribute name="invisible">1</attribute>
|
||||
<xpath expr="//field[@name='user_id']" position="attributes">
|
||||
<attribute name="string">采购员</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//header/button[@name='button_confirm'][4]" position="attributes">
|
||||
<attribute name="invisible">1</attribute>
|
||||
<xpath expr="//field[@name='origin']" position="attributes">
|
||||
<attribute name="string">源单据</attribute>
|
||||
</xpath>
|
||||
|
||||
<field name="partner_id" position="replace">
|
||||
@@ -38,13 +42,6 @@
|
||||
<field name="currency_id" position="after">
|
||||
<field name="remark" attrs="{'readonly': [('state', 'in', ['purchase'])]}" string="订单备注"/>
|
||||
</field>
|
||||
<xpath expr="//form/header/button[@name='button_confirm'][2]" position="replace">
|
||||
<button name="button_confirm" type="object" context="{'validate_analytic': True}"
|
||||
string="确认订单" id="draft_confirm"
|
||||
groups="sf_base.group_purchase,sf_base.group_purchase_director"
|
||||
attrs="{'invisible': [('state', 'in', ['purchase', 'cancel'])]}"
|
||||
/>
|
||||
</xpath>
|
||||
<xpath expr="//form/header/button[@name='action_rfq_send'][1]" position="replace">
|
||||
<button name="action_rfq_send" states="draft" string="通过Email发送采购单" type="object"
|
||||
context="{'send_rfq':True}" class="oe_highlight" data-hotkey="g"
|
||||
@@ -81,10 +78,6 @@
|
||||
<xpath expr="//form/header/button[@name='action_create_invoice'][2]" position="attributes">
|
||||
<attribute name="groups">sf_base.group_purchase,sf_base.group_purchase_director</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//form/header/button[@name='button_confirm']" position="attributes">
|
||||
<attribute name="groups">sf_base.group_purchase,sf_base.group_purchase_director</attribute>
|
||||
<!-- <button name="action_create_invoice" string="创建账单" type="object" class="oe_highlight" context="{'create_bill':True}" attrs="{'invisible': ['|', ('state', 'not in', ('purchase', 'done')), ('invoice_status', 'in', ('no', 'invoiced'))]}" data-hotkey="w" groups="sf_base.group_purchase,sf_base.group_purchase_director"/> -->
|
||||
</xpath>
|
||||
<!-- <xpath expr="//form/header/button[@name='action_create_invoice[2]']" position="attributes">-->
|
||||
<!-- <attribute name="groups">sf_base.group_purchase,sf_base.group_purchase_director</attribute>-->
|
||||
<!-- </xpath>-->
|
||||
@@ -181,6 +174,7 @@
|
||||
<field name="partner_id" position="after">
|
||||
<field name="purchase_type" string="采购类型" readonly="1"/>
|
||||
<field name="picking_type_id" string="作业类型" domain="[('code','=','incoming'), '|', ('warehouse_id', '=', False), ('warehouse_id.company_id', '=', company_id)]" options="{'no_create': True}" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="urgent_purchase"/>
|
||||
<label for="date_planned" string="最近交货日期"/>
|
||||
<div name="date_planned_div" class="o_row">
|
||||
<field name="date_planned" attrs="{'readonly': [('state', 'not in', ('draft', 'sent', 'to approve', 'purchase'))]}"/>
|
||||
@@ -235,6 +229,9 @@
|
||||
<xpath expr="//field[@name='user_id']" position="attributes">
|
||||
<attribute name="string">采购员</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='origin']" position="attributes">
|
||||
<attribute name="string">源单据</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='activity_ids']" position="attributes">
|
||||
<attribute name="optional">hide</attribute>
|
||||
</xpath>
|
||||
@@ -292,6 +289,9 @@
|
||||
<xpath expr="//field[@name='user_id']" position="attributes">
|
||||
<attribute name="string">采购员</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='origin']" position="attributes">
|
||||
<attribute name="string">源单据</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='user_id']" position="after">
|
||||
<field name="delivery_warning" optional="show"/>
|
||||
<field name="date_planned" string="最近交货日期" optional="show" widget="date"/>
|
||||
|
||||
@@ -13,6 +13,74 @@ _logger = logging.getLogger(__name__)
|
||||
class StockPicking(models.Model):
|
||||
_inherit = 'stock.picking'
|
||||
|
||||
pro_purchase_count = fields.Integer('坯料采购单数量', compute='_compute_pro_purchase_count', store=True)
|
||||
|
||||
@api.depends('name')
|
||||
def _compute_pro_purchase_count(self):
|
||||
for sp in self:
|
||||
if sp:
|
||||
po_ids = self.env['purchase.order'].sudo().search([
|
||||
('origin', 'like', sp.name), ('purchase_type', '=', 'standard')])
|
||||
if po_ids:
|
||||
sp.pro_purchase_count = len(po_ids)
|
||||
|
||||
def pro_purchase_order(self):
|
||||
"""
|
||||
坯料采购
|
||||
"""
|
||||
po_ids = self.env['purchase.order'].sudo().search([
|
||||
('origin', 'like', self.name), ('purchase_type', '=', 'standard')])
|
||||
action = {
|
||||
'res_model': 'purchase.order',
|
||||
'type': 'ir.actions.act_window',
|
||||
}
|
||||
if len(po_ids) == 1:
|
||||
action.update({
|
||||
'view_mode': 'form',
|
||||
'res_id': po_ids.id,
|
||||
})
|
||||
else:
|
||||
action.update({
|
||||
'name': _("采购订单列表"),
|
||||
'domain': [('id', 'in', po_ids.ids)],
|
||||
'view_mode': 'tree,form',
|
||||
})
|
||||
return action
|
||||
|
||||
pro_out_purchase_count = fields.Integer('坯料委外单数量', compute='_compute_pro_out_purchase_count', store=True)
|
||||
|
||||
@api.depends('name')
|
||||
def _compute_pro_out_purchase_count(self):
|
||||
for sp in self:
|
||||
if sp:
|
||||
po_ids = self.env['purchase.order'].sudo().search([
|
||||
('origin', 'like', sp.name), ('purchase_type', '=', 'outsourcing')])
|
||||
if po_ids:
|
||||
sp.pro_out_purchase_count = len(po_ids)
|
||||
|
||||
def pro_out_purchase_order(self):
|
||||
"""
|
||||
坯料委外
|
||||
"""
|
||||
po_ids = self.env['purchase.order'].sudo().search([
|
||||
('origin', 'like', self.name), ('purchase_type', '=', 'outsourcing')])
|
||||
action = {
|
||||
'res_model': 'purchase.order',
|
||||
'type': 'ir.actions.act_window',
|
||||
}
|
||||
if len(po_ids) == 1:
|
||||
action.update({
|
||||
'view_mode': 'form',
|
||||
'res_id': po_ids.id,
|
||||
})
|
||||
else:
|
||||
action.update({
|
||||
'name': _("委外订单列表"),
|
||||
'domain': [('id', 'in', po_ids.ids)],
|
||||
'view_mode': 'tree,form',
|
||||
})
|
||||
return action
|
||||
|
||||
# 重写验证,下发发货到bfm
|
||||
def button_validate(self):
|
||||
info = super(StockPicking, self).button_validate()
|
||||
|
||||
@@ -1,6 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
</data>
|
||||
<data>
|
||||
<record id="add_check_out_view_picking_form" model="ir.ui.view">
|
||||
<field name="name">添加坯料采购单链接</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//form//sheet//div[@name='button_box']//button[@name='action_picking_move_tree']" position="before">
|
||||
<button class="oe_stat_button" name="pro_purchase_order" type="object" icon="fa-credit-card"
|
||||
attrs="{'invisible': [('pro_purchase_count', '=', 0)]}">
|
||||
<div class="o_field_widget o_stat_info">
|
||||
<span class="o_stat_value"><field name="pro_purchase_count"/></span>
|
||||
<span class="o_stat_text">坯料采购</span>
|
||||
</div>
|
||||
</button>
|
||||
<button class="oe_stat_button" name="pro_out_purchase_order" type="object" icon="fa-credit-card"
|
||||
attrs="{'invisible': [('pro_out_purchase_count', '=', 0)]}">
|
||||
<div class="o_field_widget o_stat_info">
|
||||
<span class="o_stat_value"><field name="pro_out_purchase_count"/></span>
|
||||
<span class="o_stat_text">坯料委外</span>
|
||||
</div>
|
||||
</button>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -21,7 +21,7 @@ class FixtureMaterialSearch(models.Model):
|
||||
image = fields.Binary('图片', related='product_id.image_1920')
|
||||
number = fields.Integer('总数量', compute='_compute_number')
|
||||
usable_num = fields.Integer('可用数量', compute='_compute_number')
|
||||
have_been_used_num = fields.Integer('在用数量', compute='_compute_number')
|
||||
have_been_used_num = fields.Integer('占用数量', compute='_compute_number')
|
||||
scrap_num = fields.Integer('报废数量', compute='_compute_number')
|
||||
|
||||
barcode_ids = fields.One2many('stock.lot', 'fixture_material_search_id', string='序列号', readonly=True)
|
||||
|
||||
@@ -126,16 +126,16 @@ class StockLot(models.Model):
|
||||
tool_material_search_id = fields.Many2one('sf.tool.material.search', string='刀具物料搜索')
|
||||
fixture_material_search_id = fields.Many2one('sf.fixture.material.search', string='夹具物料搜索')
|
||||
tool_material_status = fields.Selection(
|
||||
[('未入库', '未入库'), ('可用', '可用'), ('在用', '空闲'), ('报废', '报废')], string='状态',
|
||||
[('未入库', '未入库'), ('可用', '空闲'), ('在用', '占用'), ('报废', '报废')], string='状态',
|
||||
compute='_compute_tool_material_status', store=True)
|
||||
|
||||
@api.depends('quant_ids')
|
||||
def _compute_tool_material_status(self):
|
||||
for record in self:
|
||||
if record:
|
||||
if record.product_id.categ_id.name in ['刀具', '夹具']:
|
||||
if record.product_id.categ_id.name in ['刀具']:
|
||||
if record.quant_ids:
|
||||
if record.quant_ids[-1].location_id.name in ['刀具房', '夹具房']:
|
||||
if record.quant_ids[-1].location_id.name in ['刀具房']:
|
||||
record.tool_material_status = '可用'
|
||||
elif record.quant_ids[-1].location_id.name == '刀具组装位置':
|
||||
record.tool_material_status = '在用'
|
||||
|
||||
@@ -943,6 +943,8 @@ class SfStockPicking(models.Model):
|
||||
for record in self:
|
||||
if record.state != 'assigned':
|
||||
continue
|
||||
for move in record.move_ids:
|
||||
move.action_show_details()
|
||||
record.action_set_quantities_to_reservation()
|
||||
record.button_validate()
|
||||
|
||||
@@ -1122,7 +1124,7 @@ class SfPickingType(models.Model):
|
||||
if not self.env.user.has_group('base.group_system'):
|
||||
action['context']['create'] = False
|
||||
if self.sequence_code in ['DL', 'INT', 'PC']:
|
||||
action['context']['search_default_retrospect_ref'] = 1
|
||||
action['context']['search_default_retrospect'] = 1
|
||||
return action
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user