Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions product_attribute_value_menu/README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
====================================
Product Attribute Value Price Import
====================================
============================
Product Attribute Value Menu
============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
Expand All @@ -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**

Expand All @@ -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
===========

Expand All @@ -76,6 +85,10 @@ Contributors

* Ilyas <irazor147@gmail.com>

* `ForgeFlow <http://www.forgeflow.com>`_:

* Guillem Casassas <guillem.casassas@forgeflow.com>

Maintainers
~~~~~~~~~~~

Expand Down
9 changes: 6 additions & 3 deletions product_attribute_value_menu/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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,
}
1 change: 1 addition & 0 deletions product_attribute_value_menu/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import product_attribute_value
36 changes: 36 additions & 0 deletions product_attribute_value_menu/models/product_attribute_value.py
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions product_attribute_value_menu/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* `Ooops404 <https://www.ooops404.com>`_:

* Ilyas <irazor147@gmail.com>

* `ForgeFlow <http://www.forgeflow.com>`_:

* Guillem Casassas <guillem.casassas@forgeflow.com>
13 changes: 10 additions & 3 deletions product_attribute_value_menu/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 2 additions & 0 deletions product_attribute_value_menu/readme/USAGE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2021 ForgeFlow
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="product_attribute_value_tree_view" model="ir.ui.view">
<field name="name">product.attribute.value.tree</field>
<field name="model">product.attribute.value</field>
<field name="priority">1</field>
<field name="arch" type="xml">
<tree string="Attribute Values">
<field name="attribute_id" widget="many2one" />
<field name="name" />
<field
name="product_count"
class="text-right"
string="Products"
attrs="{'invisible': [('product_count', '=', 0)]}"
/>
<button
type="object"
name="action_view_product"
class="btn btn-link text-left"
icon="fa-wrench"
attrs="{'invisible': [('product_count', '=', 0)]}"
/>
</tree>
</field>
</record>

<record id="product_attribute_value_search_view" model="ir.ui.view">
<field name="name">product.attribute.value.search</field>
<field name="model">product.attribute.value</field>
<field name="arch" type="xml">
<search>
<field name="name" />
<field name="attribute_id" />
<group expand="1" string="Group By">
<filter
string="Attribute"
name="attribute"
context="{'group_by':'attribute_id'}"
/>
</group>
</search>
</field>
</record>

<act_window
id="attribute_value_action"
name="Attributes Values"
res_model="product.attribute.value"
view_mode="tree"
/>

<menuitem
id="sale_menu_product_archived_attribute_action"
action="attribute_value_action"
parent="sale.prod_config_main"
groups="product.group_product_variant"
sequence="2"
/>

<menuitem
id="stock_menu_product_archived_attribute_action"
action="attribute_value_action"
parent="stock.menu_product_in_config_stock"
sequence="4"
groups="product.group_product_variant"
/>

</odoo>
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</record>

<record id="import_product_attribute_value_action" model="ir.actions.act_window">
<field name="name">Product Variant Values</field>
<field name="name">Attribute Values Extra Prices</field>
<field name="res_model">product.template.attribute.value</field>
<field name="view_mode">tree,form</field>
<field
Expand All @@ -61,7 +61,7 @@

<menuitem
id="import_product_attribute_value_configuration_action_menu"
name="Product Variant Values"
name="Attribute Values Extra Prices"
parent="sale.prod_config_main"
sequence="1"
groups="product.group_product_variant"
Expand Down