[MIG] mrp_usability to v14

This commit is contained in:
Alexis de Lattre
2020-12-03 23:18:48 +01:00
parent 92cf447add
commit 7110f5afcc
9 changed files with 98 additions and 122 deletions

View File

@@ -1,2 +1,2 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import mrp, product
from . import mrp_production
from . import product

View File

@@ -1,4 +1,4 @@
# © 2015-2016 Akretion (http://www.akretion.com)
# Copyright 2015-2020 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
@@ -8,8 +8,8 @@ from odoo import api, models
class MrpProduction(models.Model):
_inherit = 'mrp.production'
_order = 'id desc'
# Method used by the report, inherited in this module
@api.model
def get_stock_move_sold_out_report(self, move):
lines = move.active_move_line_ids

View File

@@ -11,34 +11,30 @@ class ProductTemplate(models.Model):
"""Replace native action `template_open_bom` to distinguish if we will display
only one BoM form or a list of BoMs."""
self.ensure_one()
act_window_xml_id = "mrp.mrp_bom_form_action"
act_window = self.env.ref(act_window_xml_id).read()[0]
if self.bom_count > 1:
act_window["context"] = {
"default_product_tmpl_id": self.id,
"search_default_product_tmpl_id": self.id,
}
if self.bom_count == 1:
action = self.env.ref("mrp.mrp_bom_form_action").read()[0]
bom = self.env["mrp.bom"].search([("product_tmpl_id", "=", self.id)])
action.update({
"context": {"default_product_tmpl_id": self.id},
"views": False,
"view_mode": "form,tree",
"res_id": bom.id,
})
else:
act_window["context"] = {"default_product_tmpl_id": self.id}
act_window["views"] = [(self.env.ref("mrp.mrp_bom_form_view").id, "form")]
act_window["res_id"] = (
self.env["mrp.bom"].search([("product_tmpl_id", "=", self.id)]).id
)
return act_window
action = self.env.ref("mrp.template_open_bom").read()[0]
return action
class ProductProduct(models.Model):
_inherit = "product.product"
def action_view_bom(self):
res = super().action_view_bom()
bom_target_ids = self.env["mrp.bom"].search(res["domain"])
action = super().action_view_bom()
bom_target_ids = self.env["mrp.bom"].search(action["domain"])
if len(bom_target_ids) == 1:
res["views"] = [(self.env.ref("mrp.mrp_bom_form_view").id, "form")]
res["res_id"] = bom_target_ids[0].id
return res
action.update({
"views": False,
"view_mode": "form,tree",
"res_id": bom_target_ids[0].id,
})
return action