[FIX]stock_request_direction: fixed an error while on click on one2many editabe tree on sro request model

This commit is contained in:
Vimal Patel
2021-09-02 15:31:05 +05:30
committed by Freni Patel
parent 8f7de0989c
commit aa31b5c09a
6 changed files with 36 additions and 17 deletions

View File

@@ -0,0 +1 @@
../../../../stock_request_direction

View File

@@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

View File

@@ -4,7 +4,7 @@
{
"name": "Stock Requests Direction",
"summary": "From or to your warehouse?",
"version": "14.0.1.0.0",
"version": "14.0.1.0.1",
"license": "LGPL-3",
"website": "https://github.com/OCA/stock-logistics-warehouse",
"author": "Open Source Integrators, Odoo Community Association (OCA)",

View File

@@ -16,9 +16,10 @@ class StockRequest(models.Model):
@api.onchange("direction")
def _onchange_location_id(self):
if self.direction == "outbound":
# Stock Location set to Partner Locations/Customers
self.location_id = self.company_id.partner_id.property_stock_customer.id
else:
# Otherwise the Stock Location of the Warehouse
self.location_id = self.warehouse_id.lot_stock_id.id
if not self._context.get("default_location_id"):
if self.direction == "outbound":
# Stock Location set to Partner Locations/Customers
self.location_id = self.company_id.partner_id.property_stock_customer.id
else:
# Otherwise the Stock Location of the Warehouse
self.location_id = self.warehouse_id.lot_stock_id.id

View File

@@ -17,7 +17,7 @@
<field name="inherit_id" ref="stock_request.stock_request_order_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='warehouse_id']" position="after">
<field name="direction" required="1" />
<field name="direction" />
</xpath>
<xpath expr="//field[@name='stock_request_ids']" position="attributes">
<attribute name="context">{

View File

@@ -108,18 +108,29 @@ class TestStockRequestOrder(TestStockRequest):
)
)
form = Form(self.env["stock.request.order"])
form.company_id = self.main_company
form.expected_date = expected_date
form.warehouse_id = self.warehouse
form.location_id = self.warehouse.lot_stock_id
form.save()
stock_request_order_obj = self.env["stock.request.order"]
vals = {
"company_id": self.main_company.id,
"expected_date": expected_date,
"warehouse_id": self.warehouse.id,
"location_id": self.warehouse.lot_stock_id.id,
}
stock_request_order_new = stock_request_order_obj.new(vals)
# Test onchange_warehouse_picking_id
form.warehouse_id = wh
form.save()
stock_request_order_new.onchange_warehouse_picking_id()
vals.update(
stock_request_order_new.sudo()._convert_to_write(
{
name: stock_request_order_new[name]
for name in stock_request_order_new._cache
}
)
)
vals.update({"warehouse_id": wh.id})
stock_request_order = stock_request_order_obj.create(vals)
self.assertEqual(form.picking_type_id, new_pick_type)
self.assertEqual(stock_request_order.picking_type_id, new_pick_type)
def test_create(self):
expected_date = fields.Datetime.now()