Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/commercially_launched
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
'category': 'purchase',
|
'category': 'purchase',
|
||||||
'depends': ['sf_manufacturing', 'purchase_request'],
|
'depends': ['sf_manufacturing', 'purchase_request'],
|
||||||
'data': [
|
'data': [
|
||||||
|
'views/sale_order_view.xml',
|
||||||
],
|
],
|
||||||
# 'assets': {
|
# 'assets': {
|
||||||
# 'web.assets_backend': [
|
# 'web.assets_backend': [
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from . import product_template
|
from . import product_template
|
||||||
from . import purchase_request
|
from . import purchase_request
|
||||||
|
from . import sale_order
|
||||||
|
|||||||
50
jikimo_purchase_request/models/sale_order.py
Normal file
50
jikimo_purchase_request/models/sale_order.py
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
from odoo import fields, models, api, _
|
||||||
|
|
||||||
|
|
||||||
|
class StatusChange(models.Model):
|
||||||
|
_inherit = 'sale.order'
|
||||||
|
|
||||||
|
def action_confirm(self):
|
||||||
|
res = super(StatusChange, self).action_confirm()
|
||||||
|
# 采购申请自动确认
|
||||||
|
pr_ids = self.env["purchase.request"].sudo().search(
|
||||||
|
[('origin', 'like', self.name), ('rule_new_add', '=', True)])
|
||||||
|
if pr_ids:
|
||||||
|
pr_ids.write({'need_validation': False})
|
||||||
|
pr_ids.write({"state": "approved"})
|
||||||
|
return res
|
||||||
|
|
||||||
|
purchase_request_purchase_order_count = fields.Integer('采购申请单数量', compute='_compute_purchase_request_count',
|
||||||
|
store=True)
|
||||||
|
|
||||||
|
@api.depends('state')
|
||||||
|
def _compute_purchase_request_count(self):
|
||||||
|
for so in self:
|
||||||
|
pr_ids = self.env['purchase.request'].sudo().search([('origin', 'like', so.name)])
|
||||||
|
if pr_ids:
|
||||||
|
so.purchase_request_purchase_order_count = len(pr_ids)
|
||||||
|
else:
|
||||||
|
so.purchase_request_purchase_order_count = 0
|
||||||
|
|
||||||
|
def action_view_purchase_request_purchase_orders(self):
|
||||||
|
"""
|
||||||
|
采购请求
|
||||||
|
"""
|
||||||
|
self.ensure_one()
|
||||||
|
pr_ids = self.env['purchase.request'].sudo().search([('origin', 'like', self.name)])
|
||||||
|
action = {
|
||||||
|
'res_model': 'purchase.request',
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
}
|
||||||
|
if len(pr_ids) == 1:
|
||||||
|
action.update({
|
||||||
|
'view_mode': 'form',
|
||||||
|
'res_id': pr_ids[0].id,
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
action.update({
|
||||||
|
'name': _("从 %s生成采购请求单", self.name),
|
||||||
|
'domain': [('id', 'in', pr_ids)],
|
||||||
|
'view_mode': 'tree,form',
|
||||||
|
})
|
||||||
|
return action
|
||||||
19
jikimo_purchase_request/views/sale_order_view.xml
Normal file
19
jikimo_purchase_request/views/sale_order_view.xml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<odoo>
|
||||||
|
<record id="sale_order_inherited_form_purchase_request_sf" model="ir.ui.view">
|
||||||
|
<field name="name">sale.order.inherited.form.purchase.request</field>
|
||||||
|
<field name="model">sale.order</field>
|
||||||
|
<field name="inherit_id" ref="sale_purchase.sale_order_inherited_form_purchase"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//button[@name='action_preview_sale_order']" position="before">
|
||||||
|
<button class="oe_stat_button" name="action_view_purchase_request_purchase_orders" type="object" icon="fa-credit-card"
|
||||||
|
groups='purchase.group_purchase_user'
|
||||||
|
attrs="{'invisible': [('purchase_request_purchase_order_count', '=', 0)]}">
|
||||||
|
<div class="o_field_widget o_stat_info">
|
||||||
|
<span class="o_stat_value"><field name="purchase_request_purchase_order_count"/></span>
|
||||||
|
<span class="o_stat_text">采购申请</span>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
@@ -477,8 +477,8 @@ class QualityCheck(models.Model):
|
|||||||
if not self.report_content:
|
if not self.report_content:
|
||||||
raise UserError(_('当前质检单没有出厂检验报告,请先发布报告'))
|
raise UserError(_('当前质检单没有出厂检验报告,请先发布报告'))
|
||||||
|
|
||||||
if not self.part_number:
|
if not self.product_id.model_name:
|
||||||
raise UserError(_('零件图号不能为空'))
|
raise UserError(_('产品模型名称为空'))
|
||||||
|
|
||||||
if not self.picking_id or not self.picking_id.origin:
|
if not self.picking_id or not self.picking_id.origin:
|
||||||
raise UserError(_('无法找到相关的调拨单或来源单据'))
|
raise UserError(_('无法找到相关的调拨单或来源单据'))
|
||||||
@@ -490,7 +490,7 @@ class QualityCheck(models.Model):
|
|||||||
# 准备请求数据
|
# 准备请求数据
|
||||||
payload = {
|
payload = {
|
||||||
"order_ref": order_ref,
|
"order_ref": order_ref,
|
||||||
"part_number": self.part_number,
|
"model_name": self.product_id.model_name,
|
||||||
"report_file": self.report_content.decode('utf-8') if isinstance(self.report_content, bytes) else self.report_content
|
"report_file": self.report_content.decode('utf-8') if isinstance(self.report_content, bytes) else self.report_content
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -541,12 +541,18 @@ class QualityCheck(models.Model):
|
|||||||
"""
|
"""
|
||||||
# 获取订单号(从调拨单的来源字段获取)
|
# 获取订单号(从调拨单的来源字段获取)
|
||||||
order_ref = self.picking_id.retrospect_ref
|
order_ref = self.picking_id.retrospect_ref
|
||||||
|
|
||||||
|
if not order_ref:
|
||||||
|
raise UserError(_('无法找到相关的调拨单或来源单据'))
|
||||||
|
|
||||||
|
if not self.product_id.model_name:
|
||||||
|
raise UserError(_('产品模型名称为空'))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# 准备请求数据
|
# 准备请求数据
|
||||||
payload = {
|
payload = {
|
||||||
"order_ref": order_ref,
|
"order_ref": order_ref,
|
||||||
"part_number": self.part_number
|
"model_name": self.product_id.model_name
|
||||||
}
|
}
|
||||||
|
|
||||||
# 将Python字典转换为JSON字符串
|
# 将Python字典转换为JSON字符串
|
||||||
|
|||||||
Binary file not shown.
@@ -26,4 +26,12 @@ class SfQualityPoint(models.Model):
|
|||||||
if self.test_type_id.name == '出厂检验报告':
|
if self.test_type_id.name == '出厂检验报告':
|
||||||
if self.measure_on != 'product':
|
if self.measure_on != 'product':
|
||||||
raise ValidationError('出厂检验报告的测量对象必须为产品')
|
raise ValidationError('出厂检验报告的测量对象必须为产品')
|
||||||
|
|
||||||
|
@api.onchange('measure_on')
|
||||||
|
def _onchange_measure_on(self):
|
||||||
|
"""
|
||||||
|
如果measure_on的值变了,则清空test_type_id的值
|
||||||
|
"""
|
||||||
|
if self.measure_on != 'product':
|
||||||
|
self.test_type_id = False
|
||||||
|
|
||||||
|
|||||||
@@ -325,10 +325,11 @@ class RePurchaseOrder(models.Model):
|
|||||||
@api.depends('origin')
|
@api.depends('origin')
|
||||||
def _compute_purchase_type(self):
|
def _compute_purchase_type(self):
|
||||||
for purchase in self:
|
for purchase in self:
|
||||||
order_id = self.env['sale.order'].sudo().search([('name', '=', purchase.origin)])
|
origin = [origin.replace(' ', '') for origin in purchase.origin.split(',')]
|
||||||
if order_id:
|
order_ids = self.env['sale.order'].sudo().search([('name', 'in', origin)])
|
||||||
|
if order_ids:
|
||||||
product_list = [line.product_id.id for line in purchase.order_line]
|
product_list = [line.product_id.id for line in purchase.order_line]
|
||||||
for order_line in order_id.order_line:
|
for order_line in order_ids[0].order_line:
|
||||||
if order_line.supply_method == 'purchase':
|
if order_line.supply_method == 'purchase':
|
||||||
if order_line.product_id.id in product_list:
|
if order_line.product_id.id in product_list:
|
||||||
purchase.purchase_type = 'outside'
|
purchase.purchase_type = 'outside'
|
||||||
|
|||||||
Reference in New Issue
Block a user