Skip to content

Commit

Permalink
[FIX] purchase_stock: 'propagate_cancel' check not visible
Browse files Browse the repository at this point in the history
Activate "Reception Report" feature
Create a SO for a storable product, confirm.
Create a PO for the same product.
Confirm the PO and check the delivery, open the "Allocation" report
Assign the Product to the delivery of the SO.
Go back to the PO and cancel the order, delivery of the SO will be cancelled.

Issue: Currently the user cannot modify this behavior as the
`propagate_cancel` checkbox is unaccessible

opw-3733512

closes odoo#158587

Signed-off-by: Quentin Wolfs (quwo) <[email protected]>
  • Loading branch information
agr-odoo committed Mar 28, 2024
1 parent 67da943 commit 91dba73
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
41 changes: 41 additions & 0 deletions addons/purchase_stock/tests/test_purchase_delete_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo.exceptions import UserError
from odoo.fields import Command
from .common import PurchaseTestCommon


Expand Down Expand Up @@ -40,3 +41,43 @@ def test_00_delete_order(self):
purchase_order_3.button_cancel()
self.assertEqual(purchase_order_3.state, 'cancel', 'PO is cancelled!')
purchase_order_3.unlink()

def test_01_delete_propagation(self):
''' Testcase for deleting purchase order with linked move and propagate cancel off'''

partner = self.env['res.partner'].create({'name': 'My Partner'})

stock_location = self.env.ref('stock.warehouse0').out_type_id.default_location_src_id
cust_location = self.env.ref('stock.stock_location_customers')
picking_type_out = self.ref('stock.picking_type_out')
move = self.env['stock.move'].create({
'name': self.product_2.name,
'product_id': self.product_2.id,
'product_uom_qty': 1,
'product_uom': self.product_2.uom_id.id,
'location_id': stock_location.id,
'location_dest_id': cust_location.id,
'picking_type_id': picking_type_out,
})
move._action_confirm()
self.assertEqual(move.state, 'confirmed', 'Move should be confirmed as there is no quantity in stock')

purchase_order = self.env['purchase.order'].create({
'partner_id': partner.id,
'order_line': [
Command.create({
'product_id': self.product_2.id,
'product_qty': 1.0,
'product_uom': self.product_2.uom_id.id,
'propagate_cancel': False,
})],
})
purchase_order.button_confirm()

self.env['report.stock.report_reception'].action_assign(move.ids, [1], purchase_order.order_line.move_ids.ids)
self.assertEqual(move.state, 'waiting', 'Move should be waiting for the linked purchase')
purchase_order.button_cancel()
# Check purchase order and related move are canceled while linked move state is not
self.assertEqual(purchase_order.state, 'cancel', 'Purchase Order should be canceled')
self.assertEqual(purchase_order.order_line.move_ids.state, 'cancel', 'Purchase order move should be canceled')
self.assertEqual(move.state, 'waiting', 'Move should be still waiting')
3 changes: 3 additions & 0 deletions addons/purchase_stock/views/purchase_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
<xpath expr="//field[@name='order_line']/form//field[@name='account_analytic_id']" position="before">
<field name="propagate_cancel" groups="base.group_no_one"/>
</xpath>
<xpath expr="//field[@name='order_line']/tree//field[@name='account_analytic_id']" position="before">
<field name="propagate_cancel" groups="base.group_no_one" optional="hide"/>
</xpath>
<xpath expr="//field[@name='order_line']/tree//field[@name='qty_received']" position="attributes">
<attribute name="attrs">{'column_invisible': [('parent.state', 'not in', ('purchase', 'done'))], 'readonly': [('product_type', 'in', ('consu', 'product'))]}</attribute>
</xpath>
Expand Down

0 comments on commit 91dba73

Please sign in to comment.