Files
manufacture/mrp_request_bom_structure/models/bom_structure.py
2020-12-28 19:19:17 +01:00

25 lines
944 B
Python
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# © 2020 David BEAL @ Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import json
from odoo import api, models
class ReportBomStructure(models.AbstractModel):
_inherit = "report.mrp.report_bom_structure"
@api.model
def get_html(self, bom_id=False, searchQty=1, searchVariant=False):
"""Set quantity from stored parameter"""
IConf = self.env["ir.config_parameter"].sudo()
param = IConf.get_param("request_bom_structure")
param = json.loads(param)
if self.env.context.get("model") == "mrp.production.request" and searchQty == 1:
# We don't want used stored quantity when we are in an other situation
# to avoid break native behavior
searchQty = param.get(str(self.env.context.get("uid"))) or searchQty
return super().get_html(
bom_id=bom_id, searchQty=searchQty, searchVariant=searchVariant
)