Compare commits
99 Commits
feature/20
...
feature/增加
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f07bbdeae | ||
|
|
2a7048dafd | ||
|
|
a2be3a0dbf | ||
|
|
1f4ceab377 | ||
|
|
94d727e8e0 | ||
|
|
42d9f894dd | ||
|
|
9416d1c1a0 | ||
|
|
7dd44ca12c | ||
|
|
5a98b20988 | ||
|
|
2738085a1e | ||
|
|
61c1fdbd05 | ||
|
|
7eea5a0ff2 | ||
|
|
714c68c0c1 | ||
|
|
f3e7ba7f68 | ||
|
|
df589b43e7 | ||
|
|
8bdc65c626 | ||
|
|
0c3407572f | ||
|
|
e5404efb60 | ||
|
|
46f60028aa | ||
|
|
bfc071debd | ||
|
|
7fca59322e | ||
|
|
42694c1ac6 | ||
|
|
e88fc012ec | ||
|
|
ff7cd9c927 | ||
|
|
588b7d340f | ||
|
|
5902d61f13 | ||
|
|
8cfad007b9 | ||
|
|
5008210176 | ||
|
|
f487ab4cce | ||
|
|
0441f345ef | ||
|
|
3527105e83 | ||
|
|
88e4cfb541 | ||
|
|
5a175c078f | ||
|
|
20980bed9d | ||
|
|
9b94357439 | ||
|
|
5ae3c5dd47 | ||
|
|
60be14dda2 | ||
|
|
f0ff7c4a74 | ||
|
|
2b6e2fe31b | ||
|
|
f1390e47c9 | ||
|
|
c7cd0a6a69 | ||
|
|
fa5307a2ea | ||
|
|
07e4cdcaa0 | ||
|
|
ff5925eb06 | ||
|
|
2a7e07b4c0 | ||
|
|
4706bfe85e | ||
|
|
2f21c510bd | ||
|
|
7adaa7e79b | ||
|
|
166d10e7d9 | ||
|
|
36d6a3ed4c | ||
|
|
650ff9b3e2 | ||
|
|
559c6bfb1d | ||
|
|
e83d3f8a1c | ||
|
|
ac0966f3bf | ||
|
|
1f93ba3b42 | ||
|
|
4d2ab82645 | ||
|
|
7b4499184d | ||
|
|
d02babaf0a | ||
|
|
acb6fd42ca | ||
|
|
c2cb24c60b | ||
|
|
3be1c4c529 | ||
|
|
60e7415a27 | ||
|
|
22763903a4 | ||
|
|
4c6cf0ba5e | ||
|
|
02012b2c52 | ||
|
|
a2b2efed7d | ||
|
|
925c59e1fe | ||
|
|
f86e27b45e | ||
|
|
b704f99a29 | ||
|
|
1ac6314f5f | ||
|
|
8b3eef1256 | ||
|
|
22ccb095ee | ||
|
|
9db4ea745b | ||
|
|
60fd4d4a73 | ||
|
|
c6c4331c0b | ||
|
|
10c6f59f52 | ||
|
|
df4995fa24 | ||
|
|
6e877d0449 | ||
|
|
3822d78f35 | ||
|
|
b23e50daa6 | ||
|
|
4615f1576f | ||
|
|
0350f78710 | ||
|
|
c8f1676de9 | ||
|
|
b267f2351d | ||
|
|
c31cc868a9 | ||
|
|
334d406c35 | ||
|
|
048f07aba4 | ||
|
|
c03cda8250 | ||
|
|
50a066c23a | ||
|
|
fe4659987f | ||
|
|
c14e2c19bf | ||
|
|
413cf43ea0 | ||
|
|
deda36a0f9 | ||
|
|
8a953a1417 | ||
|
|
d046fd5298 | ||
|
|
9f00fddc09 | ||
|
|
f41d3558d2 | ||
|
|
02b4f76326 | ||
|
|
2f26aee90a |
@@ -94,12 +94,20 @@ class PurchaseOrder(models.Model):
|
|||||||
|
|
||||||
def button_cancel(self):
|
def button_cancel(self):
|
||||||
"""
|
"""
|
||||||
将取消的采购订单关联的库存移动撤销
|
1. 先将采购订单行与目标库存移动断开链接,避免采购单取消后,调拨单被调整为mts的问题
|
||||||
|
2. 取消采购订单
|
||||||
|
3. 将采购订单行与目标库存移动重新建立链接
|
||||||
"""
|
"""
|
||||||
move_ids = self.order_line.move_dest_ids.filtered(lambda move: move.state != 'done' and not move.scrapped)
|
created_purchase_request_line_ids = {}
|
||||||
|
if self.order_line.move_dest_ids.created_purchase_request_line_id:
|
||||||
|
move_ids = self.order_line.move_dest_ids.filtered(lambda move: move.state != 'done' and not move.scrapped)
|
||||||
|
created_purchase_request_line_ids = {move.id: move.created_purchase_request_line_id for move in move_ids}
|
||||||
|
self.order_line.write({'move_dest_ids': [(5, 0, 0)]})
|
||||||
res =super(PurchaseOrder, self).button_cancel()
|
res =super(PurchaseOrder, self).button_cancel()
|
||||||
if move_ids.mapped('created_purchase_request_line_id'):
|
for move_id, created_purchase_request_line_id in created_purchase_request_line_ids.items():
|
||||||
move_ids.write({'state': 'waiting', 'is_done': False})
|
self.env['stock.move'].browse(move_id).created_purchase_request_line_id = created_purchase_request_line_id
|
||||||
|
# if move_ids.mapped('created_purchase_request_line_id'):
|
||||||
|
# move_ids.write({'state': 'waiting', 'is_done': False})
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class StatusChange(models.Model):
|
|||||||
else:
|
else:
|
||||||
action.update({
|
action.update({
|
||||||
'name': _("从 %s生成采购请求单", self.name),
|
'name': _("从 %s生成采购请求单", self.name),
|
||||||
'domain': [('id', 'in', pr_ids)],
|
'domain': [('id', 'in', pr_ids.ids)],
|
||||||
'view_mode': 'tree,form',
|
'view_mode': 'tree,form',
|
||||||
})
|
})
|
||||||
return action
|
return action
|
||||||
|
|||||||
@@ -41,8 +41,10 @@ class StockPicking(models.Model):
|
|||||||
if backorder_ids:
|
if backorder_ids:
|
||||||
purchase_request_lines = self.move_ids.move_orig_ids.purchase_line_id.purchase_request_lines
|
purchase_request_lines = self.move_ids.move_orig_ids.purchase_line_id.purchase_request_lines
|
||||||
if purchase_request_lines:
|
if purchase_request_lines:
|
||||||
purchase_request_lines.move_dest_ids = [
|
purchase_request_lines.move_dest_ids = [
|
||||||
(4, x.id) for x in backorder_ids.move_ids if x.product_id.id in purchase_request_lines.mapped('product_id.id')
|
(4, x.id) for x in backorder_ids.move_ids if
|
||||||
|
x.product_id.id in purchase_request_lines.mapped('product_id.id') and \
|
||||||
|
not x.created_purchase_request_line_id
|
||||||
]
|
]
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ class StockRule(models.Model):
|
|||||||
_inherit = 'stock.rule'
|
_inherit = 'stock.rule'
|
||||||
|
|
||||||
def _run_buy(self, procurements):
|
def _run_buy(self, procurements):
|
||||||
res = super(StockRule, self)._run_buy(procurements)
|
|
||||||
# 判断是否根据规则生成新的采购申请单据,如果生成则修改状态为 approved
|
# 判断是否根据规则生成新的采购申请单据,如果生成则修改状态为 approved
|
||||||
origins = list(set([procurement[0].origin for procurement in procurements]))
|
origins = list(set([procurement[0].origin for procurement in procurements]))
|
||||||
|
res = super(StockRule, self)._run_buy(procurements)
|
||||||
|
# origins = list(set([procurement[0].origin for procurement in procurements]))
|
||||||
for origin in origins:
|
for origin in origins:
|
||||||
pr_ids = self.env["purchase.request"].sudo().search(
|
pr_ids = self.env["purchase.request"].sudo().search(
|
||||||
[('origin', 'like', origin), ('rule_new_add', '=', True), ('state', '=', 'draft')])
|
[('origin', 'like', origin), ('rule_new_add', '=', True), ('state', '=', 'draft')])
|
||||||
|
|||||||
@@ -35,7 +35,6 @@
|
|||||||
],
|
],
|
||||||
'web.assets_backend': [
|
'web.assets_backend': [
|
||||||
'sf_base/static/src/scss/*.scss',
|
'sf_base/static/src/scss/*.scss',
|
||||||
'sf_base/static/src/js/*.js',
|
|
||||||
],
|
],
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
/** @odoo-module **/
|
|
||||||
|
|
||||||
import { registry } from "@web/core/registry";
|
|
||||||
import { barcodeGenericHandlers } from '@barcodes/barcode_handlers';
|
|
||||||
import { patch } from "@web/core/utils/patch";
|
|
||||||
|
|
||||||
// 定义新的 clickOnButton 函数
|
|
||||||
function customClickOnButton(selector) {
|
|
||||||
console.log("This is the custom clickOnButton function!");
|
|
||||||
|
|
||||||
const buttons = document.body.querySelectorAll(selector);
|
|
||||||
|
|
||||||
let length = buttons.length;
|
|
||||||
if (length > 0) {
|
|
||||||
buttons[length - 1].click();
|
|
||||||
} else {
|
|
||||||
console.warn(`Button with selector ${selector} not found`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
patch(barcodeGenericHandlers, "start", {
|
|
||||||
start(env, { ui, barcode, notification }) {
|
|
||||||
// 使用新定义的 clickOnButton 函数
|
|
||||||
const COMMANDS = {
|
|
||||||
"O-CMD.EDIT": () => customClickOnButton(".o_form_button_edit"),
|
|
||||||
"O-CMD.DISCARD": () => customClickOnButton(".o_form_button_cancel"),
|
|
||||||
"O-CMD.SAVE": () => customClickOnButton(".o_form_button_save"),
|
|
||||||
"O-CMD.PREV": () => customClickOnButton(".o_pager_previous"),
|
|
||||||
"O-CMD.NEXT": () => customClickOnButton(".o_pager_next"),
|
|
||||||
"O-CMD.PAGER-FIRST": () => updatePager("first"),
|
|
||||||
"O-CMD.PAGER-LAST": () => updatePager("last"),
|
|
||||||
"O-CMD.CONFIRM": () => customClickOnButton(".jikimo_button_confirm"),
|
|
||||||
"O-CMD.FLUSHED": () => customClickOnButton(".jikimo_button_flushed"),
|
|
||||||
};
|
|
||||||
|
|
||||||
barcode.bus.addEventListener("barcode_scanned", (ev) => {
|
|
||||||
const barcode = ev.detail.barcode;
|
|
||||||
if (barcode.startsWith("O-BTN.")) {
|
|
||||||
let targets = [];
|
|
||||||
try {
|
|
||||||
targets = getVisibleElements(ui.activeElement, `[barcode_trigger=${barcode.slice(6)}]`);
|
|
||||||
} catch (_e) {
|
|
||||||
console.warn(`Barcode '${barcode}' is not valid`);
|
|
||||||
}
|
|
||||||
for (let elem of targets) {
|
|
||||||
elem.click();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (barcode.startsWith("O-CMD.")) {
|
|
||||||
const fn = COMMANDS[barcode];
|
|
||||||
if (fn) {
|
|
||||||
fn();
|
|
||||||
} else {
|
|
||||||
notification.add(env._t("Barcode: ") + `'${barcode}'`, {
|
|
||||||
title: env._t("Unknown barcode command"),
|
|
||||||
type: "danger"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
/** @odoo-module **/
|
|
||||||
|
|
||||||
import { registry } from '@web/core/registry';
|
|
||||||
|
|
||||||
import { formView } from '@web/views/form/form_view';
|
|
||||||
import { FormController } from '@web/views/form/form_controller';
|
|
||||||
|
|
||||||
import { listView } from '@web/views/list/list_view';
|
|
||||||
import { ListController } from '@web/views/list/list_controller'
|
|
||||||
|
|
||||||
import { onRendered, onMounted } from "@odoo/owl";
|
|
||||||
|
|
||||||
export class RemoveFocusFormController extends FormController {
|
|
||||||
setup() {
|
|
||||||
super.setup();
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
this.__owl__.bdom.el.querySelectorAll(':focus').forEach(element => element.blur());
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
registry.category('views').add('remove_focus_form_view', {
|
|
||||||
...formView,
|
|
||||||
Controller: RemoveFocusFormController,
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
export class RemoveFocusListController extends ListController {
|
|
||||||
setup() {
|
|
||||||
super.setup();
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
this.__owl__.bdom.el.querySelectorAll(':focus').forEach(element => element.blur());
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
registry.category('views').add('remove_focus_list_view', {
|
|
||||||
...listView,
|
|
||||||
Controller: RemoveFocusListController,
|
|
||||||
});
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||||
{
|
{
|
||||||
'name': '机企猫智能工厂 需求计划',
|
'name': '机企猫智能工厂 需求计划',
|
||||||
'version': '1.0',
|
'version': '1.1',
|
||||||
'summary': '智能工厂计划管理',
|
'summary': '智能工厂计划管理',
|
||||||
'sequence': 1,
|
'sequence': 1,
|
||||||
'description': """
|
'description': """
|
||||||
@@ -10,18 +10,14 @@
|
|||||||
""",
|
""",
|
||||||
'category': 'sf',
|
'category': 'sf',
|
||||||
'website': 'https://www.sf.jikimo.com',
|
'website': 'https://www.sf.jikimo.com',
|
||||||
'depends': ['sf_plan'],
|
'depends': ['sf_plan','jikimo_printing'],
|
||||||
'data': [
|
'data': [
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
'data/stock_route_group.xml',
|
'data/stock_route_group.xml',
|
||||||
<<<<<<< HEAD
|
'views/demand_plan_info.xml',
|
||||||
'views/sale_order_views.xml',
|
|
||||||
'views/demand_plan.xml',
|
'views/demand_plan.xml',
|
||||||
'views/demand_main_plan.xml',
|
|
||||||
=======
|
|
||||||
'views/demand_plan.xml',
|
|
||||||
>>>>>>> develop
|
|
||||||
'views/stock_route.xml',
|
'views/stock_route.xml',
|
||||||
|
'views/sale_order_views.xml',
|
||||||
'wizard/sf_demand_plan_print_wizard_view.xml',
|
'wizard/sf_demand_plan_print_wizard_view.xml',
|
||||||
'wizard/sf_release_plan_wizard_views.xml',
|
'wizard/sf_release_plan_wizard_views.xml',
|
||||||
'views/menu_view.xml',
|
'views/menu_view.xml',
|
||||||
@@ -34,6 +30,7 @@
|
|||||||
'web.assets_backend': [
|
'web.assets_backend': [
|
||||||
'sf_demand_plan/static/src/scss/style.css',
|
'sf_demand_plan/static/src/scss/style.css',
|
||||||
'sf_demand_plan/static/src/js/print_demand.js',
|
'sf_demand_plan/static/src/js/print_demand.js',
|
||||||
|
'sf_demand_plan/static/src/js/custom_button.js',
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
'license': 'LGPL-3',
|
'license': 'LGPL-3',
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ from odoo import api, SUPERUSER_ID
|
|||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
#需求计划模块升级的时候,同步处理存量需求明细数据,关联上新加的需求计划主表
|
|
||||||
def migrate(cr, version):
|
def migrate(cr, version):
|
||||||
# 获取环境
|
# 获取环境
|
||||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||||
|
|
||||||
ProductionLine = env['sf.production.demand.plan']
|
ProductionLine = env['sf.production.demand.plan']
|
||||||
DemandPlan = env['sf.demand.main.plan']
|
DemandPlan = env['sf.demand.plan']
|
||||||
|
|
||||||
lines = ProductionLine.search([('demand_plan_id', '=', False)])
|
lines = ProductionLine.search([('demand_plan_id', '=', False)])
|
||||||
for line in lines:
|
for line in lines:
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from . import mrp_bom
|
|
||||||
from . import mrp_production
|
from . import sf_demand_plan
|
||||||
from . import sf_demand_main_plan
|
|
||||||
from . import sf_production_demand_plan
|
from . import sf_production_demand_plan
|
||||||
from . import sale_order
|
from . import sale_order
|
||||||
from . import stock_route
|
from . import stock_route
|
||||||
|
from . import mrp_bom
|
||||||
|
from . import mrp_production
|
||||||
from . import stock_rule
|
from . import stock_rule
|
||||||
from . import purchase_request
|
from . import purchase_request
|
||||||
from . import purchase_order
|
from . import purchase_order
|
||||||
|
|
||||||
|
|||||||
@@ -18,3 +18,12 @@ class MrpBom(models.Model):
|
|||||||
subcontract = self.get_supplier(product.materials_type_id)
|
subcontract = self.get_supplier(product.materials_type_id)
|
||||||
bom_id.subcontractor_id = subcontract.partner_id.id
|
bom_id.subcontractor_id = subcontract.partner_id.id
|
||||||
return bom_id
|
return bom_id
|
||||||
|
|
||||||
|
def name_get(self):
|
||||||
|
"""重写name_get方法,只显示BOM编码"""
|
||||||
|
result = []
|
||||||
|
for record in self:
|
||||||
|
# 只显示BOM编码,如果编码为空则显示产品名称
|
||||||
|
display_name = record.code or record.product_tmpl_id.name or f'BOM-{record.id}'
|
||||||
|
result.append((record.id, display_name))
|
||||||
|
return result
|
||||||
@@ -21,6 +21,23 @@ class MrpProduction(models.Model):
|
|||||||
production.production_type = None
|
production.production_type = None
|
||||||
|
|
||||||
def _get_purchase_request(self):
|
def _get_purchase_request(self):
|
||||||
"""获取跟制造订单相关的采购申请单"""
|
"""获取跟制造订单相关的采购申请单(根据采购申请单行项目的产品匹配)"""
|
||||||
pr_ids = self.env['purchase.request'].sudo().search([('origin', '=', self.name)])
|
pr_ids = self.env['purchase.request'].sudo().search(
|
||||||
|
[('line_ids.demand_plan_line_id', 'in', self.demand_plan_line_id.ids)])
|
||||||
return pr_ids
|
return pr_ids
|
||||||
|
|
||||||
|
@api.depends('procurement_group_id', 'procurement_group_id.stock_move_ids.group_id')
|
||||||
|
def _compute_picking_ids(self):
|
||||||
|
for order in self:
|
||||||
|
if order.product_id.product_tmpl_id.single_manufacturing == True and not order.is_remanufacture:
|
||||||
|
first_order = self.env['mrp.production'].search(
|
||||||
|
[('demand_plan_line_id', '=', order.demand_plan_line_id.id), ('product_id', '=', order.product_id.id)], limit=1, order='id asc')
|
||||||
|
order.picking_ids = self.env['stock.picking'].search([
|
||||||
|
('group_id', '=', first_order.procurement_group_id.id), ('group_id', '!=', False),
|
||||||
|
])
|
||||||
|
order.delivery_count = len(first_order.picking_ids)
|
||||||
|
else:
|
||||||
|
order.picking_ids = self.env['stock.picking'].search([
|
||||||
|
('group_id', '=', order.procurement_group_id.id), ('group_id', '!=', False),
|
||||||
|
])
|
||||||
|
order.delivery_count = len(order.picking_ids)
|
||||||
|
|||||||
@@ -5,18 +5,44 @@ from odoo.tools import float_compare
|
|||||||
class PurchaseOrder(models.Model):
|
class PurchaseOrder(models.Model):
|
||||||
_inherit = 'purchase.order'
|
_inherit = 'purchase.order'
|
||||||
|
|
||||||
demand_plan_line_id = fields.Many2one(comodel_name="sf.production.demand.plan",
|
def button_confirm(self):
|
||||||
string="需求计划明细", readonly=True)
|
if self.order_line[0].demand_plan_line_id:
|
||||||
|
self = self.with_context(
|
||||||
|
demand_plan_line_id=self.order_line[0].demand_plan_line_id.id
|
||||||
|
)
|
||||||
|
res = super(PurchaseOrder, self).button_confirm()
|
||||||
|
return res
|
||||||
|
|
||||||
@api.depends('origin', 'demand_plan_line_id')
|
@api.depends('origin')
|
||||||
def _compute_purchase_type(self):
|
def _compute_purchase_type(self):
|
||||||
for purchase in self:
|
for purchase in self:
|
||||||
if purchase.order_line[0].product_id.categ_id.name == '坯料':
|
if purchase.order_line[0].product_id.categ_id.name == '坯料':
|
||||||
if purchase.order_line[0].product_id.materials_type_id.gain_way == '外协':
|
if purchase.order_line[0].product_id.materials_type_id.gain_way == '外协':
|
||||||
purchase.purchase_type = 'outsourcing'
|
purchase.purchase_type = 'outsourcing'
|
||||||
else:
|
else:
|
||||||
if purchase.demand_plan_line_id.supply_method == 'outsourcing':
|
if purchase.order_line[0].demand_plan_line_id.supply_method == 'outsourcing':
|
||||||
purchase.purchase_type = 'outsourcing'
|
purchase.purchase_type = 'outsourcing'
|
||||||
|
|
||||||
elif purchase.demand_plan_line_id.supply_method == 'purchase':
|
elif purchase.order_line[0].demand_plan_line_id.supply_method == 'purchase':
|
||||||
purchase.purchase_type = 'outside'
|
purchase.purchase_type = 'outside'
|
||||||
|
|
||||||
|
|
||||||
|
class PurchaseOrderLine(models.Model):
|
||||||
|
_inherit = 'purchase.order.line'
|
||||||
|
|
||||||
|
demand_plan_line_id = fields.Many2one(comodel_name="sf.production.demand.plan",
|
||||||
|
string="需求计划明细", readonly=True)
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def create(self, vals):
|
||||||
|
res = super(PurchaseOrderLine, self).create(vals)
|
||||||
|
if not res.demand_plan_line_id and res.order_id.origin:
|
||||||
|
origin = [origin.replace(' ', '') for origin in res.order_id.origin.split(',')]
|
||||||
|
if self.env.context.get('demand_plan_line_id'):
|
||||||
|
res.demand_plan_line_id = self.env.context.get('demand_plan_line_id')
|
||||||
|
elif 'MO' in res.order_id.origin:
|
||||||
|
# 原单据是制造订单
|
||||||
|
mp_ids = self.env['mrp.production'].sudo().search([('name', 'in', origin)])
|
||||||
|
if mp_ids:
|
||||||
|
res.demand_plan_line_id = mp_ids[0].demand_plan_line_id.id
|
||||||
|
return res
|
||||||
|
|||||||
@@ -28,83 +28,8 @@ class PurchaseRequestLine(models.Model):
|
|||||||
class PurchaseRequestLineMakePurchaseOrder(models.TransientModel):
|
class PurchaseRequestLineMakePurchaseOrder(models.TransientModel):
|
||||||
_inherit = "purchase.request.line.make.purchase.order"
|
_inherit = "purchase.request.line.make.purchase.order"
|
||||||
|
|
||||||
def make_purchase_order(self):
|
@api.model
|
||||||
res = []
|
def _prepare_purchase_order_line(self, po, item):
|
||||||
purchase_obj = self.env["purchase.order"]
|
ret = super(PurchaseRequestLineMakePurchaseOrder, self)._prepare_purchase_order_line(po, item)
|
||||||
po_line_obj = self.env["purchase.order.line"]
|
ret['demand_plan_line_id'] = item.line_id.demand_plan_line_id.id
|
||||||
purchase = False
|
return ret
|
||||||
|
|
||||||
if len(set([item_id.line_id.supply_method for item_id in self.item_ids])) > 1:
|
|
||||||
raise ValidationError('不同供货方式不可合并创建询价单!')
|
|
||||||
|
|
||||||
for item in self.item_ids:
|
|
||||||
line = item.line_id
|
|
||||||
if item.product_qty <= 0.0:
|
|
||||||
raise UserError(_("Enter a positive quantity."))
|
|
||||||
if self.purchase_order_id:
|
|
||||||
purchase = self.purchase_order_id
|
|
||||||
if not purchase:
|
|
||||||
po_data = self._prepare_purchase_order(
|
|
||||||
line.request_id.picking_type_id,
|
|
||||||
line.request_id.group_id,
|
|
||||||
line.company_id,
|
|
||||||
line.request_id.origin,
|
|
||||||
)
|
|
||||||
po_data['demand_plan_line_id'] = item.line_id.demand_plan_line_id.id
|
|
||||||
# po_data.update({'related_product':line.related_product.id})
|
|
||||||
purchase = purchase_obj.create(po_data)
|
|
||||||
|
|
||||||
# Look for any other PO line in the selected PO with same
|
|
||||||
# product and UoM to sum quantities instead of creating a new
|
|
||||||
# po line
|
|
||||||
domain = self._get_order_line_search_domain(purchase, item)
|
|
||||||
available_po_lines = po_line_obj.search(domain)
|
|
||||||
new_pr_line = True
|
|
||||||
# If Unit of Measure is not set, update from wizard.
|
|
||||||
if not line.product_uom_id:
|
|
||||||
line.product_uom_id = item.product_uom_id
|
|
||||||
# Allocation UoM has to be the same as PR line UoM
|
|
||||||
alloc_uom = line.product_uom_id
|
|
||||||
wizard_uom = item.product_uom_id
|
|
||||||
if available_po_lines and not item.keep_description:
|
|
||||||
new_pr_line = False
|
|
||||||
po_line = available_po_lines[0]
|
|
||||||
po_line.purchase_request_lines = [(4, line.id)]
|
|
||||||
po_line.move_dest_ids |= line.move_dest_ids
|
|
||||||
po_line_product_uom_qty = po_line.product_uom._compute_quantity(
|
|
||||||
po_line.product_uom_qty, alloc_uom
|
|
||||||
)
|
|
||||||
wizard_product_uom_qty = wizard_uom._compute_quantity(
|
|
||||||
item.product_qty, alloc_uom
|
|
||||||
)
|
|
||||||
all_qty = min(po_line_product_uom_qty, wizard_product_uom_qty)
|
|
||||||
self.create_allocation(po_line, line, all_qty, alloc_uom)
|
|
||||||
else:
|
|
||||||
po_line_data = self._prepare_purchase_order_line(purchase, item)
|
|
||||||
if item.keep_description:
|
|
||||||
po_line_data["name"] = item.name
|
|
||||||
if line.related_product:
|
|
||||||
po_line_data.update({'related_product': line.related_product.id})
|
|
||||||
po_line = po_line_obj.create(po_line_data)
|
|
||||||
po_line_product_uom_qty = po_line.product_uom._compute_quantity(
|
|
||||||
po_line.product_uom_qty, alloc_uom
|
|
||||||
)
|
|
||||||
wizard_product_uom_qty = wizard_uom._compute_quantity(
|
|
||||||
item.product_qty, alloc_uom
|
|
||||||
)
|
|
||||||
all_qty = min(po_line_product_uom_qty, wizard_product_uom_qty)
|
|
||||||
self.create_allocation(po_line, line, all_qty, alloc_uom)
|
|
||||||
self._post_process_po_line(item, po_line, new_pr_line)
|
|
||||||
res.append(purchase.id)
|
|
||||||
|
|
||||||
purchase_requests = self.item_ids.mapped("request_id")
|
|
||||||
purchase_requests.button_in_progress()
|
|
||||||
return {
|
|
||||||
"domain": [("id", "in", res)],
|
|
||||||
"name": _("RFQ"),
|
|
||||||
"view_mode": "tree,form",
|
|
||||||
"res_model": "purchase.order",
|
|
||||||
"view_id": False,
|
|
||||||
"context": False,
|
|
||||||
"type": "ir.actions.act_window",
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -9,22 +9,24 @@ class ReSaleOrder(models.Model):
|
|||||||
compute='_compute_mrp_production_ids',
|
compute='_compute_mrp_production_ids',
|
||||||
string='与此销售订单相关联的制造订单',
|
string='与此销售订单相关联的制造订单',
|
||||||
groups='mrp.group_mrp_user', store=True)
|
groups='mrp.group_mrp_user', store=True)
|
||||||
demand_plan_ids = fields.Many2many(comodel_name="sf.demand.main.plan",
|
|
||||||
string="需求计划", readonly=True)
|
demand_plan_ids = fields.Many2many(comodel_name="sf.demand.plan",
|
||||||
|
string="需求计划", readonly=True)
|
||||||
|
|
||||||
demand_plan_count = fields.Integer(
|
demand_plan_count = fields.Integer(
|
||||||
"需求计划生成计数",
|
string="需求计划生成计数",
|
||||||
compute='_compute_demand_plan_count',
|
compute='_compute_demand_plan_count'
|
||||||
)
|
)
|
||||||
#暂时不知道哪里用到了
|
|
||||||
@api.depends('demand_plan_ids.line_ids.status')
|
@api.depends('demand_plan_ids.line_ids.status')
|
||||||
def _compute_purchase_request_count(self):
|
def _compute_purchase_request_count(self):
|
||||||
for record in self:
|
for so in self:
|
||||||
pr_ids = self.env['purchase.request'].sudo().search([('origin', 'like', record.name)])
|
pr_ids = self.env['purchase.request'].sudo().search([('origin', 'like', so.name)])
|
||||||
if pr_ids:
|
if pr_ids:
|
||||||
record.purchase_request_purchase_order_count = len(pr_ids)
|
so.purchase_request_purchase_order_count = len(pr_ids)
|
||||||
else:
|
else:
|
||||||
record.purchase_request_purchase_order_count = 0
|
so.purchase_request_purchase_order_count = 0
|
||||||
#计算需求计划生成计数
|
|
||||||
@api.depends('demand_plan_ids.line_ids')
|
@api.depends('demand_plan_ids.line_ids')
|
||||||
def _compute_demand_plan_count(self):
|
def _compute_demand_plan_count(self):
|
||||||
for line in self:
|
for line in self:
|
||||||
@@ -33,47 +35,33 @@ class ReSaleOrder(models.Model):
|
|||||||
|
|
||||||
def sale_order_create_line(self, product, item):
|
def sale_order_create_line(self, product, item):
|
||||||
ret = super(ReSaleOrder, self).sale_order_create_line(product, item)
|
ret = super(ReSaleOrder, self).sale_order_create_line(product, item)
|
||||||
# vals = {
|
vals = {
|
||||||
# 'sale_order_id': ret.order_id.id,
|
'sale_order_id': ret.order_id.id,
|
||||||
# 'sale_order_line_id': ret.id,
|
'sale_order_line_id': ret.id,
|
||||||
# }
|
}
|
||||||
# demand_plan_info = self.env['sf.demand.main.plan'].sudo().create(vals)
|
demand_plan_info = self.env['sf.demand.plan'].sudo().create(vals)
|
||||||
# vals.update({'demand_plan_id': demand_plan_info.id, 'plan_uom_qty': ret.product_uom_qty})
|
vals.update({'demand_plan_id': demand_plan_info.id, 'plan_uom_qty': ret.product_uom_qty,
|
||||||
# demand_plan = self.env['sf.production.demand.plan'].sudo().create(vals)
|
'new_supply_method': 'custom_made', 'custom_made_type': 'manual'})
|
||||||
# demand_plan_info.write({'line_ids': demand_plan.ids})
|
demand_plan = self.env['sf.production.demand.plan'].sudo().create(vals)
|
||||||
# 优化方案1:使用事务确保数据一致性
|
demand_plan_info.write({'line_ids': demand_plan.ids})
|
||||||
with self.env.cr.savepoint():
|
|
||||||
# 1. 先创建主计划
|
|
||||||
demand_plan_info = self.env['sf.demand.main.plan'].sudo().create({
|
|
||||||
'sale_order_id': ret.order_id.id,
|
|
||||||
'sale_order_line_id': ret.id,
|
|
||||||
})
|
|
||||||
# 2. 创建明细计划时直接建立关联(利用One2many的inverse特性)
|
|
||||||
demand_plan = self.env['sf.production.demand.plan'].sudo().create({
|
|
||||||
'demand_plan_id': demand_plan_info.id,
|
|
||||||
'plan_uom_qty': ret.product_uom_qty,
|
|
||||||
'sale_order_id': ret.order_id.id,
|
|
||||||
'sale_order_line_id': ret.id,
|
|
||||||
})
|
|
||||||
# 3. 不需要手动更新line_ids,Odoo的ORM会自动处理One2many关系
|
|
||||||
if demand_plan.product_id.machining_drawings_name:
|
if demand_plan.product_id.machining_drawings_name:
|
||||||
filename_url = demand_plan.product_id.machining_drawings_name.rsplit('.', 1)[0]
|
filename_url = demand_plan.product_id.machining_drawings_name.rsplit('.', 1)[0]
|
||||||
wizard_vals = {
|
wizard_vals = {
|
||||||
'demand_plan_id': demand_plan.id,
|
|
||||||
'model_id': demand_plan.model_id,
|
'model_id': demand_plan.model_id,
|
||||||
'filename_url': filename_url,
|
'filename_url': filename_url,
|
||||||
|
'machining_drawings': product.machining_drawings,
|
||||||
'type': '1',
|
'type': '1',
|
||||||
}
|
}
|
||||||
self.env['sf.demand.plan.print.wizard'].sudo().create(wizard_vals)
|
self.env['sf.demand.plan.print.wizard'].sudo().create(wizard_vals)
|
||||||
ret.order_id.demand_plan_ids = [(4, demand_plan_info.id)]
|
ret.order_id.demand_plan_ids = [(4, demand_plan_info.id)]
|
||||||
return ret
|
return ret
|
||||||
#从sf工厂调过来时,调用了,这里重写
|
|
||||||
def confirm_to_supply_method(self):
|
def confirm_to_supply_method(self):
|
||||||
self.state = 'sale'
|
self.state = 'sale'
|
||||||
for line in self.order_line:
|
for line in self.order_line:
|
||||||
if line.product_id.auto_machining:
|
if line.product_id.auto_machining:
|
||||||
line.supply_method = 'automation'
|
line.supply_method = 'automation'
|
||||||
#在销售订单打开需求计划列表
|
|
||||||
def action_view_demand_plan(self):
|
def action_view_demand_plan(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
demand_plan_ids = self.env['sf.production.demand.plan'].sudo().search([('sale_order_id', '=', self.id)]).ids
|
demand_plan_ids = self.env['sf.production.demand.plan'].sudo().search([('sale_order_id', '=', self.id)]).ids
|
||||||
@@ -84,4 +72,3 @@ class ReSaleOrder(models.Model):
|
|||||||
'domain': [('id', 'in', demand_plan_ids)],
|
'domain': [('id', 'in', demand_plan_ids)],
|
||||||
'view_mode': 'tree',
|
'view_mode': 'tree',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,20 +3,15 @@
|
|||||||
from odoo import models, fields, api, _
|
from odoo import models, fields, api, _
|
||||||
from odoo.tools import float_compare
|
from odoo.tools import float_compare
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
class SfDemandMainPlan(models.Model):
|
class SfDemandPlan(models.Model):
|
||||||
_name = 'sf.demand.main.plan'
|
_name = 'sf.demand.plan'
|
||||||
_description = 'sf_demand_main_plan'
|
_description = 'sf_demand_plan'
|
||||||
|
|
||||||
def _get_machining_precision(self):
|
|
||||||
machinings = self.env['sf.machining.accuracy'].sudo().search([])
|
|
||||||
list = [(m.sync_id, m.name) for m in machinings]
|
|
||||||
return list
|
|
||||||
|
|
||||||
state = fields.Selection([
|
state = fields.Selection([
|
||||||
('10', '需求确认'),
|
('10', '待工艺设计'),
|
||||||
('20', '待工艺设计'),
|
|
||||||
('30', '部分下达'),
|
('30', '部分下达'),
|
||||||
('40', '已下达'),
|
('40', '已下达'),
|
||||||
('50', '取消'),
|
('50', '取消'),
|
||||||
@@ -41,6 +36,9 @@ class SfDemandMainPlan(models.Model):
|
|||||||
|
|
||||||
blank_type = fields.Selection([('圆料', '圆料'), ('方料', '方料')], string='坯料分类',
|
blank_type = fields.Selection([('圆料', '圆料'), ('方料', '方料')], string='坯料分类',
|
||||||
related='product_id.blank_type')
|
related='product_id.blank_type')
|
||||||
|
blank_precision = fields.Selection([('精坯', '精坯'), ('粗坯', '粗坯')], string='坯料类型',
|
||||||
|
related='product_id.blank_precision')
|
||||||
|
manual_quotation = fields.Boolean('人工编程', related='product_id.manual_quotation', default=False)
|
||||||
embryo_long = fields.Char('坯料尺寸(mm)', compute='_compute_embryo_long', store=True)
|
embryo_long = fields.Char('坯料尺寸(mm)', compute='_compute_embryo_long', store=True)
|
||||||
is_incoming_material = fields.Boolean('客供料', related='sale_order_line_id.is_incoming_material', store=True)
|
is_incoming_material = fields.Boolean('客供料', related='sale_order_line_id.is_incoming_material', store=True)
|
||||||
pending_qty = fields.Float(
|
pending_qty = fields.Float(
|
||||||
@@ -64,12 +62,10 @@ class SfDemandMainPlan(models.Model):
|
|||||||
compute='_compute_model_process_parameters_ids'
|
compute='_compute_model_process_parameters_ids'
|
||||||
, store=True
|
, store=True
|
||||||
)
|
)
|
||||||
model_machining_precision = fields.Selection(selection=_get_machining_precision, string='精度',
|
model_machining_precision = fields.Selection(related='product_id.model_machining_precision', string='精度')
|
||||||
related='product_id.model_machining_precision')
|
|
||||||
|
|
||||||
inventory_quantity_auto_apply = fields.Float(
|
inventory_quantity_auto_apply = fields.Float(
|
||||||
string="成品库存",
|
string="成品库存",
|
||||||
compute='_compute_inventory_quantity_auto_apply', store=True
|
compute='_compute_inventory_quantity_auto_apply'
|
||||||
)
|
)
|
||||||
|
|
||||||
priority = fields.Selection([
|
priority = fields.Selection([
|
||||||
@@ -79,12 +75,22 @@ class SfDemandMainPlan(models.Model):
|
|||||||
('4', '低'),
|
('4', '低'),
|
||||||
], string='优先级', default='3')
|
], string='优先级', default='3')
|
||||||
|
|
||||||
|
overdelivery_allowed = fields.Boolean('可超量发货', default=False)
|
||||||
|
|
||||||
hide_button_release_plan = fields.Boolean(
|
hide_button_release_plan = fields.Boolean(
|
||||||
string='显示下达计划按钮',
|
string='显示下达计划按钮',
|
||||||
compute='_compute_hide_button_release_plan',
|
compute='_compute_hide_button_release_plan',
|
||||||
default=False
|
default=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
readonly_custom_made_type = fields.Boolean(
|
||||||
|
string='字段自制类型只读',
|
||||||
|
compute='_compute_readonly_custom_made_type',
|
||||||
|
default=False
|
||||||
|
)
|
||||||
|
demand_plan_number = fields.Char('需求计划号', compute='_compute_demand_plan_number', readonly=True, store=True)
|
||||||
|
origin = fields.Char('来源', related='sale_order_id.name', readonly=True, store=True)
|
||||||
|
|
||||||
@api.depends('product_id.part_number', 'product_id.model_name')
|
@api.depends('product_id.part_number', 'product_id.model_name')
|
||||||
def _compute_part_number(self):
|
def _compute_part_number(self):
|
||||||
for line in self:
|
for line in self:
|
||||||
@@ -109,7 +115,10 @@ class SfDemandMainPlan(models.Model):
|
|||||||
def _compute_embryo_long(self):
|
def _compute_embryo_long(self):
|
||||||
for line in self:
|
for line in self:
|
||||||
if line.product_id:
|
if line.product_id:
|
||||||
line.embryo_long = f"{round(line.product_id.model_long, 3)}*{round(line.product_id.model_width, 3)}*{round(line.product_id.model_height, 3)}"
|
if line.product_id.blank_type == '圆料':
|
||||||
|
line.embryo_long = f"Ø{round(line.product_id.model_width, 3)}*{round(line.product_id.model_long, 3)}"
|
||||||
|
else:
|
||||||
|
line.embryo_long = f"{round(line.product_id.model_long, 3)}*{round(line.product_id.model_width, 3)}*{round(line.product_id.model_height, 3)}"
|
||||||
else:
|
else:
|
||||||
line.embryo_long = None
|
line.embryo_long = None
|
||||||
|
|
||||||
@@ -147,12 +156,8 @@ class SfDemandMainPlan(models.Model):
|
|||||||
for line in self:
|
for line in self:
|
||||||
sum_plan_uom_qty = sum(line.line_ids.mapped('plan_uom_qty'))
|
sum_plan_uom_qty = sum(line.line_ids.mapped('plan_uom_qty'))
|
||||||
pending_qty = line.product_uom_qty - sum_plan_uom_qty
|
pending_qty = line.product_uom_qty - sum_plan_uom_qty
|
||||||
rounding = line.product_id.uom_id.rounding or 0.01#设置默认精度
|
if float_compare(pending_qty, 0,
|
||||||
# 如果精度小于等于0,则设置为0.01
|
precision_rounding=line.product_id.uom_id.rounding) == -1:
|
||||||
if rounding<=0:
|
|
||||||
rounding = 0.01
|
|
||||||
# 如果计划量小于等于0,则设置为0
|
|
||||||
if float_compare(pending_qty, 0, precision_rounding=rounding) == -1:
|
|
||||||
line.pending_qty = 0
|
line.pending_qty = 0
|
||||||
else:
|
else:
|
||||||
line.pending_qty = pending_qty
|
line.pending_qty = pending_qty
|
||||||
@@ -165,32 +170,40 @@ class SfDemandMainPlan(models.Model):
|
|||||||
@api.depends('line_ids.status')
|
@api.depends('line_ids.status')
|
||||||
def _compute_hide_button_release_plan(self):
|
def _compute_hide_button_release_plan(self):
|
||||||
for line in self:
|
for line in self:
|
||||||
line.hide_button_release_plan = bool(line.line_ids.filtered(lambda p: p.status != '60'))
|
line.hide_button_release_plan = bool(line.line_ids.filtered(
|
||||||
|
lambda p: p.status == '30'))
|
||||||
def button_release_plan(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@api.depends('line_ids.status', 'sale_order_id.state')
|
@api.depends('line_ids.status', 'sale_order_id.state')
|
||||||
def _compute_state(self):
|
def _compute_state(self):
|
||||||
for line in self:
|
for line in self:
|
||||||
#已下达的订单
|
|
||||||
status_line = line.line_ids.filtered(lambda p: p.status == '60')
|
status_line = line.line_ids.filtered(lambda p: p.status == '60')
|
||||||
if line.sale_order_id.state == 'cancel':
|
if not line.line_ids:
|
||||||
|
line.state = '10'
|
||||||
|
elif line.sale_order_id.state == 'cancel':
|
||||||
line.state = '50'
|
line.state = '50'
|
||||||
line.line_ids.status = '100'
|
line.line_ids.status = '100'
|
||||||
elif len(line.line_ids) == len(status_line):
|
elif len(line.line_ids) == len(status_line):
|
||||||
line.state = '40'
|
line.state = '40'
|
||||||
#排除上面全部下达的情形后,如果有已下达订单,则状态为部分
|
|
||||||
elif bool(status_line):
|
elif bool(status_line):
|
||||||
line.state = '30'
|
line.state = '30'
|
||||||
else:
|
else:
|
||||||
line.state = '10'
|
line.state = '10'
|
||||||
|
|
||||||
|
@api.depends('line_ids.status')
|
||||||
|
def _compute_readonly_custom_made_type(self):
|
||||||
|
for line in self:
|
||||||
|
production_demand_plan = line.line_ids.filtered(
|
||||||
|
lambda p: p.status in ('50', '60') and p.new_supply_method == 'custom_made')
|
||||||
|
line.readonly_custom_made_type = bool(production_demand_plan)
|
||||||
|
|
||||||
|
@api.constrains('line_ids')
|
||||||
|
def check_line_ids(self):
|
||||||
|
for item in self:
|
||||||
|
if not item.line_ids:
|
||||||
|
raise ValidationError('计划不能为空!')
|
||||||
|
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
res = super(SfDemandMainPlan, self).write(vals)
|
res = super(SfDemandPlan, self).write(vals)
|
||||||
line_ids = self.line_ids.filtered(lambda p: p.plan_uom_qty == 0 or p.plan_uom_qty < 0)
|
|
||||||
if line_ids:
|
|
||||||
raise ValidationError(f"计划量不能小于等于0")
|
|
||||||
if 'line_ids' in vals:
|
if 'line_ids' in vals:
|
||||||
for line in self.line_ids:
|
for line in self.line_ids:
|
||||||
if not line.sale_order_id:
|
if not line.sale_order_id:
|
||||||
@@ -202,5 +215,51 @@ class SfDemandMainPlan(models.Model):
|
|||||||
def name_get(self):
|
def name_get(self):
|
||||||
result = []
|
result = []
|
||||||
for plan in self:
|
for plan in self:
|
||||||
result.append((plan.id, plan.sale_order_id.name))
|
result.append((plan.id, plan.demand_plan_number))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def button_production_release_plan(self):
|
||||||
|
line_ids = self.line_ids.filtered(lambda p: p.status == '30')
|
||||||
|
sum_product_uom_qty = sum(line_ids.mapped('plan_uom_qty'))
|
||||||
|
customer_location_id = self.env['ir.model.data']._xmlid_to_res_id('stock.stock_location_customers')
|
||||||
|
check_overdelivery_allowed = False
|
||||||
|
for line in line_ids:
|
||||||
|
if line.location_id.id == customer_location_id:
|
||||||
|
if not self.overdelivery_allowed:
|
||||||
|
if float_compare(sum_product_uom_qty, self.product_uom_qty,
|
||||||
|
precision_rounding=line.product_id.uom_id.rounding) == 1:
|
||||||
|
check_overdelivery_allowed = True
|
||||||
|
if check_overdelivery_allowed:
|
||||||
|
raise ValidationError(f"已禁止向合作伙伴/客户超量发货,请更换“补货原因”或将“可超量发货”设置为“是”。")
|
||||||
|
elif float_compare(sum_product_uom_qty, self.product_uom_qty,
|
||||||
|
precision_rounding=self.product_id.uom_id.rounding) == 1:
|
||||||
|
return {
|
||||||
|
'name': _('需求计划'),
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'views': [(self.env.ref(
|
||||||
|
'sf_demand_plan.sf_release_plan_wizard_form').id,
|
||||||
|
'form')],
|
||||||
|
'res_model': 'sf.release.plan.wizard',
|
||||||
|
'target': 'new',
|
||||||
|
'context': {
|
||||||
|
'default_demand_plan_line_id': line_ids.ids,
|
||||||
|
'default_release_message': f"您正在下达计划量 {sum_product_uom_qty},需求数量为 {self.product_uom_qty},已超过需求数量,是否继续?",
|
||||||
|
}}
|
||||||
|
else:
|
||||||
|
for demand_plan_line_id in line_ids:
|
||||||
|
demand_plan_line_id.action_confirm()
|
||||||
|
|
||||||
|
# 需求要求取值格式是来源+来源明细行ID,但是来源明细行ID取得就是product_id.name得最后一位,所以这里也直接截取product_id.name
|
||||||
|
@api.depends('product_id.name')
|
||||||
|
def _compute_demand_plan_number(self):
|
||||||
|
for line in self:
|
||||||
|
product_name = line.product_id.name or ''
|
||||||
|
plan_no = None
|
||||||
|
if line.product_id:
|
||||||
|
# 使用正则表达式匹配P-后面的所有字符
|
||||||
|
match = re.search(r'P-(.*)', product_name)
|
||||||
|
if match:
|
||||||
|
plan_no = match.group(1)
|
||||||
|
line.demand_plan_number = plan_no
|
||||||
|
else:
|
||||||
|
line.demand_plan_number = None
|
||||||
@@ -12,54 +12,29 @@ import re
|
|||||||
class SfProductionDemandPlan(models.Model):
|
class SfProductionDemandPlan(models.Model):
|
||||||
_name = 'sf.production.demand.plan'
|
_name = 'sf.production.demand.plan'
|
||||||
_description = 'sf_production_demand_plan'
|
_description = 'sf_production_demand_plan'
|
||||||
|
|
||||||
def get_location_id(self):
|
def get_location_id(self):
|
||||||
stock_location = self.env['stock.location'].sudo().search([('name', '=', '客户')], limit=1)
|
customer_location_id = self.env['ir.model.data']._xmlid_to_res_id('stock.stock_location_customers')
|
||||||
return stock_location.id
|
return customer_location_id
|
||||||
|
|
||||||
def _get_machining_precision(self):
|
|
||||||
machinings = self.env['sf.machining.accuracy'].sudo().search([])
|
|
||||||
list = [(m.sync_id, m.name) for m in machinings]
|
|
||||||
return list
|
|
||||||
demand_plan_id = fields.Many2one(comodel_name="sf.demand.main.plan",
|
|
||||||
string="物料需求", readonly=True)
|
|
||||||
priority = fields.Selection([
|
|
||||||
('1', '紧急'),
|
|
||||||
('2', '高'),
|
|
||||||
('3', '中'),
|
|
||||||
('4', '低'),
|
|
||||||
], string='优先级', related='demand_plan_id.priority')
|
|
||||||
|
|
||||||
|
priority = fields.Selection(related='demand_plan_id.priority', string='优先级', store=True)
|
||||||
status = fields.Selection([
|
status = fields.Selection([
|
||||||
('10', '草稿'),
|
('10', '草稿'),
|
||||||
('20', '待确认'),
|
('20', '待确认'),
|
||||||
('30', '需求确认'),
|
('30', '待工艺设计'),
|
||||||
('50', '待下达生产'),
|
('50', '待下达生产'),
|
||||||
('60', '已下达'),
|
('60', '已下达'),
|
||||||
('100', '取消'),
|
('100', '取消'),
|
||||||
], string='状态', default='30', readonly=True)
|
], string='状态', default='30', readonly=True)
|
||||||
|
demand_plan_id = fields.Many2one(comodel_name="sf.demand.plan",
|
||||||
plan_uom_qty = fields.Float(string="计划量")
|
string="物料需求", readonly=True)
|
||||||
procurement_reason = fields.Selection([
|
sale_order_id = fields.Many2one(comodel_name="sale.order", string="销售订单", readonly=True)
|
||||||
('销售订单', "销售订单"),
|
sale_order_line_id = fields.Many2one(comodel_name="sale.order.line", string="销售订单明细", readonly=True)
|
||||||
('需求预测', "需求预测"),
|
|
||||||
('生产报废', "生产报废"),
|
|
||||||
], string='补货原因', default='销售订单')
|
|
||||||
|
|
||||||
blank_arrival_date = fields.Date('采购计划到货(坯料)')
|
|
||||||
finished_product_arrival_date = fields.Date('采购计划到货(成品)')
|
|
||||||
bom_id = fields.Many2one('mrp.bom', string="BOM", readonly=True)
|
|
||||||
location_id = fields.Many2one('stock.location', string='需求位置', default=get_location_id, readonly=True)
|
|
||||||
|
|
||||||
|
|
||||||
sale_order_id = fields.Many2one(comodel_name="sale.order",
|
|
||||||
string="销售订单", readonly=True)
|
|
||||||
sale_order_line_id = fields.Many2one(comodel_name="sale.order.line",
|
|
||||||
string="销售订单明细", readonly=True)
|
|
||||||
sale_order_line_number = fields.Char(string='销售订单行', compute='_compute_sale_order_line_number', store=True)
|
sale_order_line_number = fields.Char(string='销售订单行', compute='_compute_sale_order_line_number', store=True)
|
||||||
company_id = fields.Many2one(
|
company_id = fields.Many2one(
|
||||||
related='sale_order_id.company_id',
|
related='sale_order_id.company_id',
|
||||||
store=True, index=True, precompute=True)
|
store=True, index=True, precompute=True)
|
||||||
customer_name = fields.Char('客户', related='sale_order_id.customer_name')
|
customer_name = fields.Char('客户', related='sale_order_id.customer_name', store=True)
|
||||||
order_remark = fields.Text(related='sale_order_id.remark',
|
order_remark = fields.Text(related='sale_order_id.remark',
|
||||||
string="订单备注", store=True)
|
string="订单备注", store=True)
|
||||||
glb_url = fields.Char(related='sale_order_line_id.glb_url', string='glb文件地址')
|
glb_url = fields.Char(related='sale_order_line_id.glb_url', string='glb文件地址')
|
||||||
@@ -70,14 +45,25 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
model_id = fields.Char('模型ID', related='product_id.model_id')
|
model_id = fields.Char('模型ID', related='product_id.model_id')
|
||||||
part_name = fields.Char('零件名称', related='product_id.part_name')
|
part_name = fields.Char('零件名称', related='product_id.part_name')
|
||||||
part_number = fields.Char('零件图号', related='demand_plan_id.part_number')
|
part_number = fields.Char('零件图号', related='demand_plan_id.part_number')
|
||||||
#part_number = fields.Char('零件图号', compute='_compute_part_number', store=True)
|
|
||||||
is_incoming_material = fields.Boolean('客供料', related='sale_order_line_id.is_incoming_material', store=True)
|
is_incoming_material = fields.Boolean('客供料', related='sale_order_line_id.is_incoming_material', store=True)
|
||||||
|
|
||||||
|
new_supply_method = fields.Selection([
|
||||||
|
('custom_made', "自制"),
|
||||||
|
('purchase', "外购"),
|
||||||
|
('outsourcing', "委外加工"),
|
||||||
|
], string='供货方式', required=True)
|
||||||
|
|
||||||
|
custom_made_type = fields.Selection([
|
||||||
|
('automation', "自动化产线加工"),
|
||||||
|
('manual', "人工线下加工"),
|
||||||
|
], string='产线类型', compute='_compute_custom_made_type', store=True)
|
||||||
|
|
||||||
supply_method = fields.Selection([
|
supply_method = fields.Selection([
|
||||||
('automation', "自动化产线加工"),
|
('automation', "自动化产线加工"),
|
||||||
('manual', "人工线下加工"),
|
('manual', "人工线下加工"),
|
||||||
('purchase', "外购"),
|
('purchase', "外购"),
|
||||||
('outsourcing', "委外加工"),
|
('outsourcing', "委外加工"),
|
||||||
], string='供货方式', default='manual')
|
], string='供货方式', compute='_compute_supply_method', store=True, readonly=True)
|
||||||
product_uom_qty = fields.Float(
|
product_uom_qty = fields.Float(
|
||||||
string="需求数量",
|
string="需求数量",
|
||||||
related='sale_order_line_id.product_uom_qty', store=True)
|
related='sale_order_line_id.product_uom_qty', store=True)
|
||||||
@@ -85,56 +71,30 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
inventory_quantity_auto_apply = fields.Float(
|
inventory_quantity_auto_apply = fields.Float(
|
||||||
string="成品库存",
|
string="成品库存",
|
||||||
related='demand_plan_id.inventory_quantity_auto_apply'
|
related='demand_plan_id.inventory_quantity_auto_apply'
|
||||||
#compute='_compute_inventory_quantity_auto_apply'
|
|
||||||
)
|
)
|
||||||
qty_delivered = fields.Float(
|
qty_delivered = fields.Float(
|
||||||
"交货数量", related='sale_order_line_id.qty_delivered')
|
"交货数量", related='sale_order_line_id.qty_delivered')
|
||||||
qty_to_deliver = fields.Float(
|
qty_to_deliver = fields.Float(
|
||||||
"待交货数量", related='sale_order_line_id.qty_to_deliver')
|
"待交货数量", compute='_compute_qty_to_deliver', store=True)
|
||||||
model_long = fields.Char('尺寸(mm)', compute='_compute_model_long')
|
model_long = fields.Char('尺寸(mm)', compute='_compute_model_long')
|
||||||
blank_type = fields.Selection([('圆料', '圆料'), ('方料', '方料')], string='坯料分类',
|
blank_type = fields.Selection([('圆料', '圆料'), ('方料', '方料')], string='坯料分类',
|
||||||
related='product_id.blank_type')
|
related='product_id.blank_type')
|
||||||
<<<<<<< HEAD
|
blank_precision = fields.Selection([('精坯', '精坯'), ('粗坯', '粗坯')], string='坯料类型',
|
||||||
#blank_precision = fields.Selection([('精坯', '精坯'), ('粗坯', '粗坯')], string='坯料类型', related='product_id.blank_precision')
|
related='product_id.blank_precision')
|
||||||
#materials_id = fields.Char('材料', compute='_compute_materials_id', store=True)
|
unit_number = fields.Float('单件用量', digits=(16, 3), related='product_id.unit_number')
|
||||||
embryo_long = fields.Char('坯料尺寸(mm)', related='demand_plan_id.embryo_long')
|
embryo_long = fields.Char('坯料尺寸(mm)', related='demand_plan_id.embryo_long')
|
||||||
materials_id = fields.Char('材料', related='demand_plan_id.materials_id')
|
materials_id = fields.Char('材料', related='demand_plan_id.materials_id', store=True)
|
||||||
|
model_machining_precision = fields.Selection(related='product_id.model_machining_precision', string='精度')
|
||||||
=======
|
|
||||||
blank_precision = fields.Selection([('精坯', '精坯'), ('粗坯', '粗坯')], string='坯料类型', related='product_id.blank_precision')
|
|
||||||
embryo_long = fields.Char('坯料尺寸(mm)', compute='_compute_embryo_long')
|
|
||||||
materials_id = fields.Char('材料', compute='_compute_materials_id', store=True)
|
|
||||||
>>>>>>> develop
|
|
||||||
model_machining_precision = fields.Selection(selection=_get_machining_precision, string='精度',
|
|
||||||
related='product_id.model_machining_precision')
|
|
||||||
#model_process_parameters_ids = fields.Many2many('sf.production.process.parameter',
|
|
||||||
# 'plan_process_parameter_rel',
|
|
||||||
# string='表面工艺',
|
|
||||||
# compute='_compute_model_process_parameters_ids'
|
|
||||||
# , store=True
|
|
||||||
# )
|
|
||||||
model_process_parameters_ids = fields.Many2many(related='demand_plan_id.model_process_parameters_ids',
|
model_process_parameters_ids = fields.Many2many(related='demand_plan_id.model_process_parameters_ids',
|
||||||
string='表面工艺', )
|
string='表面工艺', )
|
||||||
|
|
||||||
product_remark = fields.Char("产品备注", related='product_id.model_remark')
|
product_remark = fields.Char("产品备注", related='product_id.model_remark')
|
||||||
order_code = fields.Char('E-SHOP订单号', related='sale_order_id.order_code')
|
order_code = fields.Char('E-SHOP订单号', related='sale_order_id.order_code')
|
||||||
<<<<<<< HEAD
|
|
||||||
order_state = fields.Selection( string='订单状态',related='sale_order_line_id.state')
|
|
||||||
|
|
||||||
#route_id = fields.Many2one('stock.route', string='路线', related='sale_order_line_id.route_id', store=True)
|
|
||||||
route_ids = fields.Many2many('stock.route', 'stock_route_demand_plan', 'demand_plan_id', 'route_id', '库存路线',
|
|
||||||
domain=[('demand_plan_selectable', '=', True)], compute='_compute_route_ids',
|
|
||||||
store=True)
|
|
||||||
|
|
||||||
=======
|
|
||||||
order_state = fields.Selection(
|
order_state = fields.Selection(
|
||||||
string='订单状态',
|
string='订单状态',
|
||||||
related='sale_order_line_id.state')
|
related='sale_order_line_id.state')
|
||||||
route_id = fields.Many2one('stock.route', string='路线', related='sale_order_line_id.route_id', store=True)
|
route_ids = fields.Many2many('stock.route', 'stock_route_demand_plan', 'demand_plan_id', 'route_id', '库存路线',
|
||||||
route_ids = fields.Many2many('stock.route', 'stock_route_demand_plan', 'demand_plan_id', 'route_id', '路线',
|
|
||||||
domain=[('demand_plan_selectable', '=', True)], compute='_compute_route_ids',
|
domain=[('demand_plan_selectable', '=', True)], compute='_compute_route_ids',
|
||||||
store=True)
|
store=True)
|
||||||
>>>>>>> develop
|
|
||||||
contract_date = fields.Date('合同日期', related='sale_order_id.contract_date')
|
contract_date = fields.Date('合同日期', related='sale_order_id.contract_date')
|
||||||
date_order = fields.Datetime('下单日期', related='sale_order_id.date_order')
|
date_order = fields.Datetime('下单日期', related='sale_order_id.date_order')
|
||||||
contract_code = fields.Char('合同号', related='sale_order_id.contract_code', store=True)
|
contract_code = fields.Char('合同号', related='sale_order_id.contract_code', store=True)
|
||||||
@@ -155,12 +115,24 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
compute='_compute_mrp_production_ids',
|
compute='_compute_mrp_production_ids',
|
||||||
string='与此相需求计划关联的制造订单',
|
string='与此相需求计划关联的制造订单',
|
||||||
store=True)
|
store=True)
|
||||||
|
|
||||||
hide_release_production_order = fields.Boolean(
|
hide_release_production_order = fields.Boolean(
|
||||||
string='显示下发生产按钮',
|
string='显示下发生产按钮',
|
||||||
compute='_compute_hide_release_production_order',
|
compute='_compute_hide_release_production_order',
|
||||||
default=False
|
default=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
readonly_custom_made_type = fields.Boolean(
|
||||||
|
related='demand_plan_id.readonly_custom_made_type',
|
||||||
|
string='字段自制类型只读'
|
||||||
|
)
|
||||||
|
|
||||||
|
is_processing = fields.Boolean(
|
||||||
|
string='正在处理中',
|
||||||
|
default=False,
|
||||||
|
help='用于防止重复点击按钮'
|
||||||
|
)
|
||||||
|
|
||||||
# hide_action_open_mrp_production = fields.Boolean(
|
# hide_action_open_mrp_production = fields.Boolean(
|
||||||
# string='显示待工艺确认按钮',
|
# string='显示待工艺确认按钮',
|
||||||
# compute='_compute_hid_button',
|
# compute='_compute_hid_button',
|
||||||
@@ -192,6 +164,76 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
# )
|
# )
|
||||||
#
|
#
|
||||||
# outsourcing_purchase_request = fields.Char('委外采购申请单')
|
# outsourcing_purchase_request = fields.Char('委外采购申请单')
|
||||||
|
|
||||||
|
plan_uom_qty = fields.Float(string="计划量", required=True)
|
||||||
|
procurement_reason = fields.Selection([
|
||||||
|
('销售订单', "销售订单"),
|
||||||
|
('需求预测', "需求预测"),
|
||||||
|
('生产报废', "生产报废"),
|
||||||
|
], string='补货原因', default='销售订单', readonly=True)
|
||||||
|
|
||||||
|
blank_arrival_date = fields.Date('采购计划到货(坯料)')
|
||||||
|
finished_product_arrival_date = fields.Date('采购计划到货(成品)')
|
||||||
|
bom_id = fields.Many2one('mrp.bom', string="BOM", readonly=True)
|
||||||
|
location_id = fields.Many2one('stock.location', string='需求位置', default=get_location_id, readonly=True)
|
||||||
|
manual_quotation = fields.Boolean('人工编程', related='product_id.manual_quotation', default=False)
|
||||||
|
|
||||||
|
@api.constrains('plan_uom_qty')
|
||||||
|
def _check_plan_uom_qty(self):
|
||||||
|
line_ids = self.filtered(lambda p: p.plan_uom_qty == 0 or p.plan_uom_qty < 0)
|
||||||
|
if line_ids:
|
||||||
|
raise ValidationError(_("计划量不能小于等于0"))
|
||||||
|
|
||||||
|
@api.constrains('supply_method')
|
||||||
|
def _check_supply_method(self):
|
||||||
|
product_name = []
|
||||||
|
product = []
|
||||||
|
for line in self:
|
||||||
|
if line.supply_method == 'purchase' and line.is_incoming_material:
|
||||||
|
product_name.append(line.product_id.display_name)
|
||||||
|
if line.supply_method == 'automation' and line.manual_quotation:
|
||||||
|
product.append(line.product_id.display_name)
|
||||||
|
|
||||||
|
if product_name:
|
||||||
|
unique_product_names = list(set(product_name))
|
||||||
|
raise UserError('当前(%s)产品为客供料,不能选择外购' % ','.join(unique_product_names))
|
||||||
|
if product:
|
||||||
|
unique_product = list(set(product))
|
||||||
|
raise UserError('当前(%s)产品为人工编程,不能选择自动化产线加工' % ','.join(unique_product))
|
||||||
|
|
||||||
|
@api.depends('new_supply_method')
|
||||||
|
def _compute_custom_made_type(self):
|
||||||
|
DemandPlan = self.env['sf.production.demand.plan'].sudo()
|
||||||
|
for line in self:
|
||||||
|
if line.new_supply_method != "custom_made":
|
||||||
|
line.custom_made_type = False
|
||||||
|
else:
|
||||||
|
demand_plan_id = line.demand_plan_id._origin.id
|
||||||
|
demand_plan = DemandPlan.search([
|
||||||
|
('demand_plan_id', '=', demand_plan_id),
|
||||||
|
('new_supply_method', '=', 'custom_made'),
|
||||||
|
('status', 'in', ('50', '60'))
|
||||||
|
], limit=1)
|
||||||
|
if demand_plan:
|
||||||
|
line.custom_made_type = demand_plan.custom_made_type
|
||||||
|
|
||||||
|
@api.depends('new_supply_method', 'custom_made_type')
|
||||||
|
def _compute_supply_method(self):
|
||||||
|
for line in self:
|
||||||
|
if line.new_supply_method == 'custom_made':
|
||||||
|
line.supply_method = line.custom_made_type
|
||||||
|
else:
|
||||||
|
line.supply_method = line.new_supply_method
|
||||||
|
|
||||||
|
@api.depends('sale_order_line_id.qty_to_deliver')
|
||||||
|
def _compute_qty_to_deliver(self):
|
||||||
|
for line in self:
|
||||||
|
if float_compare(line.sale_order_line_id.qty_to_deliver, 0,
|
||||||
|
precision_rounding=line.product_id.uom_id.rounding) == -1:
|
||||||
|
line.qty_to_deliver = 0
|
||||||
|
else:
|
||||||
|
line.qty_to_deliver = line.sale_order_line_id.qty_to_deliver
|
||||||
|
|
||||||
@api.depends('supply_method')
|
@api.depends('supply_method')
|
||||||
def _compute_route_ids(self):
|
def _compute_route_ids(self):
|
||||||
for pdp in self:
|
for pdp in self:
|
||||||
@@ -204,74 +246,6 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
continue
|
continue
|
||||||
pdp.route_ids = None
|
pdp.route_ids = None
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
hide_action_stock_picking = fields.Boolean(
|
|
||||||
string='显示调拨单按钮',
|
|
||||||
compute='_compute_hide_action_stock_picking',
|
|
||||||
default=False
|
|
||||||
)
|
|
||||||
|
|
||||||
hide_action_outsourcing_stock_picking = fields.Boolean(
|
|
||||||
string='委外显示调拨单按钮',
|
|
||||||
compute='_compute_hide_action_stock_picking',
|
|
||||||
default=False
|
|
||||||
)
|
|
||||||
|
|
||||||
hide_action_view_programming = fields.Boolean(
|
|
||||||
string='显示编程单按钮',
|
|
||||||
compute='_compute_hid_button',
|
|
||||||
default=False
|
|
||||||
)
|
|
||||||
|
|
||||||
outsourcing_purchase_request = fields.Char('委外采购申请单')
|
|
||||||
|
|
||||||
@api.depends('supply_method')
|
|
||||||
def _compute_route_ids(self):
|
|
||||||
for pdp in self:
|
|
||||||
if pdp.supply_method:
|
|
||||||
group_id = self.env['stock.route.group'].sudo().search([('code', '=', pdp.supply_method)])
|
|
||||||
route_ids = self.env['stock.route'].sudo().search(
|
|
||||||
[('demand_plan_selectable', '=', True), ('stock_route_group_ids', '=', group_id.id)])
|
|
||||||
if route_ids:
|
|
||||||
pdp.route_ids = route_ids.ids
|
|
||||||
break
|
|
||||||
pdp.route_ids = None
|
|
||||||
|
|
||||||
@api.depends('sale_order_id.state', 'sale_order_id.mrp_production_ids.schedule_state', 'sale_order_id.order_line',
|
|
||||||
'sale_order_id.mrp_production_ids.state')
|
|
||||||
def _compute_status(self):
|
|
||||||
for record in self:
|
|
||||||
if record.sale_order_id:
|
|
||||||
sale_order_state = record.sale_order_id.state
|
|
||||||
if sale_order_state in ('draft', 'sent', 'supply method'):
|
|
||||||
record.status = '20' # 待确认
|
|
||||||
if record.supply_method in ('purchase', 'outsourcing') and sale_order_state in (
|
|
||||||
'sale', 'processing', 'physical_distribution', 'delivered',
|
|
||||||
'done') and sale_order_state != 'cancel':
|
|
||||||
record.status = '60' # 已下达
|
|
||||||
if record.supply_method in ('automation', 'manual'):
|
|
||||||
if sale_order_state in (
|
|
||||||
'sale', 'processing', 'physical_distribution', 'delivered',
|
|
||||||
'done') and sale_order_state != 'cancel':
|
|
||||||
record.status = '30' # 需求确认
|
|
||||||
# 检查所有制造订单的排程单状态,有一个为待排程状态,就为待下达生产
|
|
||||||
pending_productions = record.sale_order_id.mrp_production_ids.filtered(
|
|
||||||
lambda p: p.state == 'confirmed' and p.product_id.id == record.product_id.id
|
|
||||||
)
|
|
||||||
if pending_productions:
|
|
||||||
record.status = '50' # 待下达生产
|
|
||||||
# 检查所有制造订单的排程单状态
|
|
||||||
if record.sale_order_id.mrp_production_ids:
|
|
||||||
product_productions = record.sale_order_id.mrp_production_ids.filtered(
|
|
||||||
lambda p: p.product_id.id == record.product_id.id
|
|
||||||
)
|
|
||||||
if product_productions and all(order.schedule_state != '未排' for order in product_productions):
|
|
||||||
record.status = '60' # 已下达
|
|
||||||
if sale_order_state == 'cancel' or not record.sale_order_line_id:
|
|
||||||
record.status = '100' # 取消
|
|
||||||
>>>>>>> develop
|
|
||||||
|
|
||||||
@api.depends('sale_order_line_id.product_id.name')
|
@api.depends('sale_order_line_id.product_id.name')
|
||||||
def _compute_sale_order_line_number(self):
|
def _compute_sale_order_line_number(self):
|
||||||
for line in self:
|
for line in self:
|
||||||
@@ -288,84 +262,26 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
else:
|
else:
|
||||||
line.model_long = None
|
line.model_long = None
|
||||||
|
|
||||||
<<<<<<< HEAD
|
@api.depends('mrp_production_ids.workorder_ids.date_start')
|
||||||
=======
|
|
||||||
@api.depends('product_id.model_long', 'product_id.model_width', 'product_id.model_height', 'product_id.blank_type')
|
|
||||||
def _compute_embryo_long(self):
|
|
||||||
for line in self:
|
|
||||||
if line.product_id:
|
|
||||||
if line.product_id.blank_type == '圆料':
|
|
||||||
line.embryo_long = f"Ø{round(line.product_id.model_width, 3)}*{round(line.product_id.model_long, 3)}"
|
|
||||||
else:
|
|
||||||
line.embryo_long = f"{round(line.product_id.model_long, 3)}*{round(line.product_id.model_width, 3)}*{round(line.product_id.model_height, 3)}"
|
|
||||||
else:
|
|
||||||
line.embryo_long = None
|
|
||||||
|
|
||||||
@api.depends('product_id.materials_id')
|
|
||||||
def _compute_materials_id(self):
|
|
||||||
for line in self:
|
|
||||||
if line.product_id:
|
|
||||||
line.materials_id = f"{line.product_id.materials_id.name}/{line.product_id.materials_type_id.name}"
|
|
||||||
else:
|
|
||||||
line.materials_id = None
|
|
||||||
|
|
||||||
@api.depends('product_id.model_process_parameters_ids')
|
|
||||||
def _compute_model_process_parameters_ids(self):
|
|
||||||
for line in self:
|
|
||||||
if line.product_id and line.product_id.model_process_parameters_ids:
|
|
||||||
line.model_process_parameters_ids = [(6, 0, line.product_id.model_process_parameters_ids.ids)]
|
|
||||||
else:
|
|
||||||
line.model_process_parameters_ids = [(5, 0, 0)]
|
|
||||||
|
|
||||||
def _compute_inventory_quantity_auto_apply(self):
|
|
||||||
location_id = self.env['stock.location'].search([('name', '=', '成品存货区')], limit=1).id
|
|
||||||
product_ids = self.mapped('product_id').ids
|
|
||||||
if product_ids:
|
|
||||||
quant_data = self.env['stock.quant'].read_group(
|
|
||||||
domain=[
|
|
||||||
('product_id', 'in', product_ids),
|
|
||||||
('location_id', '=', location_id)
|
|
||||||
],
|
|
||||||
fields=['product_id', 'inventory_quantity_auto_apply'],
|
|
||||||
groupby=['product_id']
|
|
||||||
)
|
|
||||||
quantity_map = {item['product_id'][0]: item['inventory_quantity_auto_apply'] for item in quant_data}
|
|
||||||
else:
|
|
||||||
quantity_map = {}
|
|
||||||
for line in self:
|
|
||||||
if line.product_id:
|
|
||||||
line.inventory_quantity_auto_apply = quantity_map.get(line.product_id.id, 0.0)
|
|
||||||
else:
|
|
||||||
line.inventory_quantity_auto_apply = 0.0
|
|
||||||
|
|
||||||
>>>>>>> develop
|
|
||||||
@api.depends('sale_order_id.mrp_production_ids.workorder_ids.date_start')
|
|
||||||
def _compute_actual_start_date(self):
|
def _compute_actual_start_date(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
if record.sale_order_id and record.sale_order_id.mrp_production_ids:
|
if record.mrp_production_ids:
|
||||||
manufacturing_orders = record.sale_order_id.mrp_production_ids.filtered(
|
start_dates = [
|
||||||
lambda mo: mo.product_id == record.product_id)
|
workorder.date_start for mo in record.mrp_production_ids
|
||||||
if manufacturing_orders:
|
for workorder in mo.workorder_ids if workorder.date_start
|
||||||
start_dates = [
|
]
|
||||||
workorder.date_start for mo in manufacturing_orders
|
record.actual_start_date = min(start_dates) if start_dates else None
|
||||||
for workorder in mo.workorder_ids if workorder.date_start
|
|
||||||
]
|
|
||||||
record.actual_start_date = min(start_dates) if start_dates else None
|
|
||||||
else:
|
|
||||||
record.actual_start_date = None
|
|
||||||
else:
|
else:
|
||||||
record.actual_start_date = None
|
record.actual_start_date = None
|
||||||
|
|
||||||
@api.depends('sale_order_id.mrp_production_ids.workorder_ids.state',
|
@api.depends('mrp_production_ids.workorder_ids.state',
|
||||||
'sale_order_id.mrp_production_ids.workorder_ids.date_finished')
|
'mrp_production_ids.workorder_ids.date_finished')
|
||||||
def _compute_actual_end_date(self):
|
def _compute_actual_end_date(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
if record.sale_order_id and record.sale_order_id.mrp_production_ids:
|
if record.mrp_production_ids:
|
||||||
manufacturing_orders = record.sale_order_id.mrp_production_ids.filtered(
|
finished_orders = record.mrp_production_ids.filtered(lambda mo: mo.state == 'done')
|
||||||
lambda mo: mo.product_id == record.product_id)
|
|
||||||
finished_orders = manufacturing_orders.filtered(lambda mo: mo.state == 'done')
|
|
||||||
sum_product_qty = sum(finished_orders.mapped('product_qty'))
|
sum_product_qty = sum(finished_orders.mapped('product_qty'))
|
||||||
if finished_orders and float_compare(sum_product_qty, record.product_uom_qty,
|
if finished_orders and float_compare(sum_product_qty, record.plan_uom_qty,
|
||||||
precision_rounding=record.product_id.uom_id.rounding) >= 0:
|
precision_rounding=record.product_id.uom_id.rounding) >= 0:
|
||||||
end_dates = [
|
end_dates = [
|
||||||
workorder.date_finished for mo in finished_orders
|
workorder.date_finished for mo in finished_orders
|
||||||
@@ -377,27 +293,22 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
else:
|
else:
|
||||||
record.actual_end_date = None
|
record.actual_end_date = None
|
||||||
|
|
||||||
@api.depends('sale_order_id.mrp_production_ids.move_raw_ids.reserved_availability')
|
@api.depends('mrp_production_ids.move_raw_ids.reserved_availability')
|
||||||
def _compute_material_check(self):
|
def _compute_material_check(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
if record.sale_order_id and record.sale_order_id.mrp_production_ids:
|
if record.mrp_production_ids and record.mrp_production_ids.move_raw_ids:
|
||||||
manufacturing_orders = record.sale_order_id.mrp_production_ids.filtered(
|
# 获取完成的制造订单
|
||||||
lambda mo: mo.product_id == record.product_id)
|
done_manufacturing = record.mrp_production_ids.filtered(lambda mo: mo.state == 'done')
|
||||||
|
product_qty = sum(done_manufacturing.mapped('product_qty'))
|
||||||
if manufacturing_orders and manufacturing_orders.move_raw_ids:
|
# 需求数量-完成数量
|
||||||
# 获取完成的制造订单
|
product_uom_qty = record.plan_uom_qty - product_qty
|
||||||
done_manufacturing = manufacturing_orders.filtered(lambda mo: mo.state == 'done')
|
total_reserved_availability = sum(
|
||||||
product_qty = sum(done_manufacturing.mapped('product_qty'))
|
record.mrp_production_ids.mapped('move_raw_ids.reserved_availability'))
|
||||||
# 需求数量-完成数量
|
if float_compare(total_reserved_availability, product_uom_qty,
|
||||||
product_uom_qty = record.product_uom_qty - product_qty
|
precision_rounding=record.product_id.uom_id.rounding) >= 0:
|
||||||
total_reserved_availability = sum(manufacturing_orders.mapped('move_raw_ids.reserved_availability'))
|
record.material_check = '1' # 已齐套
|
||||||
if float_compare(total_reserved_availability, product_uom_qty,
|
|
||||||
precision_rounding=record.product_id.uom_id.rounding) >= 0:
|
|
||||||
record.material_check = '1' # 已齐套
|
|
||||||
else:
|
|
||||||
record.material_check = '0' # 未齐套
|
|
||||||
else:
|
else:
|
||||||
record.material_check = None
|
record.material_check = '0' # 未齐套
|
||||||
else:
|
else:
|
||||||
record.material_check = None
|
record.material_check = None
|
||||||
|
|
||||||
@@ -413,10 +324,11 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
@api.depends('mrp_production_ids.state')
|
@api.depends('mrp_production_ids.state')
|
||||||
def _compute_hide_release_production_order(self):
|
def _compute_hide_release_production_order(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
# 检查这条需求计划所有制造订单的排程单状态,有一个为待排程状态,就显示该按钮
|
# 检查这条需求计划所有制造订单的排程单状态,有一个为待排程状态,就显示改按钮
|
||||||
record.hide_release_production_order = bool(record.mrp_production_ids.filtered(
|
record.hide_release_production_order = bool(record.mrp_production_ids.filtered(
|
||||||
lambda p: p.state == 'confirmed'
|
lambda p: p.state == 'confirmed'
|
||||||
))
|
))
|
||||||
|
|
||||||
@api.constrains('planned_start_date')
|
@api.constrains('planned_start_date')
|
||||||
def _check_planned_start_date(self):
|
def _check_planned_start_date(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
@@ -446,22 +358,37 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
for pro_plan in pro_plan_list:
|
for pro_plan in pro_plan_list:
|
||||||
pro_plan.do_production_schedule()
|
pro_plan.do_production_schedule()
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
def update_sale_order_state(self):
|
def update_sale_order_state(self):
|
||||||
demand_plan = self.env['sf.demand.main.plan'].sudo().search([('sale_order_id', '=', self.sale_order_id.id)])
|
# demand_plan = self.env['sf.demand.plan'].sudo().search([('sale_order_id', '=', self.sale_order_id.id)])
|
||||||
demand_plan_state = demand_plan.filtered(lambda line: line.state != '40')
|
# demand_plan_state = demand_plan.filtered(lambda line: line.state != '40')
|
||||||
if not demand_plan_state:
|
production_demand_plan = self.env['sf.production.demand.plan'].sudo().search(
|
||||||
|
[('sale_order_id', '=', self.sale_order_id.id)])
|
||||||
|
production_demand_plan_state = production_demand_plan.filtered(lambda line: line.status in ('10', '20', '30'))
|
||||||
|
if not production_demand_plan_state:
|
||||||
# 修改销售订单为加工中
|
# 修改销售订单为加工中
|
||||||
self.sale_order_id.state = 'processing'
|
self.sale_order_id.state = 'processing'
|
||||||
|
|
||||||
=======
|
def edit_button(self):
|
||||||
>>>>>>> develop
|
self.ensure_one()
|
||||||
|
action = {
|
||||||
|
'name': _("需求计划"),
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'view_mode': 'form',
|
||||||
|
'views': [[self.env.ref('sf_demand_plan.view_sf_demand_plan_form').id, 'form']],
|
||||||
|
'res_model': 'sf.demand.plan',
|
||||||
|
'res_id': self.demand_plan_id.id,
|
||||||
|
}
|
||||||
|
if self.demand_plan_id.state == '40':
|
||||||
|
action.update({'flags': {'mode': 'readonly'}})
|
||||||
|
return action
|
||||||
|
|
||||||
def button_action_print(self):
|
def button_action_print(self):
|
||||||
|
model_id = self.mapped('model_id')
|
||||||
return {
|
return {
|
||||||
'res_model': 'sf.demand.plan.print.wizard',
|
'res_model': 'sf.demand.plan.print.wizard',
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
'name': _("打印"),
|
'name': _("打印"),
|
||||||
'domain': [('demand_plan_id', 'in', self.ids)],
|
'domain': [('model_id', 'in', model_id)],
|
||||||
'views': [[self.env.ref('sf_demand_plan.action_plan_print_tree').id, 'list']],
|
'views': [[self.env.ref('sf_demand_plan.action_plan_print_tree').id, 'list']],
|
||||||
'target': 'new',
|
'target': 'new',
|
||||||
}
|
}
|
||||||
@@ -674,44 +601,96 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
# programming_no = list(set(programming_mrp_production_ids))
|
# programming_no = list(set(programming_mrp_production_ids))
|
||||||
# numbers_str = "、".join(programming_no)
|
# numbers_str = "、".join(programming_no)
|
||||||
# raise ValidationError(f"编程单号:{numbers_str},请去云平台处理")
|
# raise ValidationError(f"编程单号:{numbers_str},请去云平台处理")
|
||||||
|
@api.model
|
||||||
|
def unlink(self):
|
||||||
|
for item in self:
|
||||||
|
if item.status not in ('10', '20', '30'):
|
||||||
|
raise ValidationError(u'只能删除状态为【草稿,待确认,待工艺设计】的需求计划。')
|
||||||
|
else:
|
||||||
|
super(SfProductionDemandPlan, item).unlink()
|
||||||
|
|
||||||
def action_edit_demand_plan_form(self):
|
def button_batch_release_plan(self):
|
||||||
"""编辑需求计划详细信息"""
|
filtered_plan = self.filtered(lambda mo: mo.status == '30')
|
||||||
self.ensure_one()
|
if not filtered_plan:
|
||||||
action = {
|
raise UserError(_("没有需要下达的计划!"))
|
||||||
'name': _("需求计划"),
|
# 按产品分组并计算总数
|
||||||
'type': 'ir.actions.act_window',
|
product_data = {}
|
||||||
'view_mode': 'form',
|
for plan in filtered_plan:
|
||||||
'views': [[self.env.ref('sf_demand_plan.view_sf_demand_main_plan_form').id, 'form']],
|
check_overdelivery_allowed = False
|
||||||
'res_model': 'sf.demand.main.plan',
|
if not plan.demand_plan_id.overdelivery_allowed:
|
||||||
'res_id': self.demand_plan_id.id,
|
customer_location_id = self.env['ir.model.data']._xmlid_to_res_id('stock.stock_location_customers')
|
||||||
}
|
if plan.location_id.id == customer_location_id:
|
||||||
#打开需求计划视图时,如果状态时已下达,则只读,不能添加明细了
|
check_overdelivery_allowed = True
|
||||||
if self.demand_plan_id.state == '40':
|
if plan.product_id not in product_data:
|
||||||
action.update({'flags': {'mode': 'readonly'}})
|
# 初始化产品数据,从产品上获取需求量
|
||||||
return action
|
product_data[plan.product_id] = {
|
||||||
#删除需求计划
|
'plan_uom_qty': 0.0,
|
||||||
def button_delete(self):
|
'product_uom_qty': plan.product_uom_qty
|
||||||
self.ensure_one()
|
}
|
||||||
if len(self.demand_plan_id.line_ids) == 1:
|
|
||||||
raise ValidationError(f"最后一条计划,不能删除!")
|
# 累加计划数量
|
||||||
self.unlink()
|
product_data[plan.product_id]['plan_uom_qty'] += plan.plan_uom_qty
|
||||||
#需求明细行里下达需求计划
|
product_data[plan.product_id]['overdelivery_allowed'] = check_overdelivery_allowed
|
||||||
def button_release_plan(self):
|
# 检查需求超过计划数量的产品
|
||||||
self.ensure_one()
|
warning_messages = []
|
||||||
if not self.supply_method:
|
error_messages = []
|
||||||
raise ValidationError(f"供货方式不能为空!")
|
for product, data in product_data.items():
|
||||||
#点击时校验,累计计划量>需求数量,则提示,新增了个提示确认视图
|
if data['overdelivery_allowed'] and float_compare(data['plan_uom_qty'], data['product_uom_qty'],precision_rounding=product.uom_id.rounding) == 1:
|
||||||
if self.plan_uom_qty > self.product_uom_qty:
|
error_messages.append(f"您正在下达的产品 {product.display_name},已禁止向合作伙伴/客户超量发货,请更换“补货原因”或将“可超量发货”设置为“是”。")
|
||||||
|
elif float_compare(data['plan_uom_qty'], data['product_uom_qty'],
|
||||||
|
precision_rounding=product.uom_id.rounding) == 1:
|
||||||
|
warning_messages.append(
|
||||||
|
_("您正在下达的产品 %s,计划量%s,需求数量为%s,已超过需求数量") %
|
||||||
|
(product.display_name, data['plan_uom_qty'], data['product_uom_qty'])
|
||||||
|
)
|
||||||
|
if error_messages:
|
||||||
|
error_message = "\n".join(error_messages)
|
||||||
|
raise ValidationError(error_message)
|
||||||
|
elif warning_messages:
|
||||||
|
warning_message = "\n".join(warning_messages)
|
||||||
return {
|
return {
|
||||||
'name': _('需求计划'),
|
'name': _('需求计划'),
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
'views': [(self.env.ref('sf_demand_plan.sf_release_plan_wizard_form').id,'form')],
|
'views': [(self.env.ref(
|
||||||
|
'sf_demand_plan.sf_release_plan_wizard_form').id,
|
||||||
|
'form')],
|
||||||
'res_model': 'sf.release.plan.wizard',
|
'res_model': 'sf.release.plan.wizard',
|
||||||
'target': 'new',
|
'target': 'new',
|
||||||
'context': {
|
'context': {
|
||||||
'default_demand_plan_line_id': self.id,
|
'default_demand_plan_line_id': self.ids,
|
||||||
'default_release_message': f"您正在下达计划量 {self.plan_uom_qty},累计计划量为 {self.demand_plan_id.planned_qty},需求数量为 {self.product_uom_qty},已超过需求数量,是否继续?",
|
'default_release_message': warning_message,
|
||||||
|
}}
|
||||||
|
else:
|
||||||
|
for demand_plan_line_id in filtered_plan:
|
||||||
|
demand_plan_line_id.action_confirm()
|
||||||
|
|
||||||
|
def button_release_plan(self):
|
||||||
|
self.ensure_one()
|
||||||
|
if self.is_processing:
|
||||||
|
return
|
||||||
|
self.is_processing = True
|
||||||
|
check_overdelivery_allowed = False
|
||||||
|
if not self.demand_plan_id.overdelivery_allowed:
|
||||||
|
customer_location_id = self.env['ir.model.data']._xmlid_to_res_id('stock.stock_location_customers')
|
||||||
|
if self.location_id.id == customer_location_id:
|
||||||
|
check_overdelivery_allowed = True
|
||||||
|
if check_overdelivery_allowed:
|
||||||
|
if float_compare(self.plan_uom_qty, self.product_uom_qty,
|
||||||
|
precision_rounding=self.product_id.uom_id.rounding) == 1:
|
||||||
|
raise ValidationError(f"已禁止向合作伙伴/客户超量发货,请更换“补货原因”或将“可超量发货”设置为“是”。")
|
||||||
|
elif float_compare(self.plan_uom_qty, self.product_uom_qty,
|
||||||
|
precision_rounding=self.product_id.uom_id.rounding) == 1:
|
||||||
|
return {
|
||||||
|
'name': _('需求计划'),
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'views': [(self.env.ref(
|
||||||
|
'sf_demand_plan.sf_release_plan_wizard_form').id,
|
||||||
|
'form')],
|
||||||
|
'res_model': 'sf.release.plan.wizard',
|
||||||
|
'target': 'new',
|
||||||
|
'context': {
|
||||||
|
'default_demand_plan_line_id': self.ids,
|
||||||
|
'default_release_message': f"您正在下达计划量 {self.plan_uom_qty},需求数量为 {self.product_uom_qty},已超过需求数量,是否继续?",
|
||||||
}}
|
}}
|
||||||
self.action_confirm()
|
self.action_confirm()
|
||||||
|
|
||||||
@@ -721,29 +700,14 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
)
|
)
|
||||||
self.mrp_bom_create()
|
self.mrp_bom_create()
|
||||||
self._action_launch_stock_rule()
|
self._action_launch_stock_rule()
|
||||||
#自动化产线,人工产线,待下达生产
|
|
||||||
if self.supply_method in ('automation', 'manual'):
|
if self.supply_method in ('automation', 'manual'):
|
||||||
self.write({'status': '50'})
|
self.write({'status': '50'})
|
||||||
|
self.update_sale_order_state()
|
||||||
else:
|
else:
|
||||||
#外购,委外,已下达
|
|
||||||
self.write({'status': '60'})
|
self.write({'status': '60'})
|
||||||
self.update_sale_order_state()
|
self.update_sale_order_state()
|
||||||
|
|
||||||
def mrp_bom_create(self):
|
def mrp_bom_create(self):
|
||||||
# 检查是否已有相同供货方式的BOM
|
|
||||||
if self.supply_method in ('automation', 'manual'):
|
|
||||||
#同一需求计划下,相同供货方式的产品可以共享BOM
|
|
||||||
line_ids = self.demand_plan_id.line_ids.filtered(
|
|
||||||
lambda p: p.supply_method in ('automation', 'manual') and p.status in ('50', '60'))
|
|
||||||
if line_ids:
|
|
||||||
self.bom_id = line_ids[0].bom_id.id # 复用已有BOM
|
|
||||||
return
|
|
||||||
elif self.supply_method == 'outsourcing':
|
|
||||||
line_ids = self.demand_plan_id.line_ids.filtered(
|
|
||||||
lambda p: p.supply_method == 'outsourcing' and p.status == '60')
|
|
||||||
if line_ids:
|
|
||||||
self.bom_id = line_ids[0].bom_id.id
|
|
||||||
return
|
|
||||||
bom_type = ''
|
bom_type = ''
|
||||||
# 根据供货方式修改成品模板
|
# 根据供货方式修改成品模板
|
||||||
if self.supply_method == 'automation':
|
if self.supply_method == 'automation':
|
||||||
@@ -763,9 +727,21 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
|
|
||||||
# 复制成品模板上的属性
|
# 复制成品模板上的属性
|
||||||
self.product_id.product_tmpl_id.copy_template(product_template_id)
|
self.product_id.product_tmpl_id.copy_template(product_template_id)
|
||||||
|
if self.supply_method in ('automation', 'manual'):
|
||||||
|
line_ids = self.demand_plan_id.line_ids.filtered(
|
||||||
|
lambda p: p.supply_method in ('automation', 'manual') and p.status in ('50', '60'))
|
||||||
|
if line_ids:
|
||||||
|
self.bom_id = line_ids[0].bom_id.id
|
||||||
|
return
|
||||||
|
elif self.supply_method == 'outsourcing':
|
||||||
|
line_ids = self.demand_plan_id.line_ids.filtered(
|
||||||
|
lambda p: p.supply_method == 'outsourcing' and p.status == '60')
|
||||||
|
if line_ids:
|
||||||
|
self.bom_id = line_ids[0].bom_id.id
|
||||||
|
return
|
||||||
|
future_time = datetime.now() + timedelta(hours=8)
|
||||||
# 生成BOM单据编码
|
# 生成BOM单据编码
|
||||||
code = f"{self.product_id.default_code}-{bom_type}-{datetime.now().strftime('%Y%m%d%H%M%S')}"
|
code = f"{self.product_id.default_code}-{bom_type}-{future_time.strftime('%Y%m%d%H%M%S')}"
|
||||||
|
|
||||||
order_id = self.sale_order_id
|
order_id = self.sale_order_id
|
||||||
product = self.product_id
|
product = self.product_id
|
||||||
@@ -863,7 +839,12 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
self.bom_id = product_bom_outsource.id
|
self.bom_id = product_bom_outsource.id
|
||||||
elif self.product_id.materials_type_id.gain_way == '采购':
|
elif self.product_id.materials_type_id.gain_way == '采购':
|
||||||
purchase_id = self.env.ref('sf_dlm.product_embryo_sf_purchase').sudo()
|
purchase_id = self.env.ref('sf_dlm.product_embryo_sf_purchase').sudo()
|
||||||
purchase_embryo = self.env['product.template'].sudo().no_bom_product_create(purchase_id,item,order_id,'purchase',product_seria,product)
|
purchase_embryo = self.env['product.template'].sudo().no_bom_product_create(purchase_id,
|
||||||
|
item,
|
||||||
|
order_id,
|
||||||
|
'purchase',
|
||||||
|
product_seria,
|
||||||
|
product)
|
||||||
if purchase_embryo and purchase_embryo == -3:
|
if purchase_embryo and purchase_embryo == -3:
|
||||||
raise UserError('该订单模型的材料型号暂未设置获取方式和供应商,请先配置再进行分配')
|
raise UserError('该订单模型的材料型号暂未设置获取方式和供应商,请先配置再进行分配')
|
||||||
else:
|
else:
|
||||||
@@ -874,10 +855,8 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
purchase_embryo)
|
purchase_embryo)
|
||||||
self.bom_id = product_bom_purchase.id
|
self.bom_id = product_bom_purchase.id
|
||||||
|
|
||||||
#以下方法待了解
|
|
||||||
def _action_launch_stock_rule(self):
|
def _action_launch_stock_rule(self):
|
||||||
procurements = []
|
procurements = []
|
||||||
#创建采购需求
|
|
||||||
group_id = self.sale_order_id.procurement_group_id
|
group_id = self.sale_order_id.procurement_group_id
|
||||||
if not group_id:
|
if not group_id:
|
||||||
group_id = self.env['procurement.group'].create(self._prepare_procurement_group_vals())
|
group_id = self.env['procurement.group'].create(self._prepare_procurement_group_vals())
|
||||||
@@ -894,7 +873,6 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
line_uom = self.sale_order_line_id.product_uom
|
line_uom = self.sale_order_line_id.product_uom
|
||||||
quant_uom = self.product_id.uom_id
|
quant_uom = self.product_id.uom_id
|
||||||
plan_uom_qty, procurement_uom = line_uom._adjust_uom_quantities(self.plan_uom_qty, quant_uom)
|
plan_uom_qty, procurement_uom = line_uom._adjust_uom_quantities(self.plan_uom_qty, quant_uom)
|
||||||
#运行采购规则
|
|
||||||
procurements.append(self.env['procurement.group'].Procurement(
|
procurements.append(self.env['procurement.group'].Procurement(
|
||||||
self.product_id, plan_uom_qty, procurement_uom,
|
self.product_id, plan_uom_qty, procurement_uom,
|
||||||
self.sale_order_id.partner_shipping_id.property_stock_customer,
|
self.sale_order_id.partner_shipping_id.property_stock_customer,
|
||||||
@@ -903,7 +881,6 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
procurement_group = self.env['procurement.group']
|
procurement_group = self.env['procurement.group']
|
||||||
if self.env.context.get('import_file'):
|
if self.env.context.get('import_file'):
|
||||||
procurement_group = procurement_group.with_context(import_file=False)
|
procurement_group = procurement_group.with_context(import_file=False)
|
||||||
#确认拣货单
|
|
||||||
procurement_group.run(procurements)
|
procurement_group.run(procurements)
|
||||||
orders = self.mapped('sale_order_id')
|
orders = self.mapped('sale_order_id')
|
||||||
for order in orders:
|
for order in orders:
|
||||||
@@ -942,5 +919,5 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
}
|
}
|
||||||
return values
|
return values
|
||||||
|
|
||||||
|
def button_plan_detail(self):
|
||||||
|
pass
|
||||||
|
|||||||
@@ -19,11 +19,7 @@ class SfStockRoute(models.Model):
|
|||||||
[('supply_method', 'in', stock_route_group)])
|
[('supply_method', 'in', stock_route_group)])
|
||||||
if demand_plan_ids:
|
if demand_plan_ids:
|
||||||
sr.demand_plan_ids = demand_plan_ids.ids
|
sr.demand_plan_ids = demand_plan_ids.ids
|
||||||
<<<<<<< HEAD
|
|
||||||
continue
|
continue
|
||||||
=======
|
|
||||||
break
|
|
||||||
>>>>>>> develop
|
|
||||||
sr.demand_plan_ids = None
|
sr.demand_plan_ids = None
|
||||||
|
|
||||||
# def name_get(self):
|
# def name_get(self):
|
||||||
|
|||||||
@@ -5,16 +5,12 @@ 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,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_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
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
access_sf_demand_main_plan,sf.demand.main.plan,model_sf_demand_main_plan,base.group_user,1,0,0,0
|
access_sf_demand_plan,sf.demand.plan,model_sf_demand_plan,base.group_user,1,0,0,0
|
||||||
access_sf_demand_main_plan_for_dispatch,sf.demand.main.plan for dispatch,model_sf_demand_main_plan,sf_base.group_plan_dispatch,1,1,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
|
||||||
|
|
||||||
access_stock_route_group,stock.route.group,model_stock_route_group,base.group_user,1,0,0,0
|
access_stock_route_group,stock.route.group,model_stock_route_group,base.group_user,1,0,0,0
|
||||||
access_stock_route_group_dispatch,stock.route.group.dispatch,model_stock_route_group,sf_base.group_plan_dispatch,1,1,0,0
|
access_stock_route_group_dispatch,stock.route.group.dispatch,model_stock_route_group,sf_base.group_plan_dispatch,1,1,0,0
|
||||||
|
|
||||||
access_sf_release_plan_wizard,sf.release.plan.wizard,model_sf_release_plan_wizard,base.group_user,1,0,0,0
|
access_sf_release_plan_wizard,sf.release.plan.wizard,model_sf_release_plan_wizard,base.group_user,1,0,0,0
|
||||||
access_sf_release_plan_wizard_for_dispatch,sf.release.plan.wizard for dispatch,model_sf_release_plan_wizard,sf_base.group_plan_dispatch,1,1,1,1
|
access_sf_release_plan_wizard_for_dispatch,sf.release.plan.wizard for dispatch,model_sf_release_plan_wizard,sf_base.group_plan_dispatch,1,1,1,1
|
||||||
=======
|
|
||||||
access_stock_route_group,stock.route.group,model_stock_route_group,base.group_user,1,0,0,0
|
|
||||||
access_stock_route_group_dispatch,stock.route.group.dispatch,model_stock_route_group,sf_base.group_plan_dispatch,1,1,0,0
|
|
||||||
>>>>>>> develop
|
|
||||||
|
|||||||
|
59
sf_demand_plan/static/src/js/custom_button.js
Normal file
59
sf_demand_plan/static/src/js/custom_button.js
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
/** @odoo-module **/
|
||||||
|
|
||||||
|
import { registry } from "@web/core/registry";
|
||||||
|
import { ListRenderer } from "@web/views/list/list_renderer";
|
||||||
|
import { useService } from "@web/core/utils/hooks";
|
||||||
|
import { useEffect } from "@odoo/owl";
|
||||||
|
|
||||||
|
export class CustomDemandPlanListRenderer extends ListRenderer {
|
||||||
|
setup() {
|
||||||
|
super.setup();
|
||||||
|
this.orm = useService("orm");
|
||||||
|
this.notification = useService("notification");
|
||||||
|
console.log('setup', this.props);
|
||||||
|
|
||||||
|
// 监听selection属性的变化
|
||||||
|
useEffect(() => {
|
||||||
|
this.updateButtonState();
|
||||||
|
}, () => [this.props.list.selection]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新按钮状态
|
||||||
|
*/
|
||||||
|
async updateButtonState() {
|
||||||
|
const selectedRecords = this.props.list.selection;
|
||||||
|
const isStatus30 = selectedRecords.some(record => record.data.status != "30");
|
||||||
|
const button = $(this.__owl__.parent.bdom.parentEl).find('button[name="button_batch_release_plan"]');
|
||||||
|
console.log('isStatus30', isStatus30, button);
|
||||||
|
if (isStatus30) {
|
||||||
|
// 禁用按钮
|
||||||
|
button.attr('disabled', true);
|
||||||
|
} else {
|
||||||
|
button.attr('disabled', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 使用setTimeout延迟注册,避免在模块加载时立即执行
|
||||||
|
setTimeout(() => {
|
||||||
|
const registerCustomRenderer = () => {
|
||||||
|
try {
|
||||||
|
const listView = registry.category("views").get("list");
|
||||||
|
if (listView) {
|
||||||
|
registry.category("views").add("custom_demand_plan_list", {
|
||||||
|
...listView,
|
||||||
|
Renderer: CustomDemandPlanListRenderer,
|
||||||
|
});
|
||||||
|
console.log("Custom demand plan list renderer registered successfully");
|
||||||
|
} else {
|
||||||
|
console.warn("List view not found, retrying...");
|
||||||
|
// 如果还没找到,再等一段时间
|
||||||
|
setTimeout(registerCustomRenderer, 1000);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error registering custom renderer:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
registerCustomRenderer();
|
||||||
|
}, 1000);
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
th[data-name=processing_time] + th::before{
|
/*.demand_plan_tree th[data-name=planned_start_date] + th::before{*/
|
||||||
content: '待执行单据';
|
/* content: '待执行单据';*/
|
||||||
line-height: 38px;
|
/* line-height: 38px;*/
|
||||||
}
|
/*}*/
|
||||||
|
|||||||
@@ -1,70 +0,0 @@
|
|||||||
<odoo>
|
|
||||||
<record id="view_sf_demand_main_plan_form" model="ir.ui.view">
|
|
||||||
<field name="name">sf.demand.main.plan.form</field>
|
|
||||||
<field name="model">sf.demand.main.plan</field>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<form>
|
|
||||||
<header>
|
|
||||||
<field name="hide_button_release_plan" invisible="1"/>
|
|
||||||
<!-- <button string="下达计划" name="button_release_plan" type="object"-->
|
|
||||||
<!-- class="btn-primary" attrs="{'invisible': [('hide_button_release_plan', '=', False)]}"/>-->
|
|
||||||
<field name="state" widget="statusbar"/>
|
|
||||||
</header>
|
|
||||||
<sheet>
|
|
||||||
<group>
|
|
||||||
<group>
|
|
||||||
<field name="product_id"/>
|
|
||||||
<field name="part_name"/>
|
|
||||||
<field name="part_number"/>
|
|
||||||
<field name="materials_id"/>
|
|
||||||
<field name="blank_type"/>
|
|
||||||
<field name="embryo_long"/>
|
|
||||||
<field name="is_incoming_material"/>
|
|
||||||
<field name="pending_qty"/>
|
|
||||||
<field name="planned_qty"/>
|
|
||||||
<field name="model_id"/>
|
|
||||||
</group>
|
|
||||||
<group>
|
|
||||||
<field name="customer_name"/>
|
|
||||||
<field name="product_uom_qty"/>
|
|
||||||
<field name="deadline_of_delivery"/>
|
|
||||||
<field name="contract_date"/>
|
|
||||||
<field name="contract_code"/>
|
|
||||||
<field name="model_process_parameters_ids" widget="many2many_tags"/>
|
|
||||||
<field name="model_machining_precision"/>
|
|
||||||
<field name="inventory_quantity_auto_apply"/>
|
|
||||||
<field name="priority" attrs="{'readonly': [('state', 'in', ('40','50'))]}"/>
|
|
||||||
</group>
|
|
||||||
</group>
|
|
||||||
<notebook>
|
|
||||||
<page string="计划">
|
|
||||||
<field name="line_ids" attrs="{'readonly': [('state', 'in', ('40','50'))]}">
|
|
||||||
<tree editable="bottom" delete="false">
|
|
||||||
<field name="status"/>
|
|
||||||
<field name="supply_method" attrs="{'readonly': [('status', '!=', '30')]}"/>
|
|
||||||
<field name="route_ids" widget="many2many_tags" optional="hide"/>
|
|
||||||
<field name="location_id" optional="hide"/>
|
|
||||||
<field name="bom_id" optional="hide"/>
|
|
||||||
<field name="plan_uom_qty"/>
|
|
||||||
<field name="blank_arrival_date"/>
|
|
||||||
<field name="finished_product_arrival_date"/>
|
|
||||||
<field name="planned_start_date"/>
|
|
||||||
<field name="actual_start_date"/>
|
|
||||||
<field name="actual_end_date"/>
|
|
||||||
<field name="plan_remark"/>
|
|
||||||
<field name="procurement_reason"/>
|
|
||||||
<field name="write_date" string="更新时间"/>
|
|
||||||
<field name="hide_release_production_order" invisible="1"/>
|
|
||||||
<button string="下达计划" name="button_release_plan" type="object" class="btn-primary" attrs="{'invisible': [('status', 'in', ('50','60','100'))]}" />
|
|
||||||
<button name="button_release_production" type="object" string="下发生产" class="btn-primary" attrs="{'invisible': [('hide_release_production_order', '=', False)]}" />
|
|
||||||
<button name="button_delete" type="object" string="删除" class="btn-primary" attrs="{'invisible': [('status', 'not in', ('10','20','30'))]}" confirm='是否确认删除?'/>
|
|
||||||
</tree>
|
|
||||||
</field>
|
|
||||||
</page>
|
|
||||||
</notebook>
|
|
||||||
</sheet>
|
|
||||||
</form>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
</odoo>
|
|
||||||
@@ -4,10 +4,14 @@
|
|||||||
<field name="model">sf.production.demand.plan</field>
|
<field name="model">sf.production.demand.plan</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="需求计划" default_order="sequence desc,id desc" editable="bottom"
|
<tree string="需求计划" default_order="sequence desc,id desc" editable="bottom"
|
||||||
class="demand_plan_tree freeze-columns-before-part_number" create="false" delete="false">
|
class="demand_plan_tree freeze-columns-before-part_number" create="false" delete="false"
|
||||||
|
js_class="custom_demand_plan_list">
|
||||||
<header>
|
<header>
|
||||||
<button string="打印" name="button_action_print" type="object"
|
<button string="打印" name="button_action_print" type="object"
|
||||||
class="btn-primary"/>
|
class="btn-primary"/>
|
||||||
|
<button string="下达计划" name="button_batch_release_plan" type="object"
|
||||||
|
class="btn-primary"
|
||||||
|
/>
|
||||||
</header>
|
</header>
|
||||||
<field name="sequence" widget="handle"/>
|
<field name="sequence" widget="handle"/>
|
||||||
<field name="id" optional="hide"/>
|
<field name="id" optional="hide"/>
|
||||||
@@ -19,22 +23,34 @@
|
|||||||
<field name="model_id" optional="hide"/>
|
<field name="model_id" optional="hide"/>
|
||||||
<field name="part_name"/>
|
<field name="part_name"/>
|
||||||
<field name="part_number"/>
|
<field name="part_number"/>
|
||||||
|
<field name="manual_quotation" optional="hide"/>
|
||||||
<field name="is_incoming_material"/>
|
<field name="is_incoming_material"/>
|
||||||
<field name="supply_method" attrs="{'readonly': [('status', '!=', '30')]}"/>
|
<field name="new_supply_method" attrs="{'readonly': [('status', '!=', '30')]}"/>
|
||||||
|
<field name="readonly_custom_made_type" invisible="1"/>
|
||||||
|
<field name="custom_made_type"
|
||||||
|
attrs="{'readonly': ['|',('status', '!=', '30'),('readonly_custom_made_type', '=', True)],
|
||||||
|
'required': [('new_supply_method', '=', 'custom_made')]}"/>
|
||||||
<field name="product_uom_qty"/>
|
<field name="product_uom_qty"/>
|
||||||
|
<field name="plan_uom_qty" attrs="{'readonly': [('status', '!=', '30')]}"/>
|
||||||
<field name="deadline_of_delivery"/>
|
<field name="deadline_of_delivery"/>
|
||||||
<field name="inventory_quantity_auto_apply"/>
|
<field name="inventory_quantity_auto_apply" optional="hide"/>
|
||||||
<field name="qty_delivered"/>
|
<field name="qty_delivered" optional="hide"/>
|
||||||
<field name="qty_to_deliver"/>
|
<field name="qty_to_deliver" optional="hide"/>
|
||||||
<field name="model_long"/>
|
<field name="model_long"/>
|
||||||
<field name="blank_type" optional="hide"/>
|
<field name="blank_type" optional="hide"/>
|
||||||
<field name="blank_precision"/>
|
<field name="blank_precision"/>
|
||||||
<field name="embryo_long"/>
|
<field name="embryo_long"/>
|
||||||
|
<field name="unit_number" optional="hide"/>
|
||||||
|
<field name="materials_id"/>
|
||||||
|
<field name="model_machining_precision"/>
|
||||||
|
<field name="model_process_parameters_ids" widget="many2many_tags"/>
|
||||||
<field name="product_remark" optional="hide"/>
|
<field name="product_remark" optional="hide"/>
|
||||||
<field name="order_code" optional="hide"/>
|
<field name="order_code" optional="hide"/>
|
||||||
<field name="sale_order_id" optional="hide"/>
|
<field name="sale_order_id" optional="hide"/>
|
||||||
<field name="sale_order_line_number" optional="hide"/>
|
<field name="sale_order_line_number" optional="hide"/>
|
||||||
<field name="order_state"/>
|
<field name="order_state"/>
|
||||||
|
<field name="route_ids" widget="many2many_tags" optional="hide"
|
||||||
|
context="{'demand_plan_search_stock_route_id': id}"/>
|
||||||
<field name="contract_date"/>
|
<field name="contract_date"/>
|
||||||
<field name="date_order"/>
|
<field name="date_order"/>
|
||||||
<field name="contract_code"/>
|
<field name="contract_code"/>
|
||||||
@@ -68,10 +84,14 @@
|
|||||||
<field name="write_uid" optional="hide" string="更新人"/>
|
<field name="write_uid" optional="hide" string="更新人"/>
|
||||||
<field name="print_count"/>
|
<field name="print_count"/>
|
||||||
<field name="hide_release_production_order" invisible="1"/>
|
<field name="hide_release_production_order" invisible="1"/>
|
||||||
|
<button string="下达计划" name="button_release_plan" type="object"
|
||||||
|
class="btn-primary"
|
||||||
|
attrs="{'invisible': [('status', 'in', ('50','60','100'))]}"
|
||||||
|
/>
|
||||||
<button name="button_release_production" type="object" string="下发生产" class="btn-primary"
|
<button name="button_release_production" type="object" string="下发生产" class="btn-primary"
|
||||||
attrs="{'invisible': [('hide_release_production_order', '=', False)]}"
|
attrs="{'invisible': [('hide_release_production_order', '=', False)]}"
|
||||||
/>
|
/>
|
||||||
<button name="action_edit_demand_plan_form" type="object" string="编辑" class="btn-primary"/>
|
<button name="edit_button" type="object" string="拆分" class="btn-primary"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -110,6 +130,7 @@
|
|||||||
</search>
|
</search>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="sf_production_demand_plan_action" model="ir.actions.act_window">
|
<record id="sf_production_demand_plan_action" model="ir.actions.act_window">
|
||||||
<field name="name">需求计划</field>
|
<field name="name">需求计划</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
|
|||||||
123
sf_demand_plan/views/demand_plan_info.xml
Normal file
123
sf_demand_plan/views/demand_plan_info.xml
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
<odoo>
|
||||||
|
<record id="view_sf_demand_plan_form" model="ir.ui.view">
|
||||||
|
<field name="name">sf.demand.plan.form</field>
|
||||||
|
<field name="model">sf.demand.plan</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form>
|
||||||
|
<header>
|
||||||
|
<field name="state" widget="statusbar"/>
|
||||||
|
<field name="hide_button_release_plan" invisible="1"/>
|
||||||
|
<button string="下达计划" name="button_production_release_plan" type="object"
|
||||||
|
class="btn-primary"
|
||||||
|
attrs="{'invisible': [('hide_button_release_plan', '=', False)]}"/>
|
||||||
|
</header>
|
||||||
|
<sheet>
|
||||||
|
<group>
|
||||||
|
<group>
|
||||||
|
<field name="demand_plan_number"/>
|
||||||
|
<field name="product_id"/>
|
||||||
|
<field name="part_name"/>
|
||||||
|
<field name="part_number"/>
|
||||||
|
<field name="materials_id"/>
|
||||||
|
<field name="blank_type"/>
|
||||||
|
<field name="blank_precision"/>
|
||||||
|
<field name="embryo_long"/>
|
||||||
|
<field name="manual_quotation"/>
|
||||||
|
<field name="is_incoming_material"/>
|
||||||
|
<field name="pending_qty"/>
|
||||||
|
<field name="planned_qty"/>
|
||||||
|
<field name="model_id"/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="customer_name"/>
|
||||||
|
<field name="product_uom_qty"/>
|
||||||
|
<field name="deadline_of_delivery"/>
|
||||||
|
<field name="contract_date"/>
|
||||||
|
<field name="contract_code"/>
|
||||||
|
<field name="model_process_parameters_ids" widget="many2many_tags"/>
|
||||||
|
<field name="model_machining_precision"/>
|
||||||
|
<field name="inventory_quantity_auto_apply"/>
|
||||||
|
<field name="priority" attrs="{'readonly': [('state', 'in', ('40','50'))]}"/>
|
||||||
|
<field name="overdelivery_allowed"/>
|
||||||
|
<field name="origin"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
<notebook>
|
||||||
|
<page string="计划">
|
||||||
|
<field name="line_ids" attrs="{'invisible': [('state', 'in', ('40','50'))]}">
|
||||||
|
<tree editable="bottom" create="false" delete="false">
|
||||||
|
<field name="status"/>
|
||||||
|
<field name="readonly_custom_made_type" invisible="1"/>
|
||||||
|
<field name="new_supply_method" attrs="{'readonly': [('status', '!=', '30')]}"/>
|
||||||
|
<field name="custom_made_type"
|
||||||
|
attrs="{
|
||||||
|
'readonly': ['|', '|', ('new_supply_method', '!=', 'custom_made'), ('status', '!=', '30'), ('readonly_custom_made_type', '=', True)],
|
||||||
|
'required': [('new_supply_method', '=', 'custom_made')]}"/>
|
||||||
|
<field name="route_ids" widget="many2many_tags" optional="hide"/>
|
||||||
|
<field name="location_id" optional="hide"/>
|
||||||
|
<field name="bom_id" optional="hide"/>
|
||||||
|
<field name="processing_time" optional="hide"/>
|
||||||
|
<field name="plan_uom_qty" attrs="{'readonly': [('status', '!=', '30')]}"/>
|
||||||
|
<field name="blank_arrival_date"/>
|
||||||
|
<field name="finished_product_arrival_date"/>
|
||||||
|
<field name="planned_start_date"/>
|
||||||
|
<field name="actual_start_date"/>
|
||||||
|
<field name="actual_end_date"/>
|
||||||
|
<field name="plan_remark"/>
|
||||||
|
<field name="procurement_reason"/>
|
||||||
|
<field name="write_date" string="更新时间"/>
|
||||||
|
<field name="hide_release_production_order" invisible="1"/>
|
||||||
|
<button string="下达计划" name="button_release_plan" type="object"
|
||||||
|
class="btn-primary"
|
||||||
|
attrs="{'invisible': [('status', 'in', ('50','60','100'))]}"
|
||||||
|
/>
|
||||||
|
<button name="button_release_production" type="object" string="下发生产"
|
||||||
|
class="btn-primary"
|
||||||
|
attrs="{'invisible': [('hide_release_production_order', '=', False)]}"
|
||||||
|
/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
<field name="line_ids" attrs="{'invisible': [('state', 'not in', ('40','50'))]}">
|
||||||
|
<tree editable="bottom">
|
||||||
|
<field name="status"/>
|
||||||
|
<field name="readonly_custom_made_type" invisible="1"/>
|
||||||
|
<field name="new_supply_method" attrs="{'readonly': [('status', '!=', '30')]}"/>
|
||||||
|
<field name="custom_made_type"
|
||||||
|
attrs="{
|
||||||
|
'readonly': ['|', '|', ('new_supply_method', '!=', 'custom_made'), ('status', '!=', '30'), ('readonly_custom_made_type', '=', True)],
|
||||||
|
'required': [('new_supply_method', '=', 'custom_made')]}"/>
|
||||||
|
<field name="route_ids" widget="many2many_tags" optional="hide"/>
|
||||||
|
<field name="location_id" optional="hide"/>
|
||||||
|
<field name="bom_id" optional="hide" readonly="1" options="{'no_create': True}"/>
|
||||||
|
<field name="processing_time" optional="hide"/>
|
||||||
|
<field name="plan_uom_qty" attrs="{'readonly': [('status', '!=', '30')]}"/>
|
||||||
|
<field name="blank_arrival_date"/>
|
||||||
|
<field name="finished_product_arrival_date"/>
|
||||||
|
<field name="planned_start_date"/>
|
||||||
|
<field name="actual_start_date"/>
|
||||||
|
<field name="actual_end_date"/>
|
||||||
|
<field name="plan_remark"/>
|
||||||
|
<field name="procurement_reason"/>
|
||||||
|
<field name="write_date" string="更新时间"/>
|
||||||
|
<field name="hide_release_production_order" invisible="1"/>
|
||||||
|
<button string="下达计划" name="button_release_plan" type="object"
|
||||||
|
class="btn-primary"
|
||||||
|
attrs="{'invisible': [('status', 'in', ('50','60','100'))]}"
|
||||||
|
/>
|
||||||
|
<button name="button_release_production" type="object" string="下发生产"
|
||||||
|
class="btn-primary"
|
||||||
|
attrs="{'invisible': [('hide_release_production_order', '=', False)]}"
|
||||||
|
/>
|
||||||
|
<button string="详情" name="button_plan_detail" type="object"
|
||||||
|
class="btn-primary"
|
||||||
|
/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</page>
|
||||||
|
</notebook>
|
||||||
|
</sheet>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
@@ -9,11 +9,6 @@ class SfDemandPlanPrintWizard(models.TransientModel):
|
|||||||
_name = 'sf.demand.plan.print.wizard'
|
_name = 'sf.demand.plan.print.wizard'
|
||||||
_description = u'打印向导'
|
_description = u'打印向导'
|
||||||
|
|
||||||
demand_plan_id = fields.Many2one('sf.production.demand.plan', string='需求计划ID')
|
|
||||||
product_id = fields.Many2one(
|
|
||||||
comodel_name='product.product',
|
|
||||||
related='demand_plan_id.product_id',
|
|
||||||
string='产品', store=True, index=True)
|
|
||||||
model_id = fields.Char('模型ID')
|
model_id = fields.Char('模型ID')
|
||||||
filename_url = fields.Char('文件名/URL')
|
filename_url = fields.Char('文件名/URL')
|
||||||
type = fields.Selection([
|
type = fields.Selection([
|
||||||
@@ -25,7 +20,7 @@ class SfDemandPlanPrintWizard(models.TransientModel):
|
|||||||
('success', '成功'),
|
('success', '成功'),
|
||||||
('fail', '失败'),
|
('fail', '失败'),
|
||||||
], string='状态', default='not_start')
|
], string='状态', default='not_start')
|
||||||
machining_drawings = fields.Binary('2D加工图纸', related='product_id.machining_drawings', store=True)
|
machining_drawings = fields.Binary('2D加工图纸')
|
||||||
|
|
||||||
cnc_worksheet = fields.Binary('程序单')
|
cnc_worksheet = fields.Binary('程序单')
|
||||||
|
|
||||||
@@ -42,16 +37,19 @@ class SfDemandPlanPrintWizard(models.TransientModel):
|
|||||||
if pdf_data:
|
if pdf_data:
|
||||||
try:
|
try:
|
||||||
# 执行打印
|
# 执行打印
|
||||||
self.env['jikimo.printing'].sudo().print_pdf(pdf_data)
|
# self.env['jikimo.printing'].sudo().print_pdf(pdf_data)
|
||||||
record.status = 'success'
|
record.status = 'success'
|
||||||
t_part, c_part = record.demand_plan_id.print_count.split('C')
|
production_demand_plan_id = self.env['sf.production.demand.plan'].sudo().search(
|
||||||
t_num = int(t_part[1:])
|
[('model_id', '=', record.model_id)])
|
||||||
c_num = int(c_part)
|
for production_demand_plan in production_demand_plan_id:
|
||||||
if record.type == '1':
|
t_part, c_part = production_demand_plan.print_count.split('C')
|
||||||
t_num += 1
|
t_num = int(t_part[1:])
|
||||||
elif record.type == '2':
|
c_num = int(c_part)
|
||||||
c_num += 1
|
if record.type == '1':
|
||||||
record.demand_plan_id.print_count = f"T{t_num}C{c_num}"
|
t_num += 1
|
||||||
|
elif record.type == '2':
|
||||||
|
c_num += 1
|
||||||
|
production_demand_plan.print_count = f"T{t_num}C{c_num}"
|
||||||
success_records.append({
|
success_records.append({
|
||||||
'filename_url': record.filename_url,
|
'filename_url': record.filename_url,
|
||||||
})
|
})
|
||||||
@@ -78,18 +76,14 @@ class MrpWorkorder(models.Model):
|
|||||||
demand_plan_print = self.env['sf.demand.plan.print.wizard'].sudo().search(
|
demand_plan_print = self.env['sf.demand.plan.print.wizard'].sudo().search(
|
||||||
[('model_id', '=', record.model_id), ('type', '=', '2')])
|
[('model_id', '=', record.model_id), ('type', '=', '2')])
|
||||||
if demand_plan_print:
|
if demand_plan_print:
|
||||||
self.env['sf.demand.plan.print.wizard'].sudo().write(
|
demand_plan_print.write(
|
||||||
{'cnc_worksheet': record.cnc_worksheet, 'filename_url': record.cnc_worksheet_name})
|
{'cnc_worksheet': record.cnc_worksheet, 'filename_url': record.cnc_worksheet_name})
|
||||||
else:
|
else:
|
||||||
demand_plan = self.env['sf.production.demand.plan'].sudo().search(
|
wizard_vals = {
|
||||||
[('product_id', '=', record.product_id.id)])
|
'model_id': record.model_id,
|
||||||
if demand_plan:
|
'type': '2',
|
||||||
wizard_vals = {
|
'cnc_worksheet': record.cnc_worksheet,
|
||||||
'demand_plan_id': demand_plan.id,
|
'filename_url': record.cnc_worksheet_name
|
||||||
'model_id': demand_plan.model_id,
|
}
|
||||||
'type': '2',
|
self.env['sf.demand.plan.print.wizard'].sudo().create(wizard_vals)
|
||||||
'cnc_worksheet': record.cnc_worksheet,
|
|
||||||
'filename_url': record.cnc_worksheet_name
|
|
||||||
}
|
|
||||||
self.env['sf.demand.plan.print.wizard'].sudo().create(wizard_vals)
|
|
||||||
return res
|
return res
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import logging
|
import logging
|
||||||
from odoo import models, fields, api, _
|
from odoo import models, fields, api, _
|
||||||
|
from werkzeug.exceptions import InternalServerError
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -9,14 +10,18 @@ class SfReleasePlanWizard(models.TransientModel):
|
|||||||
_name = 'sf.release.plan.wizard'
|
_name = 'sf.release.plan.wizard'
|
||||||
_description = u'下达计划向导'
|
_description = u'下达计划向导'
|
||||||
|
|
||||||
demand_plan_id = fields.Many2one(comodel_name="sf.demand.main.plan",
|
demand_plan_line_id = fields.Many2many(comodel_name="sf.production.demand.plan",
|
||||||
string="需求计划", readonly=True)
|
string="需求计划明细", readonly=True)
|
||||||
|
|
||||||
demand_plan_line_id = fields.Many2one(comodel_name="sf.production.demand.plan",
|
|
||||||
string="需求计划明细", readonly=True)
|
|
||||||
|
|
||||||
release_message = fields.Char(string='提示', readonly=True)
|
release_message = fields.Char(string='提示', readonly=True)
|
||||||
|
|
||||||
def confirm(self):
|
def confirm(self):
|
||||||
if self.demand_plan_line_id:
|
if self.demand_plan_line_id:
|
||||||
self.demand_plan_line_id.action_confirm()
|
for demand_plan_line_id in self.demand_plan_line_id:
|
||||||
|
try:
|
||||||
|
demand_plan_line_id.action_confirm()
|
||||||
|
except Exception as e:
|
||||||
|
self.env.cr.rollback()
|
||||||
|
demand_plan_line_id.write({'is_processing': False})
|
||||||
|
self.env.cr.commit()
|
||||||
|
raise InternalServerError('操作失败', e)
|
||||||
|
|||||||
@@ -6,50 +6,50 @@ from odoo import models, fields, api, _
|
|||||||
class StockRuleInherit(models.Model):
|
class StockRuleInherit(models.Model):
|
||||||
_inherit = 'stock.rule'
|
_inherit = 'stock.rule'
|
||||||
|
|
||||||
@api.model
|
# @api.model
|
||||||
def _run_buy(self, procurements):
|
# def _run_buy(self, procurements):
|
||||||
# 判断补货组的采购类型
|
# # 判断补货组的采购类型
|
||||||
procurements_group = {'standard': [], 'outsourcing': []}
|
# procurements_group = {'standard': [], 'outsourcing': []}
|
||||||
for procurement, rule in procurements:
|
# for procurement, rule in procurements:
|
||||||
is_outsourcing = False
|
# is_outsourcing = False
|
||||||
product = procurement.product_id
|
# product = procurement.product_id
|
||||||
# 获取主 BOM
|
# # 获取主 BOM
|
||||||
bom = self.env['mrp.bom'].search([('product_tmpl_id', '=', product.product_tmpl_id.id)], limit=1)
|
# bom = self.env['mrp.bom'].search([('product_tmpl_id', '=', product.product_tmpl_id.id)], limit=1)
|
||||||
|
#
|
||||||
if bom:
|
# if bom:
|
||||||
# 遍历 BOM 中的组件(即坯料等)
|
# # 遍历 BOM 中的组件(即坯料等)
|
||||||
for line in bom.bom_line_ids:
|
# for line in bom.bom_line_ids:
|
||||||
raw_material = line.product_id
|
# raw_material = line.product_id
|
||||||
# 检查路线
|
# # 检查路线
|
||||||
for route in raw_material.route_ids:
|
# for route in raw_material.route_ids:
|
||||||
# print('route.name:', route.name)
|
# # print('route.name:', route.name)
|
||||||
if route.name == '按订单补给外包商':
|
# if route.name == '按订单补给外包商':
|
||||||
is_outsourcing = True
|
# is_outsourcing = True
|
||||||
|
#
|
||||||
if is_outsourcing:
|
# if is_outsourcing:
|
||||||
procurements_group['outsourcing'].append((procurement, rule))
|
# procurements_group['outsourcing'].append((procurement, rule))
|
||||||
else:
|
# else:
|
||||||
procurements_group['standard'].append((procurement, rule))
|
# procurements_group['standard'].append((procurement, rule))
|
||||||
|
#
|
||||||
for key, value in procurements_group.items():
|
# for key, value in procurements_group.items():
|
||||||
super(StockRuleInherit, self)._run_buy(value)
|
# super(StockRuleInherit, self)._run_buy(value)
|
||||||
|
#
|
||||||
if key == 'outsourcing':
|
# if key == 'outsourcing':
|
||||||
for procurement, rule in value:
|
# for procurement, rule in value:
|
||||||
supplier = procurement.values.get('supplier')
|
# supplier = procurement.values.get('supplier')
|
||||||
if supplier:
|
# if supplier:
|
||||||
domain = rule._make_po_get_domain(procurement.company_id, procurement.values,
|
# domain = rule._make_po_get_domain(procurement.company_id, procurement.values,
|
||||||
supplier.partner_id)
|
# supplier.partner_id)
|
||||||
logging.info("domain=============: %s", domain)
|
# logging.info("domain=============: %s", domain)
|
||||||
po = self.env['purchase.order'].sudo().search([
|
# po = self.env['purchase.order'].sudo().search([
|
||||||
('partner_id', '=', supplier.partner_id.id),
|
# ('partner_id', '=', supplier.partner_id.id),
|
||||||
('company_id', '=', procurement.company_id.id), # 保证公司一致
|
# ('company_id', '=', procurement.company_id.id), # 保证公司一致
|
||||||
('origin', 'like', procurement.origin), # 根据来源匹配
|
# ('origin', 'like', procurement.origin), # 根据来源匹配
|
||||||
('state', '=', 'draft') # 状态为草稿
|
# ('state', '=', 'draft') # 状态为草稿
|
||||||
], limit=1)
|
# ], limit=1)
|
||||||
logging.info("po=: %s", po)
|
# logging.info("po=: %s", po)
|
||||||
if po:
|
# if po:
|
||||||
po.write({'purchase_type': 'outsourcing'})
|
# po.write({'purchase_type': 'outsourcing'})
|
||||||
|
|
||||||
# # 首先调用父类的 _run_buy 方法,以保留原有逻辑
|
# # 首先调用父类的 _run_buy 方法,以保留原有逻辑
|
||||||
# super(StockRuleInherit, self)._run_buy(procurements)
|
# super(StockRuleInherit, self)._run_buy(procurements)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
'category': 'sf',
|
'category': 'sf',
|
||||||
'website': 'https://www.sf.jikimo.com',
|
'website': 'https://www.sf.jikimo.com',
|
||||||
'depends': ['sf_base', 'sf_maintenance', 'web_widget_model_viewer', 'sf_warehouse', 'jikimo_attachment_viewer',
|
'depends': ['sf_base', 'sf_maintenance', 'web_widget_model_viewer', 'sf_warehouse', 'jikimo_attachment_viewer',
|
||||||
'jikimo_sale_multiple_supply_methods', 'product'],
|
'jikimo_sale_multiple_supply_methods', 'product', 'jikimo_tree_header_buttons_always_visible'],
|
||||||
'data': [
|
'data': [
|
||||||
'data/cron_data.xml',
|
'data/cron_data.xml',
|
||||||
'data/stock_data.xml',
|
'data/stock_data.xml',
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
'sf_manufacturing/static/src/xml/kanban_change.xml',
|
'sf_manufacturing/static/src/xml/kanban_change.xml',
|
||||||
'sf_manufacturing/static/src/js/kanban_change.js',
|
'sf_manufacturing/static/src/js/kanban_change.js',
|
||||||
'sf_manufacturing/static/src/scss/kanban_change.scss',
|
'sf_manufacturing/static/src/scss/kanban_change.scss',
|
||||||
'sf_manufacturing/static/src/xml/button_show_on_tree.xml',
|
# 'sf_manufacturing/static/src/xml/button_show_on_tree.xml',
|
||||||
'sf_manufacturing/static/src/js/workpiece_delivery_wizard_confirm.js',
|
'sf_manufacturing/static/src/js/workpiece_delivery_wizard_confirm.js',
|
||||||
'sf_manufacturing/static/src/js/agv_scheduling_resend_confirm.js',
|
'sf_manufacturing/static/src/js/agv_scheduling_resend_confirm.js',
|
||||||
'sf_manufacturing/static/src/js/agv_scheduling_cancel_confirm.js',
|
'sf_manufacturing/static/src/js/agv_scheduling_cancel_confirm.js',
|
||||||
|
|||||||
@@ -217,7 +217,8 @@ class StockRule(models.Model):
|
|||||||
'''
|
'''
|
||||||
创建制造订单时生成序列号
|
创建制造订单时生成序列号
|
||||||
'''
|
'''
|
||||||
production.action_generate_serial()
|
if production.product_id.tracking != "none":
|
||||||
|
production.action_generate_serial()
|
||||||
origin_production = production.move_dest_ids and production.move_dest_ids[
|
origin_production = production.move_dest_ids and production.move_dest_ids[
|
||||||
0].raw_material_production_id or False
|
0].raw_material_production_id or False
|
||||||
orderpoint = production.orderpoint_id
|
orderpoint = production.orderpoint_id
|
||||||
@@ -442,7 +443,7 @@ class ProductionLot(models.Model):
|
|||||||
@api.model
|
@api.model
|
||||||
def _get_next_serial(self, company, product):
|
def _get_next_serial(self, company, product):
|
||||||
"""Return the next serial number to be attributed to the product."""
|
"""Return the next serial number to be attributed to the product."""
|
||||||
if product.tracking == "serial":
|
if product.tracking != "none":
|
||||||
last_serial = self.env['stock.lot'].search(
|
last_serial = self.env['stock.lot'].search(
|
||||||
[('company_id', '=', company.id), ('product_id', '=', product.id), ('name', 'ilike', product.name)],
|
[('company_id', '=', company.id), ('product_id', '=', product.id), ('name', 'ilike', product.name)],
|
||||||
limit=1, order='name desc')
|
limit=1, order='name desc')
|
||||||
@@ -453,7 +454,9 @@ class ProductionLot(models.Model):
|
|||||||
return self.env['stock.lot'].generate_lot_names1(product.name, last_serial.name if (
|
return self.env['stock.lot'].generate_lot_names1(product.name, last_serial.name if (
|
||||||
not move_line_id or
|
not move_line_id or
|
||||||
(last_serial and last_serial.name > move_line_id.lot_name)) else move_line_id.lot_name, 2)[1]
|
(last_serial and last_serial.name > move_line_id.lot_name)) else move_line_id.lot_name, 2)[1]
|
||||||
return "%s-%03d" % (product.name, 1)
|
else:
|
||||||
|
return "%s-%03d" % (product.name, 1)
|
||||||
|
return False
|
||||||
|
|
||||||
qr_code_image = fields.Binary(string='二维码', compute='_generate_qr_code')
|
qr_code_image = fields.Binary(string='二维码', compute='_generate_qr_code')
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
|||||||
if productions:
|
if productions:
|
||||||
# 修改需求计划中的程序工时
|
# 修改需求计划中的程序工时
|
||||||
demand_plan = request.env['sf.production.demand.plan'].with_user(
|
demand_plan = request.env['sf.production.demand.plan'].with_user(
|
||||||
request.env.ref("base.user_admin")).search([('model_id', '=', ret['folder_name'])])
|
request.env.ref("base.user_admin")).search(
|
||||||
|
[('model_id', '=', ret['folder_name']), ('new_supply_method', '=', 'custom_made')])
|
||||||
if demand_plan and ret['total_estimated_time']:
|
if demand_plan and ret['total_estimated_time']:
|
||||||
demand_plan.write(
|
demand_plan.write(
|
||||||
{'processing_time': ret['total_estimated_time']})
|
{'processing_time': ret['total_estimated_time']})
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
'data/report_actions.xml',
|
'data/report_actions.xml',
|
||||||
'views/view.xml',
|
'views/view.xml',
|
||||||
'views/quality_cnc_test_view.xml',
|
'views/quality_cnc_test_view.xml',
|
||||||
|
'views/stock_picking.xml',
|
||||||
'views/mrp_workorder.xml',
|
'views/mrp_workorder.xml',
|
||||||
'views/quality_check_view.xml',
|
'views/quality_check_view.xml',
|
||||||
'views/quality_company.xml',
|
'views/quality_company.xml',
|
||||||
|
|||||||
@@ -1,24 +1,29 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from odoo import api, models
|
from odoo import api, models, fields
|
||||||
from odoo.exceptions import ValidationError, UserError
|
from odoo.exceptions import ValidationError, UserError
|
||||||
|
|
||||||
|
|
||||||
class StockPicking(models.Model):
|
class StockPicking(models.Model):
|
||||||
_inherit = 'stock.picking'
|
_inherit = 'stock.picking'
|
||||||
|
|
||||||
|
whether_show_quality_check = fields.Boolean('是否显示质量检测按钮', default=True)
|
||||||
|
|
||||||
def _compute_check(self):
|
def _compute_check(self):
|
||||||
super()._compute_check()
|
super()._compute_check()
|
||||||
for picking in self:
|
for picking in self:
|
||||||
picking_to_quality = picking.get_picking_to_quality()
|
picking_to_quality = picking.get_picking_to_quality()
|
||||||
if not picking_to_quality:
|
if not picking_to_quality:
|
||||||
picking.quality_check_todo = False
|
picking.quality_check_todo = False
|
||||||
|
picking.whether_show_quality_check = False
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
picking.whether_show_quality_check = True
|
||||||
need_quality_line = picking.get_need_quality_line(picking_to_quality)
|
need_quality_line = picking.get_need_quality_line(picking_to_quality)
|
||||||
if not need_quality_line or all(not line.get('need_done_check_ids') for line in need_quality_line):
|
if not need_quality_line or all(not line.get('need_done_check_ids') for line in need_quality_line):
|
||||||
picking.quality_check_todo = False
|
picking.quality_check_todo = False
|
||||||
|
|
||||||
|
|
||||||
def check_quality(self):
|
def check_quality(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
# checkable_products = self.mapped('move_line_ids').mapped('product_id')
|
# checkable_products = self.mapped('move_line_ids').mapped('product_id')
|
||||||
|
|||||||
28
sf_quality/views/stock_picking.xml
Normal file
28
sf_quality/views/stock_picking.xml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<record id="stock_picking_view_form_inherit_quality_sf_quality" model="ir.ui.view">
|
||||||
|
<field name="name">stock.picking.view.form.sf.quality</field>
|
||||||
|
<field name="model">stock.picking</field>
|
||||||
|
<field name="inherit_id" ref="quality_control.stock_picking_view_form_inherit_quality"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//div[@name='button_box']" position="inside">
|
||||||
|
<field name="whether_show_quality_check" invisible="1"/>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//button[@name='action_open_quality_check_picking'][1]" position="attributes">
|
||||||
|
<attribute name="attrs">{'invisible': ['|', '|','|', ('check_ids', '=', []), ('quality_check_fail', '=',
|
||||||
|
True), ('quality_check_todo', '!=', True), ('whether_show_quality_check', '!=', True)]}
|
||||||
|
</attribute>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//button[@name='action_open_quality_check_picking'][2]" position="attributes">
|
||||||
|
<attribute name="attrs">{'invisible': ['|', '|','|', ('check_ids', '=', []), ('quality_check_fail', '=',
|
||||||
|
True), ('quality_check_todo', '=', True), ('whether_show_quality_check', '!=', True)]}
|
||||||
|
</attribute>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//button[@name='action_open_quality_check_picking'][3]" position="attributes">
|
||||||
|
<attribute name="attrs">{'invisible': ['|', '|',('check_ids', '=', []), ('quality_check_fail', '!=',
|
||||||
|
True), ('whether_show_quality_check', '!=', True)]}
|
||||||
|
</attribute>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
@@ -155,7 +155,7 @@ class ReSaleOrder(models.Model):
|
|||||||
'glb_url': item['glb_url'],
|
'glb_url': item['glb_url'],
|
||||||
'remark': item.get('remark'),
|
'remark': item.get('remark'),
|
||||||
'embryo_redundancy_id': item.get('embryo_redundancy_id'),
|
'embryo_redundancy_id': item.get('embryo_redundancy_id'),
|
||||||
'is_incoming_material': True if item.get('embryo_redundancy_id') else False,
|
'is_incoming_material': True if item.get('incoming_size') else False,
|
||||||
'manual_quotation': item.get('manual_quotation'),
|
'manual_quotation': item.get('manual_quotation'),
|
||||||
'model_id': item['model_id'],
|
'model_id': item['model_id'],
|
||||||
'delivery_end_date': item['delivery_end_date']
|
'delivery_end_date': item['delivery_end_date']
|
||||||
@@ -287,7 +287,7 @@ class ResaleOrderLine(models.Model):
|
|||||||
check_status = fields.Selection(related='order_id.check_status')
|
check_status = fields.Selection(related='order_id.check_status')
|
||||||
remark = fields.Char('备注')
|
remark = fields.Char('备注')
|
||||||
|
|
||||||
is_incoming_material = fields.Boolean('客供料', compute='_compute_is_incoming_material', store=True)
|
is_incoming_material = fields.Boolean('客供料', store=True)
|
||||||
embryo_redundancy_id = fields.Many2one('sf.embryo.redundancy', '坯料冗余')
|
embryo_redundancy_id = fields.Many2one('sf.embryo.redundancy', '坯料冗余')
|
||||||
manual_quotation = fields.Boolean('人工编程', default=False)
|
manual_quotation = fields.Boolean('人工编程', default=False)
|
||||||
model_url = fields.Char('模型文件地址')
|
model_url = fields.Char('模型文件地址')
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
# 'security/sf_stock_security.xml',
|
# 'security/sf_stock_security.xml',
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
'wizard/wizard_view.xml',
|
'wizard/wizard_view.xml',
|
||||||
|
'views/product.xml',
|
||||||
'views/view.xml',
|
'views/view.xml',
|
||||||
'views/shelf_location.xml',
|
'views/shelf_location.xml',
|
||||||
'views/change_stock_move_views.xml',
|
'views/change_stock_move_views.xml',
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
from . import model
|
from . import model
|
||||||
from . import sync_common
|
from . import sync_common
|
||||||
|
from . import product
|
||||||
|
|||||||
@@ -1082,6 +1082,10 @@ class SfStockPicking(models.Model):
|
|||||||
重写验证方法,当验证时意味着调拨单已经完成,已经移动到了目标货位,所以需要将当前货位的状态改为空闲
|
重写验证方法,当验证时意味着调拨单已经完成,已经移动到了目标货位,所以需要将当前货位的状态改为空闲
|
||||||
"""
|
"""
|
||||||
res = super(SfStockPicking, self).button_validate()
|
res = super(SfStockPicking, self).button_validate()
|
||||||
|
if any(ml.state == 'done' for ml in self.move_line_ids):
|
||||||
|
# 验证产品库存为负库存问题
|
||||||
|
self.move_ids.product_id.verify_product_repertory(self.location_id)
|
||||||
|
|
||||||
for line in self.move_line_ids:
|
for line in self.move_line_ids:
|
||||||
if line:
|
if line:
|
||||||
if line.destination_location_id:
|
if line.destination_location_id:
|
||||||
|
|||||||
29
sf_warehouse/models/product.py
Normal file
29
sf_warehouse/models/product.py
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
from odoo import models, fields
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
|
class SfProductCategory(models.Model):
|
||||||
|
_inherit = 'product.category'
|
||||||
|
|
||||||
|
negative_inventory_allowed = fields.Boolean('可负库存', default=True)
|
||||||
|
|
||||||
|
|
||||||
|
class SfProductTemplate(models.Model):
|
||||||
|
_inherit = 'product.product'
|
||||||
|
|
||||||
|
def verify_product_repertory(self, location_id):
|
||||||
|
"""
|
||||||
|
验证产品 负库存
|
||||||
|
"""
|
||||||
|
if not location_id:
|
||||||
|
raise ValidationError('当前位置为空!!')
|
||||||
|
elif len(location_id) != 1:
|
||||||
|
raise ValidationError(f'存在多个当前位置{[item.name for item in location_id]}')
|
||||||
|
elif location_id.usage == 'supplier':
|
||||||
|
return True
|
||||||
|
for pp in self:
|
||||||
|
if not pp.categ_id.negative_inventory_allowed:
|
||||||
|
sq = pp.stock_quant_ids.filtered(lambda sq: sq.quantity < 0 and sq.location_id == location_id)
|
||||||
|
if sq:
|
||||||
|
raise ValidationError(
|
||||||
|
f'产品{pp.name}的产品类型设置为不可负库存,当前操作会导致产品{pp.name}在库存{location_id.name}上的库存数量为负!!!')
|
||||||
17
sf_warehouse/views/product.xml
Normal file
17
sf_warehouse/views/product.xml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<record id="product_category_form_view_sf_warehouse" model="ir.ui.view">
|
||||||
|
<field name="name">product.category.property.form.warehouse</field>
|
||||||
|
<field name="model">product.category</field>
|
||||||
|
<field name="inherit_id" ref="account.view_category_property_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//group[@name='account_property']" position="after">
|
||||||
|
<group name="other">
|
||||||
|
<group string="其他">
|
||||||
|
<field name="negative_inventory_allowed"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user