diff --git a/partner_product_price/__init__.py b/partner_product_price/__init__.py new file mode 100644 index 000000000000..0650744f6bc6 --- /dev/null +++ b/partner_product_price/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/partner_product_price/__manifest__.py b/partner_product_price/__manifest__.py new file mode 100644 index 000000000000..c5f85afa97c1 --- /dev/null +++ b/partner_product_price/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2023 Ows - Henrik Norlin +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Contact -> Products with the contact's prices", + "summary": "", + "author": "Ows, Odoo Community Association (OCA)", + "category": "Product", + "data": [ + "data/ir_actions_server.xml", + "views/product_product_views.xml", + ], + "depends": [ + "product", + ], + "development_status": "Alpha", + "license": "AGPL-3", + "maintainers": ["ows-cloud"], + "version": "16.0.1.0.0", + "website": "https://github.com/OCA/product-attribute", +} diff --git a/partner_product_price/data/ir_actions_server.xml b/partner_product_price/data/ir_actions_server.xml new file mode 100644 index 000000000000..80adc9fa3ca8 --- /dev/null +++ b/partner_product_price/data/ir_actions_server.xml @@ -0,0 +1,15 @@ + + + + Products + + + + code + +action = env["ir.actions.actions"]._for_xml_id("product.product_normal_action_sell") +# action["domain"] = [("resource_booking_type_id", "!=", False)] +action["context"] = {'partner_id': record.id} + + + diff --git a/partner_product_price/models/__init__.py b/partner_product_price/models/__init__.py new file mode 100644 index 000000000000..5c74c8c30f1e --- /dev/null +++ b/partner_product_price/models/__init__.py @@ -0,0 +1 @@ +from . import product_product diff --git a/partner_product_price/models/product_product.py b/partner_product_price/models/product_product.py new file mode 100644 index 000000000000..11b567597c09 --- /dev/null +++ b/partner_product_price/models/product_product.py @@ -0,0 +1,26 @@ +from odoo import fields, models + + +class ProductProduct(models.Model): + _inherit = "product.product" + + def _compute_partner_and_price(self): + partner_id = self.env.context.get("partner_id") + partner = self.env["res.partner"].browse(partner_id) + pricelist = None + if partner: + pricelist = partner.property_product_pricelist + + for product in self: + product.partner_id = partner_id + product.partner_price = pricelist._get_product_price(product, quantity=1) + + partner_id = fields.Many2one( + "res.partner", + string="Contact", + compute="_compute_partner_and_price", + ) + partner_price = fields.Float( + "Contact's Price", + compute="_compute_partner_and_price", + ) diff --git a/partner_product_price/readme/CONTRIBUTORS.rst b/partner_product_price/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..76d51685e7a3 --- /dev/null +++ b/partner_product_price/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Henrik Norlin (Ows) diff --git a/partner_product_price/readme/DESCRIPTION.rst b/partner_product_price/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..5d977f59a967 --- /dev/null +++ b/partner_product_price/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module will show products with the pricelist of a contact. diff --git a/partner_product_price/readme/USAGE.rst b/partner_product_price/readme/USAGE.rst new file mode 100644 index 000000000000..0cf5d3166b5e --- /dev/null +++ b/partner_product_price/readme/USAGE.rst @@ -0,0 +1,3 @@ +- Open a contact. +- Click Actions - Products. +- In list view, show the fields **Contact** and **Contact's Price**. diff --git a/partner_product_price/static/description/icon.png b/partner_product_price/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/partner_product_price/static/description/icon.png differ diff --git a/partner_product_price/views/product_product_views.xml b/partner_product_price/views/product_product_views.xml new file mode 100644 index 000000000000..b8b404702e37 --- /dev/null +++ b/partner_product_price/views/product_product_views.xml @@ -0,0 +1,14 @@ + + + + product.product.tree.inherit.partner.product.price + product.product + + + + + + + + +