crea un almacén al crea un nuevo nodo si no se define movido menús al root de network_partner
25 lines
870 B
Python
25 lines
870 B
Python
# Copyright (C) 2022: Criptomart (<https://criptomart.net/>)
|
|
# @author: Criptomart (<tech@criptomart.net>)
|
|
# 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 PartnerNode(models.Model):
|
|
_inherit = 'partner.node'
|
|
|
|
wh_id = fields.Many2one('stock.warehouse', string="Almacén asociado", help='El almacén donde recibe productos el nodo y los manda a los socios finales.')
|
|
|
|
@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)
|
|
|