añade campo warehouse a partner_node

crea un almacén al crea un nuevo nodo si no se define
movido menús al root de network_partner
This commit is contained in:
santiky 2022-04-20 15:51:27 +02:00
parent 72e7b5087e
commit fecbdb7a9c
Signed by: snt
GPG key ID: A9FD34930EADBE71
12 changed files with 73 additions and 88 deletions

View file

@ -18,7 +18,7 @@ No proporciona funcionalidad por sí mismo, se usará luego en otros módulos.
'category': 'Contacts', 'category': 'Contacts',
'version': '12.0.1.0', 'version': '12.0.1.0',
'license': 'AGPL-3', 'license': 'AGPL-3',
'depends': ['base'], 'depends': ['base','stock'],
'data': [ 'data': [
'views/res_partner_views.xml', 'views/res_partner_views.xml',
'views/partner_node_views.xml', 'views/partner_node_views.xml',

View file

@ -11,9 +11,5 @@ class PartnerNetwork(models.Model):
_description = 'A network of nodes.' _description = 'A network of nodes.'
name = fields.Char(string="Nombre", help="El nombre de la red.") name = fields.Char(string="Nombre", help="El nombre de la red.")
#Fields nodes_ids = fields.One2many('partner.node', 'network_id', string="Nodos de la red", help="Los nodos de usuarios finales que conforman la red")
#network_partner_id = fields.Many2one('res.partner', required=True, ondelete='restrict')
#'groups_id': fields.many2many('res.groups', 'res_groups_users_rel', 'uid', 'gid', 'Groups'),
#member_id = fields.Many2many('res.partner', 'res_partner_network_rel', 'uid', 'nid', "Partners" )

View file

@ -8,72 +8,9 @@ from odoo import models, fields, api
class PartnerNode(models.Model): class PartnerNode(models.Model):
_name = 'partner.node' _name = 'partner.node'
_inherit = 'res.partner'
_description = 'A node of partners in a network' _description = 'A node of partners in a network'
network_id = fields.Many2one('network.partner', string="Red", help="La red a la que pertenece el nodo.") name = fields.Char(string="Nombre", help="Cómo se denomina el nodo.")
network_id = fields.Many2one('partner.network', string="Red", help="La red a la que pertenece el nodo.")
partner_ids = fields.One2many('res.partner', 'node_id', string='Contactos del nodo', help='Los contactos asociados a éste nodo.') partner_ids = fields.One2many('res.partner', 'node_id', string='Contactos del nodo', help='Los contactos asociados a éste nodo.')
"""
name = fields.Char(related='partner_id.name', string='Node Name', required=True, store=True, readonly=False)
partner_id = fields.Many2one('res.partner',
string="Contacto asociado",
help="El contacto asociado del nodo con sus datos como la dirección",
required=True
)
#street = fields.Char(compute='_compute_address', inverse='_inverse_street')
#street2 = fields.Char(compute='_compute_address', inverse='_inverse_street2')
#zip = fields.Char(compute='_compute_address', inverse='_inverse_zip')
#city = fields.Char(compute='_compute_address', inverse='_inverse_city')
#state_id = fields.Many2one('res.country.state', compute='_compute_address', inverse='_inverse_state', string="Fed. State")
#country_id = fields.Many2one('res.country', compute='_compute_address', inverse='_inverse_country', string="Country")
street = fields.Char(related='partner_id.street', store=True, readonly=False)
street2 = fields.Char(related='partner_id.street2', store=True, readonly=False)
zip = fields.Char(related='partner_id.zip', store=True, readonly=False)
city = fields.Char(related='partner_id.city', store=True, readonly=False)
#state_id = fields.Char(related='partner_id.state_id', store=True, readonly=False)
#country_id = fields.Char(related='partner_id.country_id', store=True, readonly=False)
email = fields.Char(related='partner_id.email', store=True, readonly=False)
phone = fields.Char(related='partner_id.phone', store=True, readonly=False)
def _get_company_address_fields(self, partner):
return {
'street' : partner.street,
'street2' : partner.street2,
'city' : partner.city,
'zip' : partner.zip,
'state_id' : partner.state_id,
'country_id' : partner.country_id,
}
def _compute_address(self):
for node in self.filtered(lambda node: node.partner_id):
address_data = node.partner_id.sudo().address_get(adr_pref=['contact'])
if address_data['contact']:
partner = node.partner_id.browse(address_data['contact']).sudo()
node.update(node._get_company_address_fields(partner))
def _inverse_street(self):
for company in self:
company.partner_id.street = company.street
def _inverse_street2(self):
for company in self:
company.partner_id.street2 = company.street2
def _inverse_zip(self):
for company in self:
company.partner_id.zip = company.zip
def _inverse_city(self):
for company in self:
company.partner_id.city = company.city
def _inverse_state(self):
for company in self:
company.partner_id.state_id = company.state_id
def _inverse_country(self):
for company in self:
company.partner_id.country_id = company.country_id
"""

View file

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Before After
Before After

View file

@ -4,8 +4,9 @@
<menuitem <menuitem
id="menu_network_partner_root" id="menu_network_partner_root"
name="Redes de Contactos" name="Redes de Contactos"
sequence="1" sequence="5"
groups="group_np_user" groups="group_np_user"
web_icon="network_partner,static/description/icon.png"
/> />
<!-- Submenu --> <!-- Submenu -->
<menuitem id="menu_network_partner_sub" <menuitem id="menu_network_partner_sub"

View file

@ -9,6 +9,7 @@
<form string="Redes"> <form string="Redes">
<group col="4"> <group col="4">
<field name="name"/> <field name="name"/>
<field name="nodes_ids" widget="many2many_tags" />
</group> </group>
</form> </form>
</field> </field>
@ -21,6 +22,7 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="Redes"> <tree string="Redes">
<field name="name"/> <field name="name"/>
<field name="nodes_ids" widget="many2many_tags" />
</tree> </tree>
</field> </field>
</record> </record>

View file

@ -14,8 +14,8 @@
<sheet> <sheet>
<group col="4"> <group col="4">
<field name="name"/> <field name="name"/>
<field name="street"/> <field name="network_id"/>
<field name="partner_ids"/> <field name="partner_ids" widget="many2many_tags"/>
</group> </group>
</sheet> </sheet>
</form> </form>
@ -29,8 +29,8 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="Nodes"> <tree string="Nodes">
<field name="name"/> <field name="name"/>
<field name="partner_ids"/> <field name="network_id"/>
<field name="street"/> <field name="partner_ids" widget="many2many_tags"/>
</tree> </tree>
</field> </field>
</record> </record>

View file

@ -12,8 +12,9 @@ El Usuario que crea la orden es el encargado de distribuir los productos al rest
- cuando se recibe el cargamente del proveedor, una acción permite crear albaranes de entrega a los almacenes dde los nodo - cuando se recibe el cargamente del proveedor, una acción permite crear albaranes de entrega a los almacenes dde los nodo
--> ¿poner en un módulo aparte y quitar la dependencia a network_partner? --> ¿poner en un módulo aparte y quitar la dependencia a network_partner?
- nueva secuencia para collective order purchase - nueva secuencia para collective order purchase
- workflow propio, por añadir los estados de entrega en subalmacén y entrega ala cliente. - workflow propio, por añadir los estados de entrega en subalmacén y entrega al cliente.
- reglas de seguridad y grupos - reglas de seguridad y grupos.
- extiende partner.network añadiendo un nuevo almacén que hace posible el flujo.
""", """,
'author': "Criptomart", 'author': "Criptomart",
'website': "https://criptomart.net", 'website': "https://criptomart.net",
@ -29,6 +30,7 @@ El Usuario que crea la orden es el encargado de distribuir los productos al rest
'views/sale_order.xml', 'views/sale_order.xml',
'views/actions.xml', 'views/actions.xml',
'views/menus.xml', 'views/menus.xml',
'views/partner_node_views.xml',
], ],
'demo': [], 'demo': [],
'installable': True, 'installable': True,

View file

@ -1,3 +1,3 @@
from . import purchase_collective from . import purchase_collective
from . import sale_order from . import sale_order
from . import partner_node

View file

@ -0,0 +1,25 @@
# 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)

View file

@ -1,16 +1,10 @@
<odoo> <odoo>
<data> <data>
<!-- Top menu item -->
<menuitem
id="menu_collective_purchase_root"
name="Collective Purchases"
sequence="50"
/>
<!-- Submenu -->
<menuitem id="menu_purchase_collective_sub" <menuitem id="menu_purchase_collective_sub"
parent="purchase_collective.menu_collective_purchase_root" parent="network_partner.menu_network_partner_root"
name ="Collective Purchases" name ="Collective Purchases"
sequence="5" sequence="20"
/> />
<menuitem action="action_purchase_collective_order_open" <menuitem action="action_purchase_collective_order_open"
id="menu_purchase_collective_order_open" id="menu_purchase_collective_order_open"

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="0">
<record id="view_partner_network_node_inherit_pc_form" model="ir.ui.view">
<field name="name">partner.node.form.wh.view</field>
<field name="model">partner.node</field>
<field name="inherit_id" ref="network_partner.view_partner_network_node_form"/>
<field name="arch" type="xml">
<field name="network_id" position="after">
<field name="wh_id"/>
</field>
</field>
</record>
<record id="view_partner_network_node_inherit_pc_tree" model="ir.ui.view">
<field name="name">partner.node.tree.wh.view</field>
<field name="model">partner.node</field>
<field name="inherit_id" ref="network_partner.view_partner_network_node_tree"/>
<field name="arch" type="xml">
<field name="network_id" position="after">
<field name="wh_id"/>
</field>
</field>
</record>
</data>
</odoo>