Merge PR #1365 into 14.0

Signed-off-by sebalix
This commit is contained in:
OCA-git-bot
2022-02-01 10:49:49 +00:00
4 changed files with 13 additions and 8 deletions

View File

@@ -10,7 +10,8 @@ class ProductTemplate(models.Model):
"""Create an Inventory Adjustment instead of edit directly on quants"""
self.ensure_one()
view_form_id = self.env.ref("stock.view_inventory_form").id
action = self.env.ref("stock.action_inventory_form").sudo().read()[0]
xmlid = "stock.action_inventory_form"
action = self.env["ir.actions.act_window"]._for_xml_id(xmlid)
action.update(
{
"views": [(view_form_id, "form")],
@@ -31,7 +32,8 @@ class ProductProduct(models.Model):
"""Create an Inventory Adjustment instead of edit directly on quants"""
self.ensure_one()
view_form_id = self.env.ref("stock.view_inventory_form").id
action = self.env.ref("stock.action_inventory_form").sudo().read()[0]
xmlid = "stock.action_inventory_form"
action = self.env["ir.actions.act_window"]._for_xml_id(xmlid)
action.update(
{
"views": [(view_form_id, "form")],

View File

@@ -32,13 +32,14 @@ class ProductTemplate(models.Model):
quant_ids = quants.filtered(
lambda x: x.product_id.qty_available_not_res > 0
).ids
result = self.env.ref("stock.group_stock_multi_locations").read()[0]
result["domain"] = [("id", "in", quant_ids)]
result["context"] = {
xmlid = "stock_available_unreserved.product_open_quants_unreserved"
action = self.env["ir.actions.act_window"]._for_xml_id(xmlid)
action["domain"] = [("id", "in", quant_ids)]
action["context"] = {
"search_default_locationgroup": 1,
"search_default_internal_loc": 1,
}
return result
return action
def _search_quantity_unreserved(self, operator, value):
return [("product_variant_ids.qty_available_not_res", operator, value)]

View File

@@ -16,7 +16,8 @@ class AccountAnalyticAccount(models.Model):
def action_view_stock_request(self):
self.ensure_one()
action = self.env.ref("stock_request.action_stock_request_form").read()[0]
xmlid = "stock_request.action_stock_request_form"
action = self.env["ir.actions.act_window"]._for_xml_id(xmlid)
requests = self.mapped("stock_request_ids")
if len(requests) > 1:
action["domain"] = [("id", "in", requests.ids)]

View File

@@ -58,7 +58,8 @@ class StockRequestOrder(models.Model):
raise ValidationError(
_("Analytic type (analytic_type) not present in the context")
)
action = self.env.ref(MAP_ACTIONS[analytic_type]).read()[0]
xmlid = MAP_ACTIONS[analytic_type]
action = self.env["ir.actions.act_window"]._for_xml_id(xmlid)
records = self.mapped(MAP_FIELDS[analytic_type])
if len(records) > 1:
action["domain"] = [("id", "in", records.ids)]