[FIX] purchase_stock: 'propagate_cancel' check not visible
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/odoo#159940 X-original-commit: c2059c8d2f9d8f6648a577f2dd44360d699f03cf Signed-off-by: Quentin Wolfs (quwo) <quwo@odoo.com> Signed-off-by: Andrea Grazioso (agr) <agr@odoo.com>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -40,3 +41,43 @@ class TestDeleteOrder(PurchaseTestCommon):
|
||||
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, 'confirmed', 'Move state should be recomputed to confimed')
|
||||
|
||||
@@ -58,6 +58,9 @@
|
||||
<xpath expr="//field[@name='order_line']/form//field[@name='analytic_distribution']" position="before">
|
||||
<field name="propagate_cancel" groups="base.group_no_one"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='order_line']/tree//field[@name='analytic_distribution']" 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="column_invisible">parent.state not in ('purchase', 'done')</attribute>
|
||||
<attribute name="readonly">product_type in ('consu', 'product')</attribute>
|
||||
|
||||
Reference in New Issue
Block a user