取消采购单时,如果该采购单关联的库存移动是由采购申请创建的,则不取消

This commit is contained in:
胡尧
2025-05-23 09:39:38 +08:00
parent 6bf666ac18
commit 1f8e118965
4 changed files with 25 additions and 0 deletions

View File

@@ -14,6 +14,7 @@
'wizard/purchase_request_line_make_purchase_order_view.xml',
'views/purchase_request_line_view.xml',
'views/stock_picking_views.xml',
'views/purchase_request_menu_views.xml',
],
'assets': {
'web.assets_backend': [

View File

@@ -27,4 +27,14 @@ class PurchaseOrder(models.Model):
if reverse_move_ids:
reverse_move_ids.picking_id.action_cancel()
return res
def button_cancel(self):
"""
将取消的采购订单关联的库存移动撤销
"""
move_ids = self.order_line.move_dest_ids.filtered(lambda move: move.state != 'done' and not move.scrapped)
res =super(PurchaseOrder, self).button_cancel()
if move_ids.mapped('created_purchase_request_line_id'):
move_ids.write({'state': 'waiting', 'is_done': False})
return res

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<menuitem id="purchase_request.menu_purchase_request_pro_mgt" sequence="0"/>
<menuitem id="purchase.menu_purchase_rfq" sequence="1"/>
</data>
</odoo>

View File

@@ -7,6 +7,12 @@
<xpath expr="//button[@name='button_draft']" position="attributes">
<attribute name="string">重置草稿</attribute>
</xpath>
<xpath expr="//button[@name='button_done']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//button[@name='%(purchase_request.action_purchase_request_line_make_purchase_order)d']" position="attributes">
<attribute name="class">oe_highlight</attribute>
</xpath>
<xpath expr="//field[@name='line_ids']//field[@name='purchased_qty']" position="after">
<field name="supply_method"/>
</xpath>