Skip to content

Commit

Permalink
[ADD] product_configurator_pav_price_formula
Browse files Browse the repository at this point in the history
  • Loading branch information
SirAionTech committed Dec 18, 2024
1 parent 7e91797 commit da71af2
Show file tree
Hide file tree
Showing 13 changed files with 655 additions and 0 deletions.
93 changes: 93 additions & 0 deletions product_configurator_pav_price_formula/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
==============================================================
Product Configurator and Product Attribute value price formula
==============================================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:2e19f1d583cf8c0c59b7eff48a0933eaefa721080dcd56a7b510302c1e23ec4e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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%2Fproduct--configurator-lightgray.png?logo=github
:target: https://github.com/OCA/product-configurator/tree/16.0/product_configurator_pav_price_formula
:alt: OCA/product-configurator
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/product-configurator-16-0/product-configurator-16-0-product_configurator_pav_price_formula
: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/product-configurator&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Bridge module between product configurator and formula for product attribute values.

**Table of contents**

.. contents::
:local:

Usage
=====

A new variable is available in the attribute value's formula:

- `config_session`: the current configuration session.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-configurator/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/product-configurator/issues/new?body=module:%20product_configurator_pav_price_formula%0Aversion:%2016.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
~~~~~~~

* Aion Tech

Contributors
~~~~~~~~~~~~

* `Aion Tech <https://aiontech.company/>`_:

* Simone Rubino <[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.

.. |maintainer-SirAionTech| image:: https://github.com/SirAionTech.png?size=40px
:target: https://github.com/SirAionTech
:alt: SirAionTech

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-SirAionTech|

This module is part of the `OCA/product-configurator <https://github.com/OCA/product-configurator/tree/16.0/product_configurator_pav_price_formula>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions product_configurator_pav_price_formula/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
21 changes: 21 additions & 0 deletions product_configurator_pav_price_formula/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2024 Simone Rubino - Aion Tech
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Product Configurator and Product Attribute value price formula",
"version": "16.0.1.0.0",
"category": "Sales/Sales",
"summary": "Bridge module between product configurator "
"and formula for product attribute values.",
"author": "Aion Tech, Odoo Community Association (OCA)",
"maintainers": [
"SirAionTech",
],
"license": "AGPL-3",
"website": "https://github.com/OCA/product-configurator",
"depends": [
"product_attribute_value_price_formula",
"product_configurator",
],
"auto_install": True,
}
3 changes: 3 additions & 0 deletions product_configurator_pav_price_formula/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import product_config_session
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2024 Simone Rubino - Aion Tech
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, models


class ProductConfigSession(models.Model):
_inherit = "product.config.session"

@api.model
def get_cfg_price(self, value_ids=None, custom_vals=None):
price = super().get_cfg_price(value_ids=value_ids, custom_vals=custom_vals)

if value_ids is None:
value_ids = self.value_ids.ids

product = self.product_id
product_template = self.product_tmpl_id
ptavs = self.env["product.template.attribute.value"].search(
[
("product_attribute_value_id", "in", value_ids),
("product_tmpl_id", "=", product_template.id),
]
)
for ptav in ptavs:
formula_extra_price = ptav._eval_extra_price_formula(
product,
config_session=self,
)
price += formula_extra_price

return price
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Aion Tech <https://aiontech.company/>`_:

* Simone Rubino <[email protected]>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bridge module between product configurator and formula for product attribute values.
3 changes: 3 additions & 0 deletions product_configurator_pav_price_formula/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
A new variable is available in the attribute value's formula:

- `config_session`: the current configuration session.
Loading

0 comments on commit da71af2

Please sign in to comment.