-
-
Notifications
You must be signed in to change notification settings - Fork 500
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] website_sale_product_supplierinfo_for_customer
- Loading branch information
Showing
18 changed files
with
857 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...duct_supplierinfo_for_customer/odoo/addons/website_sale_product_supplierinfo_for_customer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../website_sale_product_supplierinfo_for_customer |
6 changes: 6 additions & 0 deletions
6
setup/website_sale_product_supplierinfo_for_customer/setup.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
============================================== | ||
Website Sale Product Supplierinfo for Customer | ||
============================================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:c8511988829b08917f3c2c9564aafb1cb8a7ee921caec1b480aee85bba66c19e | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fe--commerce-lightgray.png?logo=github | ||
:target: https://github.com/OCA/e-commerce/tree/14.0/website_sale_product_supplierinfo_for_customer | ||
:alt: OCA/e-commerce | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/e-commerce-14-0/e-commerce-14-0-website_sale_product_supplierinfo_for_customer | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/e-commerce&target_branch=14.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module reflects supplier info data to website sale portal. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
* Go to Settings -> Website -> Pricing -> Pricelists, | ||
activate: "Advanced price rules (discounts, formulas)" | ||
* Create a pricelist with a rule with option "Based on" | ||
with the value "Partner Prices: Take the price from the customer info on the 'product form')". | ||
|
||
Usage | ||
===== | ||
|
||
There's a section on *Sales* tab of the product form called "Customers", | ||
where you can define records for customers with the same structure of the | ||
suppliers. | ||
|
||
Every supplier info defined there will be reflected in the website sale portal. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/e-commerce/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/e-commerce/issues/new?body=module:%20website_sale_product_supplierinfo_for_customer%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* PyTech SRL | ||
* Ooops404 | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* PyTech SRL <[email protected]> | ||
* Ooops404 <[email protected]> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
This module is part of the `OCA/e-commerce <https://github.com/OCA/e-commerce/tree/14.0/website_sale_product_supplierinfo_for_customer>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import models | ||
from . import controllers |
19 changes: 19 additions & 0 deletions
19
website_sale_product_supplierinfo_for_customer/__manifest__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "Website Sale Product Supplierinfo for Customer", | ||
"version": "14.0.1.0.0", | ||
"depends": [ | ||
"product_supplierinfo_for_customer", | ||
"website_sale", | ||
], | ||
"author": "PyTech SRL, Ooops404, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/e-commerce", | ||
"category": "E-Commerce", | ||
"license": "AGPL-3", | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"templates/product_templates.xml", | ||
], | ||
"demo": [], | ||
"installable": True, | ||
"application": False, | ||
} |
1 change: 1 addition & 0 deletions
1
website_sale_product_supplierinfo_for_customer/controllers/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import main |
35 changes: 35 additions & 0 deletions
35
website_sale_product_supplierinfo_for_customer/controllers/main.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from odoo import http | ||
from odoo.http import request | ||
from odoo.osv import expression | ||
|
||
from odoo.addons.website_sale.controllers.main import WebsiteSale | ||
|
||
|
||
class WebsiteSaleFormSupplierInfo(WebsiteSale): | ||
def _get_search_domain( | ||
self, search, category, attrib_values, search_in_description=True | ||
): | ||
res = super()._get_search_domain( | ||
search, category, attrib_values, search_in_description | ||
) | ||
res = expression.OR( | ||
[ | ||
res, | ||
[ | ||
"&", | ||
("customer_ids.name", "=", request.env.user.partner_id.id), | ||
("customer_ids.product_name", "ilike", search), | ||
], | ||
] | ||
) | ||
return res | ||
|
||
@http.route() | ||
def products_autocomplete(self, term, options=None, **kwargs): | ||
if options is None: | ||
options = {} | ||
res = super().products_autocomplete(term, options, **kwargs) | ||
products = res.get("products", []) | ||
for product in products: | ||
product["name"] = product["display_name"] | ||
return res |
1 change: 1 addition & 0 deletions
1
website_sale_product_supplierinfo_for_customer/models/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import product_template |
78 changes: 78 additions & 0 deletions
78
website_sale_product_supplierinfo_for_customer/models/product_template.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
from odoo import api, fields, models | ||
|
||
|
||
class ProductTemplate(models.Model): | ||
_inherit = "product.template" | ||
|
||
partner_price = fields.Float( | ||
"Partner Price", compute="_compute_partner_price", digits="Product Price" | ||
) | ||
|
||
@api.depends("list_price") | ||
def _compute_partner_price(self): | ||
for template in self: | ||
template.partner_price = ( | ||
template.product_variant_id.price_compute("partner")[ | ||
template.product_variant_id.id | ||
] | ||
or template.list_price | ||
) | ||
|
||
def _get_customerinfo_name(self, partner, product=False): | ||
if self.customer_ids: | ||
if not isinstance(partner, int): | ||
partner = partner.id | ||
if product: | ||
if not isinstance(product, int): | ||
product = product.id | ||
customerinfo_id = self.customer_ids.filtered( | ||
lambda x: x.name.id == partner and x.product_id.id == product | ||
) | ||
else: | ||
customerinfo_id = self.customer_ids.filtered( | ||
lambda x: x.name.id == partner | ||
) | ||
return customerinfo_id[0].product_name if customerinfo_id else False | ||
return False | ||
|
||
def _get_combination_info( | ||
self, | ||
combination=False, | ||
product_id=False, | ||
add_qty=1, | ||
pricelist=False, | ||
parent_combination=False, | ||
only_template=False, | ||
): | ||
new_self = self | ||
if ( | ||
not self.env.context.get("partner") | ||
and not self.env.context.get("partner_id") | ||
and self.env.user.partner_id | ||
): | ||
new_self = self.with_context(partner=self.env.user.partner_id.id) | ||
res = super(ProductTemplate, new_self)._get_combination_info( | ||
combination, | ||
product_id, | ||
add_qty, | ||
pricelist, | ||
parent_combination, | ||
only_template, | ||
) | ||
new_display_name = new_self._get_customerinfo_name( | ||
new_self.env.context.get("partner") | ||
or new_self.env.context.get("partner_id"), | ||
new_self.env.context.get("product_id"), | ||
) | ||
if new_display_name: | ||
res.update(display_name=new_display_name) | ||
return res | ||
|
||
def price_compute(self, price_type, uom=False, currency=False, company=None): | ||
if price_type == "partner" and self.product_variant_count == 1: | ||
price_type = "partner_price" | ||
elif price_type == "partner": | ||
price_type = "list_price" | ||
return super(ProductTemplate, self).price_compute( | ||
price_type, uom, currency, company | ||
) |
4 changes: 4 additions & 0 deletions
4
website_sale_product_supplierinfo_for_customer/readme/CONFIGURE.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
* Go to Settings -> Website -> Pricing -> Pricelists, | ||
activate: "Advanced price rules (discounts, formulas)" | ||
* Create a pricelist with a rule with option "Based on" | ||
with the value "Partner Prices: Take the price from the customer info on the 'product form')". |
2 changes: 2 additions & 0 deletions
2
website_sale_product_supplierinfo_for_customer/readme/CONTRIBUTORS.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* PyTech SRL <[email protected]> | ||
* Ooops404 <[email protected]> |
1 change: 1 addition & 0 deletions
1
website_sale_product_supplierinfo_for_customer/readme/DESCRIPTION.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This module reflects supplier info data to website sale portal. |
5 changes: 5 additions & 0 deletions
5
website_sale_product_supplierinfo_for_customer/readme/USAGE.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
There's a section on *Sales* tab of the product form called "Customers", | ||
where you can define records for customers with the same structure of the | ||
suppliers. | ||
|
||
Every supplier info defined there will be reflected in the website sale portal. |
2 changes: 2 additions & 0 deletions
2
website_sale_product_supplierinfo_for_customer/security/ir.model.access.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_product_customerinfo_public,product.customerinfo.public,product_supplierinfo_for_customer.model_product_customerinfo,,1,0,0,0 |
Oops, something went wrong.