Files
odoo_source/addons/mrp/models/mrp_config_settings.py
T
Yannick Tivisse 100f320217 [REF] base/res_config: Deprecate get_default_foo and set_foo
Currently, all the methods that start with `get_default_` and `set_` are called on a res.config.settings loading or saving.

This commit purpose is to replace all the occurences of `get_default_foo` and `set_foo`. As these methods won't be called anymore, a warning is logged to notice its deprecation.

The generic method `get_default_fields` and `set_fields` could be improved too. The method names and API are not so good:

    Why "default" fields? What you ask for is the current value of the stuff, shown as fields in the model. The values are fed as default values in the wizard, but that's an implementation trick.
    Why "fields"? What you ask for are configuration parameters, and such things.
    Why passing a list of fields? Its value is never used.

We should further simplify the API of both methods to something like

def get_values(self):
    return {}

def set_values(self):
    pass
2017-06-19 17:37:38 +02:00

42 lines
1.8 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
class MrpConfigSettings(models.TransientModel):
_name = 'mrp.config.settings'
_inherit = 'res.config.settings'
company_id = fields.Many2one('res.company', string='Company', required=True,
default=lambda self: self.env.user.company_id)
manufacturing_lead = fields.Float(related='company_id.manufacturing_lead', string="Manufacturing Lead Time")
use_manufacturing_lead = fields.Boolean(string="Default Manufacturing Lead Time", oldname='default_use_manufacturing_lead')
group_product_variant = fields.Boolean("Attributes & Variants",
implied_group='product.group_product_variant')
module_mrp_byproduct = fields.Boolean("By-Products")
module_mrp_mps = fields.Boolean("Master Production Schedule")
module_mrp_plm = fields.Boolean("Product Lifecycle Management")
module_mrp_maintenance = fields.Boolean("Maintenance")
module_quality_mrp = fields.Boolean("Quality Control")
group_mrp_routings = fields.Boolean("Work Orders",
implied_group='mrp.group_mrp_routings')
module_mrp_repair = fields.Boolean("Repair")
@api.model
def get_values(self):
res = super(MrpConfigSettings, self).get_values()
res.update(
use_manufacturing_lead=self.env['ir.config_parameter'].sudo().get_param('mrp.use_manufacturing_lead')
)
return res
@api.multi
def set_values(self):
super(MrpConfigSettings, self).set_values()
self.env['ir.config_parameter'].sudo().set_param('mrp.use_manufacturing_lead', self.use_manufacturing_lead)
@api.onchange('use_manufacturing_lead')
def _onchange_use_manufacturing_lead(self):
if not self.use_manufacturing_lead:
self.manufacturing_lead = 0.0