1、询价单的确认按钮权限添加;2、成品调拨单添加对应的坯料采购单和坯料外协单跳转链接

This commit is contained in:
yuxianghui
2024-12-30 17:04:59 +08:00
parent 89d6752012
commit d7ce69f474
3 changed files with 103 additions and 25 deletions

View File

@@ -13,6 +13,74 @@ _logger = logging.getLogger(__name__)
class StockPicking(models.Model):
_inherit = 'stock.picking'
pro_purchase_count = fields.Integer('坯料采购单数量', compute='_compute_pro_purchase_count', store=True)
@api.depends('name')
def _compute_pro_purchase_count(self):
for sp in self:
if sp:
po_ids = self.env['purchase.order'].sudo().search([
('origin', 'like', sp.name), ('purchase_type', '=', 'standard')])
if po_ids:
sp.pro_purchase_count = len(po_ids)
def pro_purchase_order(self):
"""
坯料采购
"""
po_ids = self.env['purchase.order'].sudo().search([
('origin', 'like', self.name), ('purchase_type', '=', 'standard')])
action = {
'res_model': 'purchase.order',
'type': 'ir.actions.act_window',
}
if len(po_ids) == 1:
action.update({
'view_mode': 'form',
'res_id': po_ids.id,
})
else:
action.update({
'name': _("采购订单列表"),
'domain': [('id', 'in', po_ids.ids)],
'view_mode': 'tree,form',
})
return action
pro_out_purchase_count = fields.Integer('坯料外协单数量', compute='_compute_pro_out_purchase_count', store=True)
@api.depends('name')
def _compute_pro_out_purchase_count(self):
for sp in self:
if sp:
po_ids = self.env['purchase.order'].sudo().search([
('origin', 'like', sp.name), ('purchase_type', '=', 'consignment')])
if po_ids:
sp.pro_out_purchase_count = len(po_ids)
def pro_out_purchase_order(self):
"""
坯料外协
"""
po_ids = self.env['purchase.order'].sudo().search([
('origin', 'like', self.name), ('purchase_type', '=', 'consignment')])
action = {
'res_model': 'purchase.order',
'type': 'ir.actions.act_window',
}
if len(po_ids) == 1:
action.update({
'view_mode': 'form',
'res_id': po_ids.id,
})
else:
action.update({
'name': _("外协订单列表"),
'domain': [('id', 'in', po_ids.ids)],
'view_mode': 'tree,form',
})
return action
# 重写验证下发发货到bfm
def button_validate(self):
info = super(StockPicking, self).button_validate()

View File

@@ -1,6 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data>
</data>
<data>
<record id="add_check_out_view_picking_form" model="ir.ui.view">
<field name="name">添加坯料采购单链接</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<xpath expr="//form//sheet//div[@name='button_box']//button[@name='action_picking_move_tree']" position="before">
<button class="oe_stat_button" name="pro_purchase_order" type="object" icon="fa-credit-card"
attrs="{'invisible': [('pro_purchase_count', '=', 0)]}">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value"><field name="pro_purchase_count"/></span>
<span class="o_stat_text">坯料采购</span>
</div>
</button>
<button class="oe_stat_button" name="pro_out_purchase_order" type="object" icon="fa-credit-card"
attrs="{'invisible': [('pro_out_purchase_count', '=', 0)]}">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value"><field name="pro_out_purchase_count"/></span>
<span class="o_stat_text">坯料外协</span>
</div>
</button>
</xpath>
</field>
</record>
</data>
</odoo>