制造订单详情页添加对应采购申请跳转链接
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
'depends': ['sf_manufacturing', 'purchase_request'],
|
'depends': ['sf_manufacturing', 'purchase_request'],
|
||||||
'data': [
|
'data': [
|
||||||
'views/sale_order_view.xml',
|
'views/sale_order_view.xml',
|
||||||
|
'views/mrp_production.xml',
|
||||||
'views/purchase_request_view.xml',
|
'views/purchase_request_view.xml',
|
||||||
'wizard/purchase_request_line_make_purchase_order_view.xml',
|
'wizard/purchase_request_line_make_purchase_order_view.xml',
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -2,5 +2,6 @@
|
|||||||
from . import product_template
|
from . import product_template
|
||||||
from . import purchase_request
|
from . import purchase_request
|
||||||
from . import sale_order
|
from . import sale_order
|
||||||
|
from . import mrp_production
|
||||||
from . import purchase_order
|
from . import purchase_order
|
||||||
from . import stock_rule
|
from . import stock_rule
|
||||||
|
|||||||
39
jikimo_purchase_request/models/mrp_production.py
Normal file
39
jikimo_purchase_request/models/mrp_production.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
from odoo import fields, models, api, _
|
||||||
|
|
||||||
|
|
||||||
|
class MrpProduction(models.Model):
|
||||||
|
_inherit = 'mrp.production'
|
||||||
|
|
||||||
|
pr_mp_count = fields.Integer('采购申请单数量', compute='_compute_pr_mp_count', store=True)
|
||||||
|
|
||||||
|
@api.depends('state')
|
||||||
|
def _compute_pr_mp_count(self):
|
||||||
|
for item in self:
|
||||||
|
pr_ids = self.env['purchase.request'].sudo().search([('origin', 'like', item.name)])
|
||||||
|
if pr_ids:
|
||||||
|
item.pr_mp_count = len(pr_ids)
|
||||||
|
else:
|
||||||
|
item.pr_mp_count = 0
|
||||||
|
|
||||||
|
def action_view_pr_mp(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
|
||||||
21
jikimo_purchase_request/views/mrp_production.xml
Normal file
21
jikimo_purchase_request/views/mrp_production.xml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<record id="mrp_production_inherited_form_purchase_request" model="ir.ui.view">
|
||||||
|
<field name="name">mrp.production.inherited.form.purchase.request</field>
|
||||||
|
<field name="model">mrp.production</field>
|
||||||
|
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//div[@name='button_box']" position="inside">
|
||||||
|
<button class="oe_stat_button" name="action_view_pr_mp" type="object" icon="fa-dollar"
|
||||||
|
attrs="{'invisible': [('pr_mp_count', '=', 0)]}">
|
||||||
|
<div class="o_field_widget o_stat_info">
|
||||||
|
<span class="o_stat_value">
|
||||||
|
<field name="pr_mp_count"/>
|
||||||
|
</span>
|
||||||
|
<span class="o_stat_text">采购申请</span>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user