From 808e60729f764a232a689e5d5f333aa049c47755 Mon Sep 17 00:00:00 2001 From: santiky Date: Wed, 20 Apr 2022 16:47:24 +0200 Subject: [PATCH] =?UTF-8?q?a=C3=B1adido=20almac=C3=A9n=20central=20en=20pa?= =?UTF-8?q?rtner=5Fnetwork?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- purchase_collective/__manifest__.py | 1 + purchase_collective/models/__init__.py | 1 + purchase_collective/models/partner_network.py | 25 +++++++++++++++++ .../views/partner_net_views.xml | 28 +++++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 purchase_collective/models/partner_network.py create mode 100644 purchase_collective/views/partner_net_views.xml diff --git a/purchase_collective/__manifest__.py b/purchase_collective/__manifest__.py index 64d287a..47c99f6 100644 --- a/purchase_collective/__manifest__.py +++ b/purchase_collective/__manifest__.py @@ -31,6 +31,7 @@ El Usuario que crea la orden es el encargado de distribuir los productos al rest 'views/actions.xml', 'views/menus.xml', 'views/partner_node_views.xml', + 'views/partner_net_views.xml', ], 'demo': [], 'installable': True, diff --git a/purchase_collective/models/__init__.py b/purchase_collective/models/__init__.py index ffc4025..59a30b9 100644 --- a/purchase_collective/models/__init__.py +++ b/purchase_collective/models/__init__.py @@ -1,3 +1,4 @@ from . import purchase_collective from . import sale_order from . import partner_node +from . import partner_network diff --git a/purchase_collective/models/partner_network.py b/purchase_collective/models/partner_network.py new file mode 100644 index 0000000..0fa7f7a --- /dev/null +++ b/purchase_collective/models/partner_network.py @@ -0,0 +1,25 @@ +# 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) + diff --git a/purchase_collective/views/partner_net_views.xml b/purchase_collective/views/partner_net_views.xml new file mode 100644 index 0000000..9c67e3d --- /dev/null +++ b/purchase_collective/views/partner_net_views.xml @@ -0,0 +1,28 @@ + + + + + + partner.net.form.wh.view + partner.network + + + + + + + + + + partner.net.tree.wh.view + partner.network + + + + + + + + + +