network_partner
This commit is contained in:
parent
cf798a996b
commit
d2ac963ee1
15 changed files with 437 additions and 1 deletions
1
network_partner/__init__.py
Normal file
1
network_partner/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
from . import models
|
||||
35
network_partner/__manifest__.py
Normal file
35
network_partner/__manifest__.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
'name': "Network Partner",
|
||||
'summary': "Makes networks based in nodes of Partners.",
|
||||
'description': """
|
||||
Network partners
|
||||
==================================================
|
||||
Introduce el concepto de "nodo" y "red" en contactos asociados.
|
||||
|
||||
No proporciona funcionalidad por sí mismo, se usará luego en otros módulos.
|
||||
|
||||
- Modelo network
|
||||
- Modelo nodo
|
||||
- Añade campos node_id, is_node a res.partner
|
||||
- Reglas de seguridad y access lists
|
||||
""",
|
||||
'author': 'Criptomart',
|
||||
'website': "https://criptomart.net",
|
||||
'category': 'Contacts',
|
||||
'version': '12.0.1.0',
|
||||
'license': 'AGPL-3',
|
||||
'depends': ['base'],
|
||||
'data': [
|
||||
'views/res_partner_views.xml',
|
||||
'views/partner_node_views.xml',
|
||||
'views/partner_net_views.xml',
|
||||
'security/network_partner_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'views/actions.xml',
|
||||
'views/menus.xml',
|
||||
],
|
||||
'demo': [],
|
||||
'installable': True,
|
||||
'auto_install': False,
|
||||
'application': False,
|
||||
}
|
||||
4
network_partner/models/__init__.py
Normal file
4
network_partner/models/__init__.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
from . import res_partner
|
||||
from . import partner_node
|
||||
from . import partner_network
|
||||
|
||||
19
network_partner/models/partner_network.py
Normal file
19
network_partner/models/partner_network.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#import logging
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
#_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class PartnerNetwork(models.Model):
|
||||
_name = 'partner.network'
|
||||
#_inherit = 'mail.thread'
|
||||
_description = 'A network of nodes.'
|
||||
|
||||
name = fields.Char(string="Nombre", help="El nombre de la red.")
|
||||
#Fields
|
||||
#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" )
|
||||
|
||||
|
||||
79
network_partner/models/partner_node.py
Normal file
79
network_partner/models/partner_node.py
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
#import logging
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
#_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class PartnerNode(models.Model):
|
||||
_name = 'partner.node'
|
||||
_inherit = 'res.partner'
|
||||
_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.")
|
||||
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
|
||||
"""
|
||||
14
network_partner/models/res_partner.py
Normal file
14
network_partner/models/res_partner.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#import logging
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
#_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = 'res.partner'
|
||||
#'users': fields.many2many('res.users', 'res_groups_users_rel', 'gid', 'uid', 'Users'),
|
||||
node_id = fields.Many2one('partner.node', string="Nodo")
|
||||
is_node = fields.Boolean(string="Es un nodo", help="Éste partner representa un nodo en una red.")
|
||||
|
||||
5
network_partner/security/ir.model.access.csv
Normal file
5
network_partner/security/ir.model.access.csv
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_network_partner_node_group_user,network.partner.node.user,network_partner.model_partner_node,network_partner.group_np_user,1,0,0,0
|
||||
access_network_partner_node_group_manager,network.partner.node.manager,network_partner.model_partner_node,network_partner.group_np_manager,1,1,1,1
|
||||
access_network_partner_net_group_user,network.partner.net.user,network_partner.model_partner_network,network_partner.group_np_user,1,0,0,0
|
||||
access_network_partner_net_group_manager,network.partner.net.manager,network_partner.model_partner_network,network_partner.group_np_manager,1,1,1,1
|
||||
|
79
network_partner/security/network_partner_security.xml
Normal file
79
network_partner/security/network_partner_security.xml
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data noupdate="0">
|
||||
|
||||
<record model="ir.module.category" id="module_management">
|
||||
<field name="name">Network Partner module access</field>
|
||||
<field name="description">User access level for this module</field>
|
||||
<field name="sequence">3</field>
|
||||
</record>
|
||||
|
||||
<record id="group_np_user" model="res.groups">
|
||||
<field name="name">User</field>
|
||||
<field name="category_id" ref="network_partner.module_management"/>
|
||||
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="group_np_manager" model="res.groups">
|
||||
<field name="name">Manager</field>
|
||||
<field name="category_id" ref="network_partner.module_management"/>
|
||||
<field name="implied_ids" eval="[(4, ref('network_partner.group_np_user'))]"/>
|
||||
<field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
<data noupdate="1">
|
||||
<record id="base.default_user" model="res.users">
|
||||
<field name="groups_id" eval="[(4,ref('network_partner.group_np_user'))]"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.rule" id="network_partner_node_read_rule">
|
||||
<field name="name">network.partner.node.read.rule</field>
|
||||
<field name="model_id" ref="model_partner_node" />
|
||||
<field name="global" eval="True"/>
|
||||
<field name="domain_force">[(1, '=', 1)]</field>
|
||||
<field name="groups" eval="[(4,ref('network_partner.group_np_user'))]" />
|
||||
<field name="perm_read" eval="True"/>
|
||||
<field name="perm_write" eval="False"/>
|
||||
<field name="perm_unlink" eval="False"/>
|
||||
<field name="perm_create" eval="False"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.rule" id="network_partner_node_write_rule">
|
||||
<field name="name">network.partner.node.write.rule</field>
|
||||
<field name="model_id" ref="model_partner_node" />
|
||||
<field name="global" eval="True"/>
|
||||
<field name="domain_force">[(1, '=', 1)]</field>
|
||||
<field name="groups" eval="[(4,ref('network_partner.group_np_manager'))]" />
|
||||
<field name="perm_read" eval="True"/>
|
||||
<field name="perm_write" eval="True"/>
|
||||
<field name="perm_unlink" eval="True"/>
|
||||
<field name="perm_create" eval="True"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.rule" id="network_partner_net_read_rule">
|
||||
<field name="name">network.partner.net.read.rule</field>
|
||||
<field name="model_id" ref="model_partner_network" />
|
||||
<field name="global" eval="True"/>
|
||||
<field name="domain_force">[(1, '=', 1)]</field>
|
||||
<field name="groups" eval="[(4,ref('network_partner.group_np_user'))]" />
|
||||
<field name="perm_read" eval="True"/>
|
||||
<field name="perm_write" eval="False"/>
|
||||
<field name="perm_unlink" eval="False"/>
|
||||
<field name="perm_create" eval="False"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.rule" id="network_partner_net_write_rule">
|
||||
<field name="name">network.partner.net.write.rule</field>
|
||||
<field name="model_id" ref="model_partner_network" />
|
||||
<field name="global" eval="True"/>
|
||||
<field name="domain_force">[(1, '=', 1)]</field>
|
||||
<field name="groups" eval="[(4,ref('network_partner.group_np_manager'))]" />
|
||||
<field name="perm_read" eval="True"/>
|
||||
<field name="perm_write" eval="True"/>
|
||||
<field name="perm_unlink" eval="True"/>
|
||||
<field name="perm_create" eval="True"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
40
network_partner/views/actions.xml
Normal file
40
network_partner/views/actions.xml
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<odoo>
|
||||
<data>
|
||||
|
||||
<record id="action_partner_network_nets" model="ir.actions.act_window">
|
||||
<field name="name">Networks</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">partner.network</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="context">{ }</field>
|
||||
<field name="help" type="html">
|
||||
<p class="oe_view_nocontent_create">
|
||||
Click to create a new Partner Network.
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_partner_network_nodes" model="ir.actions.act_window">
|
||||
<field name="name">Nodes</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">partner.node</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="context">{ }</field>
|
||||
<field name="help" type="html">
|
||||
<p class="oe_view_nocontent_create">
|
||||
Click to create a new Node.
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_partner_network_view_node_tree" model="ir.actions.act_window.view">
|
||||
<field name="sequence" eval="1"/>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="view_id" ref="network_partner.view_partner_network_node_tree"/>
|
||||
<field name="act_window_id" ref="action_partner_network_nodes"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
32
network_partner/views/menus.xml
Normal file
32
network_partner/views/menus.xml
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<odoo>
|
||||
<data noupdate="0">
|
||||
<!-- Top menu item -->
|
||||
<menuitem
|
||||
id="menu_network_partner_root"
|
||||
name="Redes de Contactos"
|
||||
sequence="1"
|
||||
groups="group_np_user"
|
||||
/>
|
||||
<!-- Submenu -->
|
||||
<menuitem id="menu_network_partner_sub"
|
||||
parent="network_partner.menu_network_partner_root"
|
||||
name ="Redes"
|
||||
sequence="10"
|
||||
groups="group_np_user"
|
||||
/>
|
||||
<!-- nodos -->
|
||||
<menuitem action="network_partner.action_partner_network_nodes"
|
||||
id="menu_partner_networks_nodes"
|
||||
parent="network_partner.menu_network_partner_sub"
|
||||
sequence="10"
|
||||
groups="group_np_user"
|
||||
/>
|
||||
<!-- redes -->
|
||||
<menuitem action="network_partner.action_partner_network_nets"
|
||||
id="menu_partner_network_nets"
|
||||
parent="network_partner.menu_network_partner_sub"
|
||||
sequence="20"
|
||||
groups="group_np_user"
|
||||
/>
|
||||
</data>
|
||||
</odoo>
|
||||
29
network_partner/views/partner_net_views.xml
Normal file
29
network_partner/views/partner_net_views.xml
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<odoo>
|
||||
<data noupdate="0">
|
||||
|
||||
<record id="view_partner_network_net_form" model="ir.ui.view">
|
||||
<field name="name">partner.network.nets.form</field>
|
||||
<field name="model">partner.network</field>
|
||||
<field eval="8" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Redes">
|
||||
<group col="4">
|
||||
<field name="name"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_partner_network_net_tree" model="ir.ui.view">
|
||||
<field name="name">partner.network.nets.tree</field>
|
||||
<field name="model">partner.network</field>
|
||||
<field eval="8" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Redes">
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
40
network_partner/views/partner_node_views.xml
Normal file
40
network_partner/views/partner_node_views.xml
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data noupdate="0">
|
||||
|
||||
<record id="view_partner_network_node_form" model="ir.ui.view">
|
||||
<field name="name">partner.network.node.form</field>
|
||||
<field name="model">partner.node</field>
|
||||
<field name="priority">20</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Node">
|
||||
<header>
|
||||
<p>Soy el header...</p>
|
||||
</header>
|
||||
<sheet>
|
||||
<group col="4">
|
||||
<field name="name"/>
|
||||
<field name="street"/>
|
||||
<field name="partner_ids"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_partner_network_node_tree" model="ir.ui.view">
|
||||
<field name="name">partner.network.node.tree</field>
|
||||
<field name="model">partner.node</field>
|
||||
<field name="priority">10</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Nodes">
|
||||
<field name="name"/>
|
||||
<field name="partner_ids"/>
|
||||
<field name="street"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
24
network_partner/views/res_partner_views.xml
Normal file
24
network_partner/views/res_partner_views.xml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<record id="view_res_partner_network" model="ir.ui.view">
|
||||
<field name="name">Nodo</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||
<field name="priority">2</field>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page[@name='internal_notes']" position="after">
|
||||
<page name="nodes_page"
|
||||
string="Nodes" >
|
||||
<group name="nodes_information_group" >
|
||||
<field name = "is_node"/>
|
||||
<field name = "node_id" />
|
||||
</group>
|
||||
</page>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
34
network_partner/workflow.txt
Normal file
34
network_partner/workflow.txt
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
Order:
|
||||
|
||||
The status of the purchase order or the quotation request. "
|
||||
|
||||
A request for quotation is a purchase order in a 'Draft' status.
|
||||
|
||||
Then the order has to be confirmed by the user responsible , the status switch to 'Confirmed'.
|
||||
|
||||
Then the supplier must confirm the order to change the status to 'Approved'.
|
||||
|
||||
When the purchase order is paid and received, the status becomes 'Done'.
|
||||
|
||||
If a cancel action occurs in the invoice or in the receipt of goods, the status becomes "in exception."
|
||||
|
||||
STATE_SELECTION = [
|
||||
('draft', 'Draft PO'),
|
||||
('sent', 'RFQ'),
|
||||
('bid', 'Bid Received'),
|
||||
('confirmed', 'Waiting Approval'),
|
||||
('approved', 'Purchase Confirmed'),
|
||||
('except_picking', 'Shipping Exception'),
|
||||
('except_invoice', 'Invoice Exception'),
|
||||
('done', 'Done'),
|
||||
('cancel', 'Cancelled')
|
||||
|
||||
Order.Line:
|
||||
|
||||
'state': fields.selection([('draft', 'Draft'), ('confirmed', 'Confirmed'), ('done', 'Done'), ('cancel', 'Cancelled')],
|
||||
'Status', required=True, readonly=True, copy=False,
|
||||
help=' * The \'Draft\' status is set automatically when purchase order in draft status. \
|
||||
\n* The \'Confirmed\' status is set automatically as confirm when purchase order in confirm status. \
|
||||
\n* The \'Done\' status is set automatically when purchase order is set as done. \
|
||||
\n* The \'Cancelled\' status is set automatically when user cancel purchase order.'),
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue