# Copyright (C) 2022: Criptomart () # @author: Criptomart () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). #import logging from odoo import models, fields, api #from odoo.exceptions import ValidationError, Warning #_logger = logging.getLogger(__name__) class PartnerNetwork(models.Model): _inherit = 'partner.network' wh_id = fields.Many2one('stock.warehouse', string="Almacén asociado", help='El almacén central donde recibe productos la red y se redistribuye a los nodos.') @api.model def create(self, vals): if vals.get('wh_id', False) == False: vals['wh_id'] = self.env['stock.warehouse'].create({ 'name': vals.get('name'), 'code': vals.get('name')[4:] }).id return super().create(vals)