-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by simahawk
- Loading branch information
Showing
17 changed files
with
829 additions
and
0 deletions.
There are no files selected for viewing
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,92 @@ | ||
================================================ | ||
Sale Exception Product Manufactured for Customer | ||
================================================ | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:085a2fb87bda20031af7ba0a11403b34b0c473e63a33c0f9d6081b99e190defc | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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%2Fsale--workflow-lightgray.png?logo=github | ||
:target: https://github.com/OCA/sale-workflow/tree/18.0/sale_exception_product_sale_manufactured_for | ||
:alt: OCA/sale-workflow | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/sale-workflow-18-0/sale-workflow-18-0-sale_exception_product_sale_manufactured_for | ||
: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/sale-workflow&target_branch=18.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
The partner set in the sales order can order only if he/she has a | ||
commercial entity that is listed as one of the partners for which the | ||
products can be manufactured for. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/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/sale-workflow/issues/new?body=module:%20sale_exception_product_sale_manufactured_for%0Aversion:%2018.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 | ||
------- | ||
|
||
* Camptocamp | ||
|
||
Contributors | ||
------------ | ||
|
||
- `Camptocamp <https://www.camptocamp.com>`__: | ||
|
||
- Carlos Serra-Toro <[email protected]> | ||
- Simone Orsi <[email protected]> | ||
- Thierry Ducrest <[email protected]> | ||
|
||
- `Trobz <https://trobz.com>`__: | ||
|
||
- Son Ho <[email protected]> | ||
- Nhan Tran <[email protected]> | ||
|
||
Other credits | ||
------------- | ||
|
||
**Financial support** \* Cosanum \* Camptocamp R&D | ||
|
||
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/sale-workflow <https://github.com/OCA/sale-workflow/tree/18.0/sale_exception_product_sale_manufactured_for>`_ 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,3 @@ | ||
# Copyright 2021 Camptocamp SA | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) | ||
from . import models |
25 changes: 25 additions & 0 deletions
25
sale_exception_product_sale_manufactured_for/__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,25 @@ | ||
# Copyright 2021 Camptocamp SA | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) | ||
{ | ||
"name": "Sale Exception Product Manufactured for Customer", | ||
"summary": "The partner set in the sales order can order only if he/she " | ||
"has a commercial entity that is listed as one of the partners " | ||
"for which the products can be manufactured for.", | ||
"version": "18.0.1.0.0", | ||
"category": "Sales", | ||
"website": "https://github.com/OCA/sale-workflow", | ||
"author": "Camptocamp, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"application": False, | ||
"installable": True, | ||
"data": [ | ||
"data/exception_rule.xml", | ||
], | ||
"demo": [ | ||
"demo/exception_rule.xml", | ||
], | ||
"depends": [ | ||
"sale_exception", | ||
"product_sale_manufactured_for", | ||
], | ||
} |
15 changes: 15 additions & 0 deletions
15
sale_exception_product_sale_manufactured_for/data/exception_rule.xml
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,15 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<odoo> | ||
<record id="exception_partner_can_order" model="exception.rule"> | ||
<field name="name">Partner can order all the items in the sale</field> | ||
<field name="description">The partner set in the sales order can order only | ||
if he/she has a commercial entity that is listed as one of the partners | ||
for which the products can be manufactured for.</field> | ||
<field name="sequence">50</field> | ||
<field name="model">sale.order</field> | ||
<field | ||
name="code" | ||
>failed = not obj.exception_partner_can_order_manufactured_for()</field> | ||
<field name="is_blocking">True</field> | ||
</record> | ||
</odoo> |
6 changes: 6 additions & 0 deletions
6
sale_exception_product_sale_manufactured_for/demo/exception_rule.xml
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 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<odoo> | ||
<record id="exception_partner_can_order" model="exception.rule"> | ||
<field name="active" eval="False" /> | ||
</record> | ||
</odoo> |
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,54 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * sale_exception_product_sale_manufactured_for | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"PO-Revision-Date: 2024-01-17 18:35+0000\n" | ||
"Last-Translator: Ivorra78 <[email protected]>\n" | ||
"Language-Team: none\n" | ||
"Language: es\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: nplurals=2; plural=n != 1;\n" | ||
"X-Generator: Weblate 4.17\n" | ||
|
||
#. module: sale_exception_product_sale_manufactured_for | ||
#: model:ir.model.fields,field_description:sale_exception_product_sale_manufactured_for.field_sale_order__display_name | ||
msgid "Display Name" | ||
msgstr "Mostrar Nombre" | ||
|
||
#. module: sale_exception_product_sale_manufactured_for | ||
#: model:ir.model.fields,field_description:sale_exception_product_sale_manufactured_for.field_sale_order__id | ||
msgid "ID" | ||
msgstr "ID" | ||
|
||
#. module: sale_exception_product_sale_manufactured_for | ||
#: model:ir.model.fields,field_description:sale_exception_product_sale_manufactured_for.field_sale_order____last_update | ||
msgid "Last Modified on" | ||
msgstr "Última Modificación el" | ||
|
||
#. module: sale_exception_product_sale_manufactured_for | ||
#: model:exception.rule,name:sale_exception_product_sale_manufactured_for.exception_partner_can_order | ||
msgid "Partner can order all the items in the sale" | ||
msgstr "Los socios pueden pedir todos los artículos de la oferta" | ||
|
||
#. module: sale_exception_product_sale_manufactured_for | ||
#: model:ir.model,name:sale_exception_product_sale_manufactured_for.model_sale_order | ||
msgid "Sales Order" | ||
msgstr "Orden de Ventas" | ||
|
||
#. module: sale_exception_product_sale_manufactured_for | ||
#: model:exception.rule,description:sale_exception_product_sale_manufactured_for.exception_partner_can_order | ||
msgid "" | ||
"The partner set in the sales order can order only\n" | ||
" if he/she has a commercial entity that is listed as one of the partners\n" | ||
" for which the products can be manufactured for." | ||
msgstr "" | ||
"El socio establecido en el pedido de venta sólo puede realizar pedidos\n" | ||
" si tiene una entidad comercial que figura como uno de los " | ||
"socios\n" | ||
" para los que se pueden fabricar los productos." |
47 changes: 47 additions & 0 deletions
47
...ption_product_sale_manufactured_for/i18n/sale_exception_product_sale_manufactured_for.pot
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,47 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * sale_exception_product_sale_manufactured_for | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\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_exception_product_sale_manufactured_for | ||
#: model:ir.model.fields,field_description:sale_exception_product_sale_manufactured_for.field_sale_order__display_name | ||
msgid "Display Name" | ||
msgstr "" | ||
|
||
#. module: sale_exception_product_sale_manufactured_for | ||
#: model:ir.model.fields,field_description:sale_exception_product_sale_manufactured_for.field_sale_order__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: sale_exception_product_sale_manufactured_for | ||
#: model:ir.model.fields,field_description:sale_exception_product_sale_manufactured_for.field_sale_order____last_update | ||
msgid "Last Modified on" | ||
msgstr "" | ||
|
||
#. module: sale_exception_product_sale_manufactured_for | ||
#: model:exception.rule,name:sale_exception_product_sale_manufactured_for.exception_partner_can_order | ||
msgid "Partner can order all the items in the sale" | ||
msgstr "" | ||
|
||
#. module: sale_exception_product_sale_manufactured_for | ||
#: model:ir.model,name:sale_exception_product_sale_manufactured_for.model_sale_order | ||
msgid "Sales Order" | ||
msgstr "" | ||
|
||
#. module: sale_exception_product_sale_manufactured_for | ||
#: model:exception.rule,description:sale_exception_product_sale_manufactured_for.exception_partner_can_order | ||
msgid "" | ||
"The partner set in the sales order can order only\n" | ||
" if he/she has a commercial entity that is listed as one of the partners\n" | ||
" for which the products can be manufactured for." | ||
msgstr "" |
3 changes: 3 additions & 0 deletions
3
sale_exception_product_sale_manufactured_for/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,3 @@ | ||
# Copyright 2021 Camptocamp SA | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) | ||
from . import sale_order |
49 changes: 49 additions & 0 deletions
49
sale_exception_product_sale_manufactured_for/models/sale_order.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,49 @@ | ||
# Copyright 2021 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
from odoo import models | ||
from odoo.tools import SQL | ||
|
||
|
||
class SaleOrder(models.Model): | ||
_inherit = "sale.order" | ||
|
||
def exception_partner_can_order_manufactured_for(self): | ||
"""Return whether the partner can order all the items in the sale | ||
Used in a sales exception. Returns true only if the partner set in | ||
the sales order can buy all the products. This will happen if: | ||
1. it has a commercial entity that is listed as one of the | ||
partners for which the products can be manufactured for. | ||
2. it doesn't have a commercial entity and none of the products | ||
on the sale order have any restriction. | ||
""" | ||
self.ensure_one() | ||
commercial_entity = self.partner_id.commercial_partner_id | ||
|
||
self.env.cr.execute( | ||
SQL( | ||
""" | ||
SELECT rel.product_id, ARRAY_AGG(rel.partner_id) | ||
FROM sale_order_line sol | ||
JOIN product_product prod ON (sol.product_id = prod.id) | ||
JOIN product_product_manuf_for_partner_rel rel | ||
ON (rel.product_id = prod.id) | ||
WHERE sol.display_type IS NULL | ||
AND sol.order_id = %s | ||
GROUP BY rel.product_id | ||
""", | ||
(self.id,), | ||
), | ||
) | ||
for _, allowed_partner_ids in self.env.cr.fetchall(): | ||
# The product has limitations but the partner doesn't have | ||
# a commercial entity, thus the condition is not fulfilled. | ||
if not commercial_entity and allowed_partner_ids: | ||
return False | ||
|
||
# The product has limitations and the commercial entity of | ||
# the partner partner is not listed as allowed. | ||
elif commercial_entity.id not in allowed_partner_ids: | ||
return False | ||
|
||
return 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,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |
8 changes: 8 additions & 0 deletions
8
sale_exception_product_sale_manufactured_for/readme/CONTRIBUTORS.md
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,8 @@ | ||
- [Camptocamp](https://www.camptocamp.com): | ||
- Carlos Serra-Toro \<<[email protected]>\> | ||
- Simone Orsi \<<[email protected]>\> | ||
- Thierry Ducrest \<<[email protected]>\> | ||
|
||
- [Trobz](https://trobz.com): | ||
- Son Ho \<<[email protected]>\> | ||
- Nhan Tran \<<[email protected]>\> |
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 @@ | ||
**Financial support** \* Cosanum \* Camptocamp R&D |
3 changes: 3 additions & 0 deletions
3
sale_exception_product_sale_manufactured_for/readme/DESCRIPTION.md
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,3 @@ | ||
The partner set in the sales order can order only if he/she has a | ||
commercial entity that is listed as one of the partners for which the | ||
products can be manufactured for. |
Binary file added
BIN
+9.23 KB
sale_exception_product_sale_manufactured_for/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.
Oops, something went wrong.