-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
[16.0] [MIG] sale_operating_unit #600
Open
Borruso
wants to merge
34
commits into
OCA:16.0
Choose a base branch
from
Borruso:16.0-mig-sale_operating_unit
base: 16.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
3559aae
Migrated sale_operating_unit module and its test cases.
sudhir-serpentcs d390fb6
Added OU and WH constraints in SO.
sudhir-serpentcs dd3aec9
migrate code to v9 (wip)
AaronHForgeFlow 704248e
[MIG] sale_operating_unit: Migrated to 10.0
AaronHForgeFlow d669c15
[FIX] readonly on OU
serpentcs-dev1 3b87cab
[MIG] sale_operating_unit: Migration to v11
bjeficent b52bc25
[ADD] icon.png
OCA-git-bot 8587b75
[UPD] README.rst
OCA-git-bot b2dc076
[MIG]sale_operating_unit to v12
bjeficent 7adfd3a
[IMP]sale advance payment to include the OU
AaronHForgeFlow 79c991b
[UPD] Update sale_operating_unit.pot
oca-travis 58d962c
[UPD] README.rst
OCA-git-bot c849612
[FIX] Delete uncalled file
MiquelRForgeFlow a56ea23
[UPD] Update sale_operating_unit.pot
oca-travis 6a010c9
sale_operating_unit 12.0.1.0.1
OCA-git-bot bc7058a
[IMP] sale_operating_unit: black, isort
alan196 9347385
[MIG] sale_operating_unit: Migration to V13
alan196 a5ba9a7
[UPD] Update sale_operating_unit.pot
oca-travis cb78e06
[UPD] Eficent -> ForgeFlow
MiquelRForgeFlow eb57b3f
[UPD] README.rst
OCA-git-bot b769afb
[MIG] sale_operating_unit: Migration to 14.0
olveracuenca a1ed7cc
[UPD] README.rst
OCA-git-bot b5a2215
[UPD] Update sale_operating_unit.pot
d3bbc75
[FIX] Error sale report to add fiel operating unit
cramosh 2fef895
[FIX] 14.0 sale_operating_unit Error sale report to add field operati…
cramosh 56929b9
[UPD] README.rst
OCA-git-bot d175f80
sale_operating_unit 14.0.1.0.1
OCA-git-bot 66e2846
[FIX] sale_operating_unit: make operating_unit_id field in sale.order…
alan196 89f637e
[15.0][MIG] sale_operating_unit: Migration to 15.0
78a10f4
[UPD] Update sale_operating_unit.pot
bc9770f
[UPD] README.rst
OCA-git-bot d78a946
[IMP] sale_operating_unit: pre-commit stuff
Borruso 2f693bd
[MIG] sale_operating_unit: Migration to 16.0
Borruso 80fe82d
[IMP] sale_operating_unit: allowed to hide operating_unit_id in list …
alexeirivera87 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,105 @@ | ||
======================= | ||
Operating Unit in Sales | ||
======================= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:dda84076d9ffa732648bf2edae5480a5da3510410a0073b83a213b8bd707c2da | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
.. |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-LGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html | ||
:alt: License: LGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github | ||
:target: https://github.com/OCA/operating-unit/tree/16.0/sale_operating_unit | ||
:alt: OCA/operating-unit | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/operating-unit-16-0/operating-unit-16-0-sale_operating_unit | ||
: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/operating-unit&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module extends the Sales capabilities of Odoo and introduces the operating | ||
unit to the Sales Order. Security rules are defined to ensure that users can | ||
only display the Sales Orders in which they are allowed access to. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
Follow these steps: | ||
|
||
#. Create a Sale Order. | ||
#. The Operating Unit of the Sale Team is assigned to the Sale Order. | ||
|
||
Known issues / Roadmap | ||
====================== | ||
|
||
The onchange_team_id method is not working. | ||
If you try to change the team in a sales quotation and the operating unit | ||
is not taken from the sales team, and moreover, I cannot select the operating unit | ||
from the team, only Main OU shows, must have to have your salesperson in the sales team | ||
of the operating unit. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/operating-unit/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/operating-unit/issues/new?body=module:%20sale_operating_unit%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 | ||
~~~~~~~ | ||
|
||
* ForgeFlow | ||
* Serpent Consulting Services Pvt. Ltd. | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Jordi Ballester Alomar <[email protected]> | ||
* Aaron Henriquez <[email protected]> | ||
* Lois Rilo <[email protected]> | ||
* Miquel Raich <[email protected]> | ||
* Sudhir Arya <[email protected]> | ||
* Darshan Patel <[email protected]> | ||
* Alan Ramos <[email protected]> | ||
* Jorge Alberto Olvera Cuenca <[email protected]> | ||
* Alejandro Padrón <[email protected]> | ||
* Alexei Rivera <[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/operating-unit <https://github.com/OCA/operating-unit/tree/16.0/sale_operating_unit>`_ 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,5 @@ | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
|
||
from . import models | ||
from . import report | ||
from . import wizard |
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,23 @@ | ||
# © 2019 ForgeFlow S.L. | ||
# - Jordi Ballester Alomar | ||
# © 2019 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
{ | ||
"name": "Operating Unit in Sales", | ||
"version": "16.0.1.0.0", | ||
"summary": "An operating unit (OU) is an organizational entity part of a " | ||
"company", | ||
"author": "ForgeFlow, " | ||
"Serpent Consulting Services Pvt. Ltd.," | ||
"Odoo Community Association (OCA)", | ||
"license": "LGPL-3", | ||
"website": "https://github.com/OCA/operating-unit", | ||
"category": "Sales Management", | ||
"depends": ["sale", "account_operating_unit", "sales_team_operating_unit"], | ||
"data": [ | ||
"security/sale_security.xml", | ||
"views/sale_view.xml", | ||
"views/sale_report_view.xml", | ||
], | ||
"installable": 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,72 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * sale_operating_unit | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 15.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_operating_unit | ||
#: code:addons/sale_operating_unit/models/crm_team.py:0 | ||
#, python-format | ||
msgid "" | ||
"Configuration error. It is not possible to change this team. There are sale " | ||
"orders referencing it in other operating units" | ||
msgstr "" | ||
|
||
#. module: sale_operating_unit | ||
#: code:addons/sale_operating_unit/models/sale_order.py:0 | ||
#, python-format | ||
msgid "" | ||
"Configuration error. The Company in the Sales Order and in the Operating " | ||
"Unit must be the same." | ||
msgstr "" | ||
|
||
#. module: sale_operating_unit | ||
#: code:addons/sale_operating_unit/models/sale_order.py:0 | ||
#, python-format | ||
msgid "" | ||
"Configuration error. The Operating Unit of the sales team must match with " | ||
"that of the quote/sales order." | ||
msgstr "" | ||
|
||
#. module: sale_operating_unit | ||
#: model:ir.model.fields,field_description:sale_operating_unit.field_sale_order__operating_unit_id | ||
#: model:ir.model.fields,field_description:sale_operating_unit.field_sale_order_line__operating_unit_id | ||
#: model:ir.model.fields,field_description:sale_operating_unit.field_sale_report__operating_unit_id | ||
#: model_terms:ir.ui.view,arch_db:sale_operating_unit.view_sale_report_search | ||
#: model_terms:ir.ui.view,arch_db:sale_operating_unit.view_sales_order_filter | ||
msgid "Operating Unit" | ||
msgstr "" | ||
|
||
#. module: sale_operating_unit | ||
#: model:ir.model,name:sale_operating_unit.model_sale_advance_payment_inv | ||
msgid "Sales Advance Payment Invoice" | ||
msgstr "" | ||
|
||
#. module: sale_operating_unit | ||
#: model:ir.model,name:sale_operating_unit.model_sale_report | ||
msgid "Sales Analysis Report" | ||
msgstr "" | ||
|
||
#. module: sale_operating_unit | ||
#: model:ir.model,name:sale_operating_unit.model_sale_order | ||
msgid "Sales Order" | ||
msgstr "" | ||
|
||
#. module: sale_operating_unit | ||
#: model:ir.model,name:sale_operating_unit.model_sale_order_line | ||
msgid "Sales Order Line" | ||
msgstr "" | ||
|
||
#. module: sale_operating_unit | ||
#: model:ir.model,name:sale_operating_unit.model_crm_team | ||
msgid "Sales Team" | ||
msgstr "" |
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 @@ | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
|
||
from . import crm_team | ||
from . import sale_order |
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,34 @@ | ||
# © 2019 ForgeFlow S.L. | ||
# - Jordi Ballester Alomar | ||
# © 2019 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
from odoo import SUPERUSER_ID, _, api, models | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class CrmTeam(models.Model): | ||
_inherit = "crm.team" | ||
|
||
@api.constrains("operating_unit_id") | ||
def _check_sales_order_operating_unit(self): | ||
for rec in self: | ||
orders = ( | ||
self.with_user(SUPERUSER_ID) | ||
.env["sale.order"] | ||
.search( | ||
[ | ||
("team_id", "=", rec.id), | ||
("operating_unit_id", "!=", rec.operating_unit_id.id), | ||
] | ||
) | ||
) | ||
if orders: | ||
raise ValidationError( | ||
_( | ||
"Configuration error. It is not " | ||
"possible to change this " | ||
"team. There are sale orders " | ||
"referencing it in other operating " | ||
"units" | ||
) | ||
) |
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,83 @@ | ||
# © 2019 ForgeFlow S.L. | ||
# - Jordi Ballester Alomar | ||
# © 2019 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
from odoo import _, api, fields, models | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class SaleOrder(models.Model): | ||
_inherit = "sale.order" | ||
|
||
@api.model | ||
def _default_operating_unit(self): | ||
team = self.env["crm.team"]._get_default_team_id() | ||
if team.operating_unit_id: | ||
return team.operating_unit_id | ||
return self.env.user.default_operating_unit_id | ||
|
||
operating_unit_id = fields.Many2one( | ||
comodel_name="operating.unit", | ||
string="Operating Unit", | ||
default=_default_operating_unit, | ||
readonly=True, | ||
states={"draft": [("readonly", False)], "sent": [("readonly", False)]}, | ||
) | ||
|
||
@api.onchange("team_id") | ||
def onchange_team_id(self): | ||
if self.team_id: | ||
self.operating_unit_id = self.team_id.operating_unit_id | ||
|
||
@api.onchange("operating_unit_id") | ||
def onchange_operating_unit_id(self): | ||
if self.team_id and self.team_id.operating_unit_id != self.operating_unit_id: | ||
self.team_id = False | ||
if self.operating_unit_id: | ||
self.team_id = self.env["crm.team"].search( | ||
[("operating_unit_id", "=", self.operating_unit_id.id)], limit=1 | ||
) | ||
|
||
@api.constrains("team_id", "operating_unit_id") | ||
def _check_team_operating_unit(self): | ||
for rec in self: | ||
if rec.team_id and rec.team_id.operating_unit_id != rec.operating_unit_id: | ||
raise ValidationError( | ||
_( | ||
"Configuration error. The Operating " | ||
"Unit of the sales team must match " | ||
"with that of the quote/sales order." | ||
) | ||
) | ||
|
||
@api.constrains("operating_unit_id", "company_id") | ||
def _check_company_operating_unit(self): | ||
for rec in self: | ||
if ( | ||
rec.company_id | ||
and rec.operating_unit_id | ||
and rec.company_id != rec.operating_unit_id.company_id | ||
): | ||
raise ValidationError( | ||
_( | ||
"Configuration error. The Company in " | ||
"the Sales Order and in the Operating " | ||
"Unit must be the same." | ||
) | ||
) | ||
|
||
def _prepare_invoice(self): | ||
self.ensure_one() | ||
invoice_vals = super(SaleOrder, self)._prepare_invoice() | ||
invoice_vals["operating_unit_id"] = self.operating_unit_id.id | ||
return invoice_vals | ||
|
||
|
||
class SaleOrderLine(models.Model): | ||
_inherit = "sale.order.line" | ||
|
||
operating_unit_id = fields.Many2one( | ||
related="order_id.operating_unit_id", | ||
string="Operating Unit", | ||
store=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,10 @@ | ||
* Jordi Ballester Alomar <[email protected]> | ||
* Aaron Henriquez <[email protected]> | ||
* Lois Rilo <[email protected]> | ||
* Miquel Raich <[email protected]> | ||
* Sudhir Arya <[email protected]> | ||
* Darshan Patel <[email protected]> | ||
* Alan Ramos <[email protected]> | ||
* Jorge Alberto Olvera Cuenca <[email protected]> | ||
* Alejandro Padrón <[email protected]> | ||
* Alexei Rivera <[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,3 @@ | ||
This module extends the Sales capabilities of Odoo and introduces the operating | ||
unit to the Sales Order. Security rules are defined to ensure that users can | ||
only display the Sales Orders in which they are allowed access to. |
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 @@ | ||
The onchange_team_id method is not working. | ||
If you try to change the team in a sales quotation and the operating unit | ||
is not taken from the sales team, and moreover, I cannot select the operating unit | ||
from the team, only Main OU shows, must have to have your salesperson in the sales team | ||
of the operating unit. |
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 @@ | ||
Follow these steps: | ||
|
||
#. Create a Sale Order. | ||
#. The Operating Unit of the Sale Team is assigned to the Sale Order. |
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 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import sale_report |
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 @@ | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class SaleReport(models.Model): | ||
_inherit = "sale.report" | ||
|
||
operating_unit_id = fields.Many2one("operating.unit", "Operating Unit") | ||
|
||
def _group_by_sale(self): | ||
res = super()._group_by_sale() | ||
res += """, s.operating_unit_id""" | ||
return res | ||
|
||
def _select_additional_fields(self): | ||
res = super()._select_additional_fields() | ||
res["operating_unit_id"] = "s.operating_unit_id" | ||
return res |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as resolved.
Sorry, something went wrong.