Skip to content

Commit

Permalink
[ADD] partner_product_price
Browse files Browse the repository at this point in the history
  • Loading branch information
norlinhenrik committed Aug 30, 2023
1 parent aceecc9 commit cdb6dc6
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions partner_product_price/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
21 changes: 21 additions & 0 deletions partner_product_price/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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",
}
15 changes: 15 additions & 0 deletions partner_product_price/data/ir_actions_server.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="action_product_price_list_report" model="ir.actions.server">
<field name="name">Products</field>
<field name="groups_id" eval="[(4, ref('resource_booking.group_user'))]" />
<field name="model_id" ref="base.model_res_partner" />
<field name="binding_model_id" ref="base.model_res_partner" />
<field name="state">code</field>
<field name="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}
</field>
</record>
</odoo>
1 change: 1 addition & 0 deletions partner_product_price/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import product_product
26 changes: 26 additions & 0 deletions partner_product_price/models/product_product.py
Original file line number Diff line number Diff line change
@@ -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",
)
1 change: 1 addition & 0 deletions partner_product_price/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Henrik Norlin (Ows)
1 change: 1 addition & 0 deletions partner_product_price/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module will show products with the pricelist of a contact.
3 changes: 3 additions & 0 deletions partner_product_price/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Open a contact.
- Click Actions - Products.
- In list view, show the fields **Contact** and **Contact's Price**.
Binary file added partner_product_price/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions partner_product_price/views/product_product_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="product_product_tree_view" model="ir.ui.view">
<field name="name">product.product.tree.inherit.partner.product.price</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_product_tree_view" />
<field name="arch" type="xml">
<tree position="inside">
<field name="partner_id" optional="hide" />
<field name="partner_price" optional="hide" />
</tree>
</field>
</record>
</odoo>

0 comments on commit cdb6dc6

Please sign in to comment.