Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][MIG] sale_exception_product_sale_manufactured_for: Migration to 18.0 #3459

Open
wants to merge 8 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions sale_exception_product_sale_manufactured_for/README.rst
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.
3 changes: 3 additions & 0 deletions sale_exception_product_sale_manufactured_for/__init__.py
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 sale_exception_product_sale_manufactured_for/__manifest__.py
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",
],
}
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>
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>
54 changes: 54 additions & 0 deletions sale_exception_product_sale_manufactured_for/i18n/es.po
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."
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 ""
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 sale_exception_product_sale_manufactured_for/models/sale_order.py
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
3 changes: 3 additions & 0 deletions sale_exception_product_sale_manufactured_for/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
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]>\>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**Financial support** \* Cosanum \* Camptocamp R&D
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading