[MIG] partner_products_shortcut from v10 to v14
This commit is contained in:
1
partner_products_shortcut/__init__.py
Normal file
1
partner_products_shortcut/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import res_partner
|
||||
27
partner_products_shortcut/__manifest__.py
Normal file
27
partner_products_shortcut/__manifest__.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# Copyright 2014-2024 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
'name': 'Partner Product Shortcut',
|
||||
'version': '14.0.1.0.0',
|
||||
'category': 'Contact Management',
|
||||
'license': 'AGPL-3',
|
||||
'summary': 'Adds a shortcut on partner form to the products supplied by this partner',
|
||||
'description': """
|
||||
Partner Product Shortcut
|
||||
========================
|
||||
|
||||
Adds a smartbutton on partner form to the products supplied by this partner.
|
||||
|
||||
This is an alternative to the OCA module `partner_supplierinfo_smartbutton <https://github.com/OCA/purchase-workflow/tree/14.0/partner_supplierinfo_smartbutton>`_ which adds a smartbutton on partner form to links to the related product.supplierinfo (and not to product.template like in this module).
|
||||
|
||||
This module has been written by Alexis de Lattre from Akretion
|
||||
<alexis.delattre@akretion.com>.
|
||||
""",
|
||||
'author': 'Akretion',
|
||||
'website': 'https://github.com/akretion/odoo-usability',
|
||||
'depends': ['product'],
|
||||
'data': ['res_partner_view.xml'],
|
||||
'installable': True,
|
||||
}
|
||||
38
partner_products_shortcut/res_partner.py
Normal file
38
partner_products_shortcut/res_partner.py
Normal file
@@ -0,0 +1,38 @@
|
||||
# Copyright 2014-2024 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, fields, _
|
||||
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = 'res.partner'
|
||||
|
||||
def _product_supplied_count(self):
|
||||
for partner in self:
|
||||
count = 0
|
||||
sellers = self.env['product.supplierinfo'].search(
|
||||
[('name', '=', partner.id)])
|
||||
if sellers:
|
||||
count = self.env['product.template'].search_count(
|
||||
[('seller_ids', 'in', sellers.ids)])
|
||||
partner.product_supplied_count = count
|
||||
|
||||
product_supplied_count = fields.Integer(
|
||||
compute='_product_supplied_count', string="# of Products Supplied",
|
||||
)
|
||||
|
||||
def show_supplied_products(self):
|
||||
self.ensure_one()
|
||||
sellers = self.env['product.supplierinfo'].search(
|
||||
[('name', '=', self.id)])
|
||||
ptemplates = self.env['product.template'].search(
|
||||
[('seller_ids', 'in', sellers.ids)])
|
||||
action = {
|
||||
'name': _('Products'),
|
||||
'type': "ir.actions.act_window",
|
||||
"res_model": "product.template",
|
||||
"view_mode": 'tree,kanban,form',
|
||||
'domain': f"[('id', 'in', {ptemplates.ids})]",
|
||||
}
|
||||
return action
|
||||
27
partner_products_shortcut/res_partner_view.xml
Normal file
27
partner_products_shortcut/res_partner_view.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2014-2024 Akretion (http://www.akretion.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
<record id="view_partner_form" model="ir.ui.view">
|
||||
<field name="name">add.shortcut.to.product.variants.partner.form</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<div name="button_box" position="inside">
|
||||
<button class="oe_inline oe_stat_button" type="object"
|
||||
name="show_supplied_products"
|
||||
icon="fa-shopping-basket"
|
||||
attrs="{'invisible': [('product_supplied_count', '=', 0)]}">
|
||||
<field string="Products Supplied" name="product_supplied_count"
|
||||
widget="statinfo"/>
|
||||
</button>
|
||||
</div>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
BIN
partner_products_shortcut/static/description/icon.png
Normal file
BIN
partner_products_shortcut/static/description/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
Reference in New Issue
Block a user