Skip to content

Commit

Permalink
[ADD] sale_product_pack_contract
Browse files Browse the repository at this point in the history
  • Loading branch information
petrus-v committed Jan 23, 2024
1 parent 1fe287c commit c8cafa8
Show file tree
Hide file tree
Showing 17 changed files with 918 additions and 0 deletions.
100 changes: 100 additions & 0 deletions sale_product_pack_contract/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
==========================
Sale Product Pack Contract
==========================

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

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

This module is glue module between *Sale Product Pack* and *Contract*'s modules.

At the moment it mainly prevent to configure pack with weird
configuration that would let user in unexpected situations.

Currently this module support following situation:

* Pack is not a contract with at least one line of the pack is a
contract line, pack must be configured as `pack_type=detailed` and
`pack_component_price=detailed`.

**Table of contents**

.. contents::
:local:

Known issues / Roadmap
======================

* Add more support over different kind of product pack with
contract line

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

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

* Pierre Verkest <pierreverkest84@gmail.com>
*

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

* Pierre Verkest <pierreverkest84@gmail.com>

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-petrus-v| image:: https://github.com/petrus-v.png?size=40px
:target: https://github.com/petrus-v
:alt: petrus-v

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

|maintainer-petrus-v|

This module is part of the `OCA/product-pack <https://github.com/OCA/product-pack/tree/14.0/sale_product_pack_contract>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions sale_product_pack_contract/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
22 changes: 22 additions & 0 deletions sale_product_pack_contract/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2023 Foodles (http://www.foodles.co).
# @author Pierre Verkest <pierreverkest84@gmail.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Sale Product Pack Contract",
"version": "14.0.1.0.0",
"category": "Sales",
"summary": "Glue module between sale product pack and product.",
"website": "https://github.com/OCA/product-pack",
"author": (
"Pierre Verkest <pierreverkest84@gmail.com>, "
"Odoo Community Association (OCA),"
),
"maintainers": ["petrus-v"],
"license": "AGPL-3",
"depends": ["sale_product_pack", "product_contract"],
"data": [],
"demo": [
"demo/product_product_demo.xml",
],
"installable": True,
}
21 changes: 21 additions & 0 deletions sale_product_pack_contract/demo/product_product_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 Foodles (http://www.foodles.co).
@author Pierre Verkest <pierreverkest84@gmail.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<odoo>
<record id="demo_template" model="contract.template">
<field name="name">Maintenance CPU compenent contract template</field>
</record>
<record id="product_pack_cpu_maintenance_component" model="product.product">
<field name="name">Maintenance CPU compenent</field>
<field name="categ_id" ref="product.product_category_4" />
<field name="standard_price">22.5</field>
<field name="list_price">32.75</field>
<field name="type">service</field>
<field name="is_contract" eval="True" />
<field
name="property_contract_template_id"
ref="sale_product_pack_contract.demo_template"
/>
</record>
</odoo>
67 changes: 67 additions & 0 deletions sale_product_pack_contract/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_activity_board
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0+e\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: sale_product_pack_contract
#: model:ir.model.fields,field_description:sale_product_pack_contract.field_product_pack_line__display_name
#: model:ir.model.fields,field_description:sale_product_pack_contract.field_product_product__display_name
msgid "Display Name"
msgstr "Nom d'affichage"

#. module: sale_product_pack_contract
#: model:ir.model.fields,field_description:sale_product_pack_contract.field_product_pack_line__id
#: model:ir.model.fields,field_description:sale_product_pack_contract.field_product_product__id
msgid "ID"
msgstr "ID"

#. module: sale_product_pack_contract
#: model:ir.model.fields,field_description:sale_product_pack_contract.field_product_pack_line____last_update
#: model:ir.model.fields,field_description:sale_product_pack_contract.field_product_product____last_update
msgid "Last Modified on"
msgstr "Dernière modification le"

#. module: sale_product_pack_contract
#: model:product.product,name:sale_product_pack_contract.product_pack_cpu_maintenance_component
#: model:product.template,name:sale_product_pack_contract.product_pack_cpu_maintenance_component_product_template
msgid "Maintenance CPU compenent"
msgstr "Composant: maintenance CPU"

#. module: sale_product_pack_contract
#: model:ir.model,name:sale_product_pack_contract.model_product_product
msgid "Product"
msgstr "Produit"

#. module: sale_product_pack_contract
#: model:ir.model,name:sale_product_pack_contract.model_product_pack_line
msgid "Product pack line"
msgstr "Ligne de composante de pack"

#. module: sale_product_pack_contract
#: code:addons/sale_product_pack_contract/models/product_pack_line.py:0
#, python-format
msgid ""
"This pack '%s' contains components %r that are marked to be contract "
"products. At the moment contract component support only on detailed pack "
"type and detailed component price pack."
msgstr ""
"Ce pack : '%s' contient des composants : %r qui sont marqué comme étant "
"des articles de contrat. Pour le moment les linge de composante de pack "
"sont supportées uniquement sur les pack de type détaillé dont le prix est "
"détaillé sur les lignes de composants."

#. module: sale_product_pack_contract
#: model:product.product,uom_name:sale_product_pack_contract.product_pack_cpu_maintenance_component
#: model:product.template,uom_name:sale_product_pack_contract.product_pack_cpu_maintenance_component_product_template
msgid "Units"
msgstr "Unités"
63 changes: 63 additions & 0 deletions sale_product_pack_contract/i18n/sale_product_pack_contract.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_product_pack_contract
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0+e\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: sale_product_pack_contract
#: model:ir.model.fields,field_description:sale_product_pack_contract.field_product_pack_line__display_name
#: model:ir.model.fields,field_description:sale_product_pack_contract.field_product_product__display_name
msgid "Display Name"
msgstr ""

#. module: sale_product_pack_contract
#: model:ir.model.fields,field_description:sale_product_pack_contract.field_product_pack_line__id
#: model:ir.model.fields,field_description:sale_product_pack_contract.field_product_product__id
msgid "ID"
msgstr ""

#. module: sale_product_pack_contract
#: model:ir.model.fields,field_description:sale_product_pack_contract.field_product_pack_line____last_update
#: model:ir.model.fields,field_description:sale_product_pack_contract.field_product_product____last_update
msgid "Last Modified on"
msgstr ""

#. module: sale_product_pack_contract
#: model:product.product,name:sale_product_pack_contract.product_pack_cpu_maintenance_component
#: model:product.template,name:sale_product_pack_contract.product_pack_cpu_maintenance_component_product_template
msgid "Maintenance CPU compenent"
msgstr ""

#. module: sale_product_pack_contract
#: model:ir.model,name:sale_product_pack_contract.model_product_product
msgid "Product"
msgstr ""

#. module: sale_product_pack_contract
#: model:ir.model,name:sale_product_pack_contract.model_product_pack_line
msgid "Product pack line"
msgstr ""

#. module: sale_product_pack_contract
#: code:addons/sale_product_pack_contract/models/product_pack_line.py:0
#, python-format
msgid ""
"This pack '%s' contains components %r that are marked to be contract "
"products. At the moment contract component support only on detailed pack "
"type and detailed component price pack."
msgstr ""

#. module: sale_product_pack_contract
#: model:product.product,uom_name:sale_product_pack_contract.product_pack_cpu_maintenance_component
#: model:product.template,uom_name:sale_product_pack_contract.product_pack_cpu_maintenance_component_product_template
msgid "Units"
msgstr ""
2 changes: 2 additions & 0 deletions sale_product_pack_contract/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import product_pack_line
from . import product_product
38 changes: 38 additions & 0 deletions sale_product_pack_contract/models/product_pack_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2023 Foodles (http://www.foodles.co).
# @author Pierre Verkest <pierreverkest84@gmail.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import _, api, models
from odoo.exceptions import UserError


class ProductPack(models.Model):
_inherit = "product.pack.line"

@api.constrains(
"parent_product_id",
"product_id",
)
def _check_contract_component(self):
for pack_product, pack_lines in self.group_recordset_by(
lambda pack_line: pack_line.parent_product_id
):
if (
pack_product.pack_type != "detailed"
or pack_product.pack_component_price != "detailed"
):
component_contract_products = pack_lines.filtered(
lambda line: line.product_id.is_contract
)
if component_contract_products.exists():
raise UserError(
_(
"This pack '%s' contains components %r that are marked "
"to be contract products. At the moment contract component "
"support only on detailed pack type and detailed "
"component price pack."
)
% (
pack_product.name,
component_contract_products.mapped("product_id.name"),
)
)
11 changes: 11 additions & 0 deletions sale_product_pack_contract/models/product_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from odoo import api, models


class ProductProduct(models.Model):
_inherit = "product.product"

@api.constrains("pack_type", "pack_component_price")
def _check_contract_component(self):
for product in self:
if product.pack_ok:
product.pack_line_ids._check_contract_component()
1 change: 1 addition & 0 deletions sale_product_pack_contract/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Pierre Verkest <pierreverkest84@gmail.com>
10 changes: 10 additions & 0 deletions sale_product_pack_contract/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
This module is glue module between *Sale Product Pack* and *Contract*'s modules.

At the moment it mainly prevent to configure pack with weird
configuration that would let user in unexpected situations.

Currently this module support following situation:

* Pack is not a contract with at least one line of the pack is a
contract line, pack must be configured as `pack_type=detailed` and
`pack_component_price=detailed`.
2 changes: 2 additions & 0 deletions sale_product_pack_contract/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Add more support over different kind of product pack with
contract line
Loading

0 comments on commit c8cafa8

Please sign in to comment.