diff --git a/product_attribute_value_menu/README.rst b/product_attribute_value_menu/README.rst index d14b6bb0139..b54d8dbf5dc 100644 --- a/product_attribute_value_menu/README.rst +++ b/product_attribute_value_menu/README.rst @@ -1,6 +1,6 @@ -==================================== -Product Attribute Value Price Import -==================================== +============================ +Product Attribute Value Menu +============================ .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! @@ -25,10 +25,17 @@ Product Attribute Value Price Import |badge1| |badge2| |badge3| |badge4| |badge5| -This module adds a menu item in sales > configuration where user can see/edit all extra -prices set for each attribute value in each product template. +This module adds: -It also allows extra prices to be imported via standard csv/xlsx import. +- A menu item in Sales > Configuration called *Attribute Values Extra Prices* + where user can see/edit all extra prices set for each attribute value in each + product template. It also allows extra prices to be imported via standard + csv/xlsx import. + +- A menu item in Sales and Inventory Applications called *Attribute Values*, + located under the *Attributes*' one. The new menu item contains all the + Attribute Values on a tree view, having the attribute associated with a link + and the value. **Table of contents** @@ -50,6 +57,8 @@ To update values through spreadsheet, it is recommended to: - export records' external ID and relevant fields necessary to work on the spreadsheet (product template, attribute, attribute value, value price extra). - re-import records using only columns External ID and Value price extra. +To acces the attribute value view, simply go to Sales/Inventory > Configuration > Attribute Values. + Bug Tracker =========== @@ -76,6 +85,10 @@ Contributors * Ilyas +* `ForgeFlow `_: + + * Guillem Casassas + Maintainers ~~~~~~~~~~~ diff --git a/product_attribute_value_menu/__manifest__.py b/product_attribute_value_menu/__manifest__.py index 0abe12fbc32..7ef438ed112 100644 --- a/product_attribute_value_menu/__manifest__.py +++ b/product_attribute_value_menu/__manifest__.py @@ -1,13 +1,16 @@ { - "name": "Product Attribute Value Price Import", + "name": "Product Attribute Value Menu", "summary": """Product attributes values tree and form. Import attribute values.""", "version": "14.0.1.0.0", "website": "https://github.com/OCA/product-attribute", "author": "Ilyas, Ooops404, Odoo Community Association (OCA)", "license": "LGPL-3", "category": "Stock", - "depends": ["sale"], - "data": ["views/product_attribute_views.xml"], + "depends": ["sale_stock"], + "data": [ + "views/product_template_attribute_value_views.xml", + "views/product_attribute_value_views.xml", + ], "installable": True, "application": False, } diff --git a/product_attribute_value_menu/models/__init__.py b/product_attribute_value_menu/models/__init__.py index e69de29bb2d..967ba8ab066 100644 --- a/product_attribute_value_menu/models/__init__.py +++ b/product_attribute_value_menu/models/__init__.py @@ -0,0 +1 @@ +from . import product_attribute_value diff --git a/product_attribute_value_menu/models/product_attribute_value.py b/product_attribute_value_menu/models/product_attribute_value.py new file mode 100644 index 00000000000..2d56d4c795a --- /dev/null +++ b/product_attribute_value_menu/models/product_attribute_value.py @@ -0,0 +1,36 @@ +# Copyright 2022 ForgeFlow, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ProductAttributeValue(models.Model): + _inherit = "product.attribute.value" + + product_count = fields.Integer(string="Product", compute="_compute_product_count") + + def _compute_product_count(self): + for value in self: + value.product_count = len(value.pav_attribute_line_ids) + + def action_view_product(self): + action = self.env["ir.actions.act_window"]._for_xml_id( + "product.product_template_action" + ) + products = self.pav_attribute_line_ids.mapped("product_tmpl_id") + + if len(products) > 1: + action["domain"] = [("id", "in", products.ids)] + elif products: + form_view = [ + (self.env.ref("product.product_template_only_form_view").id, "form") + ] + if "views" in action: + action["views"] = form_view + [ + (state, view) for state, view in action["views"] if view != "form" + ] + else: + action["views"] = form_view + action["res_id"] = products.id + action["context"] = self.env.context + return action diff --git a/product_attribute_value_menu/readme/CONTRIBUTORS.rst b/product_attribute_value_menu/readme/CONTRIBUTORS.rst index 371d7a6096a..55156c8b2c7 100644 --- a/product_attribute_value_menu/readme/CONTRIBUTORS.rst +++ b/product_attribute_value_menu/readme/CONTRIBUTORS.rst @@ -1,3 +1,7 @@ * `Ooops404 `_: * Ilyas + +* `ForgeFlow `_: + + * Guillem Casassas diff --git a/product_attribute_value_menu/readme/DESCRIPTION.rst b/product_attribute_value_menu/readme/DESCRIPTION.rst index 8d5608cc434..58b5d633103 100644 --- a/product_attribute_value_menu/readme/DESCRIPTION.rst +++ b/product_attribute_value_menu/readme/DESCRIPTION.rst @@ -1,4 +1,11 @@ -This module adds a menu item in sales > configuration where user can see/edit all extra -prices set for each attribute value in each product template. +This module adds: -It also allows extra prices to be imported via standard csv/xlsx import. +- A menu item in Sales > Configuration called *Attribute Values Extra Prices* + where user can see/edit all extra prices set for each attribute value in each + product template. It also allows extra prices to be imported via standard + csv/xlsx import. + +- A menu item in Sales and Inventory Applications called *Attribute Values*, + located under the *Attributes*' one. The new menu item contains all the + Attribute Values on a tree view, having the attribute associated with a link + and the value. diff --git a/product_attribute_value_menu/readme/USAGE.rst b/product_attribute_value_menu/readme/USAGE.rst index ebc03c98ff2..bf33d6be7fa 100644 --- a/product_attribute_value_menu/readme/USAGE.rst +++ b/product_attribute_value_menu/readme/USAGE.rst @@ -4,3 +4,5 @@ To update values through spreadsheet, it is recommended to: - export records' external ID and relevant fields necessary to work on the spreadsheet (product template, attribute, attribute value, value price extra). - re-import records using only columns External ID and Value price extra. + +To acces the attribute value view, simply go to Sales/Inventory > Configuration > Attribute Values. diff --git a/product_attribute_value_menu/views/product_attribute_value_views.xml b/product_attribute_value_menu/views/product_attribute_value_views.xml new file mode 100644 index 00000000000..69ec69a3de5 --- /dev/null +++ b/product_attribute_value_menu/views/product_attribute_value_views.xml @@ -0,0 +1,71 @@ + + + + + product.attribute.value.tree + product.attribute.value + 1 + + + + + +