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

[15.0][FIX] account_operating_unit: default_operating_unit_id #28

Open
wants to merge 113 commits into
base: 15.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
a0a8ac3
[ADD] purchase request operating unit
JordiBForgeFlow Feb 17, 2016
edbdacc
[ADD] purchase_request_operating_unit v10
serpentcs-dev1 Jul 5, 2017
55270ce
[MIG] purchase_request_operating_unit: Migration to v12 merge with pu…
bjeficent Feb 13, 2019
ed90f24
[UPD] README.rst
OCA-git-bot Nov 25, 2019
2fd57f9
[ADD] icon.png
OCA-git-bot Nov 25, 2019
031ad52
Added translation using Weblate (Portuguese)
pedrocs-exo Feb 29, 2020
c6a4f64
Translated using Weblate (Portuguese)
pedrocs-exo Feb 29, 2020
ae0f790
[IMP] purchase_request_operating_unit: black, isort, prettier
Saran440 Dec 10, 2020
48ad5a1
[13.0][MIG] purchase_request_operating_unit
Saran440 Dec 10, 2020
9314ef3
[14.0][MIG] purchase_request_operating_unit
Saran440 Dec 10, 2020
93dbb67
[UPD] Update purchase_request_operating_unit.pot
oca-travis Jun 23, 2021
2c30955
[IMP] update dotfiles [ci skip]
OCA-git-bot Mar 31, 2022
1b47dde
Added translation using Weblate (French)
kh-badep Jun 28, 2022
79d86d4
Translated using Weblate (French)
kh-badep Jun 28, 2022
42aaacd
[IMP] purchase_request_operating_unit: black, isort, prettier
BT-pcavero Aug 2, 2022
afb5425
[15.0][MIG] purchase_request_operating_unit: Migration to 15.0
BT-pcavero Aug 2, 2022
3a6a5be
Added Sale Stock OU module for v8.
sudhir-serpentcs Feb 10, 2016
950dbc9
Migrated Sale Stock OU module from v7 to v8.
sudhir-serpentcs Feb 10, 2016
590c5b9
Added Test cases and Readme file.
sudhir-serpentcs Feb 10, 2016
56b84c9
Migrate to v9
AaronHForgeFlow Aug 24, 2016
f40d625
[MIG] sale_stock_operating_unit to v10.
LoisRForgeFlow Jan 31, 2017
3679f2b
Fix constraint on warehouses (#61)
guewen Feb 8, 2017
32a9707
[FIX]team operating unit has more priority than the default warehouse
AaronHForgeFlow May 16, 2018
a264fed
[MIG] sale_stock_operating_unit: Migration to v12
bjeficent Feb 11, 2019
08aedf1
[UPD] Update sale_stock_operating_unit.pot
oca-travis Dec 18, 2019
f489556
[UPD] README.rst
OCA-git-bot Dec 18, 2019
4e77585
[IMP] Sale Multi Ware
osi-scampbell Jan 15, 2020
9d9aa90
[UPD] Update sale_stock_operating_unit.pot
oca-travis Jan 16, 2020
a6daf2f
sale_stock_operating_unit 12.0.1.0.1
OCA-git-bot Jan 16, 2020
faf4212
Added translation using Weblate (Portuguese)
pedrocs-exo Feb 29, 2020
04b7732
Translated using Weblate (Portuguese)
pedrocs-exo Feb 29, 2020
f3a92fa
Added translation using Weblate (Italian)
francesco-ooops Jan 8, 2021
ddfb5fb
Translated using Weblate (Italian)
francesco-ooops Jun 17, 2021
5ab50d0
[IMP] sale_stock_operating_unit: black, isort, prettier
Jun 20, 2022
c96c539
[15.0][MIG] sale_stock_operating_unit: Migration to 15.0
Jun 20, 2022
f5acabf
Migrated sale_operating_unit module and its test cases.
sudhir-serpentcs Feb 9, 2016
33e5841
Added OU and WH constraints in SO.
sudhir-serpentcs Feb 10, 2016
ca14a19
migrate code to v9 (wip)
AaronHForgeFlow Aug 23, 2016
6e0cfda
[MIG] sale_operating_unit: Migrated to 10.0
AaronHForgeFlow Jan 31, 2017
12d9b41
[FIX] readonly on OU
serpentcs-dev1 Jul 4, 2017
22262d4
[MIG] sale_operating_unit: Migration to v11
bjeficent Jan 31, 2019
708b171
[ADD] icon.png
OCA-git-bot May 21, 2019
6b42ef4
[UPD] README.rst
OCA-git-bot Jul 29, 2019
e63fa3a
[MIG]sale_operating_unit to v12
bjeficent Nov 26, 2019
7fb9ae2
[IMP]sale advance payment to include the OU
AaronHForgeFlow Nov 26, 2019
db7a14a
[UPD] Update sale_operating_unit.pot
oca-travis Nov 26, 2019
7a27bbe
[UPD] README.rst
OCA-git-bot Nov 26, 2019
6d59b1d
[FIX] Delete uncalled file
MiquelRForgeFlow Nov 29, 2019
ee90ba2
[UPD] Update sale_operating_unit.pot
oca-travis Nov 29, 2019
f596dca
sale_operating_unit 12.0.1.0.1
OCA-git-bot Nov 29, 2019
a24661b
[IMP] sale_operating_unit: black, isort
alan196 Feb 12, 2020
8ea9b37
[MIG] sale_operating_unit: Migration to V13
alan196 Feb 12, 2020
7843ae4
[UPD] Update sale_operating_unit.pot
oca-travis Apr 16, 2020
5a53b2f
[UPD] Eficent -> ForgeFlow
MiquelRForgeFlow Oct 5, 2020
fa26a1c
[UPD] README.rst
OCA-git-bot Oct 5, 2020
6b987eb
Added translation using Weblate (Spanish)
javierjcf Mar 14, 2022
225b8bb
Translated using Weblate (Spanish)
javierjcf Mar 14, 2022
179f13b
[IMP] sale_operating_unit: black, isort, prettier
Jun 20, 2022
8323518
[15.0][MIG] sale_operating_unit: Migration to 15.0
Jun 20, 2022
114a29e
Added Purchase Operating Unit module.
sudhir-serpentcs Dec 31, 2015
551d238
Improved the unit test case for Purchase OU.
sudhir-serpentcs Jan 2, 2016
77cb6ec
Improved the code of unit test cases and of constraint.
sudhir-serpentcs Jan 8, 2016
4255549
Migrated the module with test cases.
sudhir-serpentcs Feb 22, 2016
316964d
create PO from procurement
JordiBForgeFlow Oct 6, 2016
e25a9bf
[MIG] purchase_operating_unit: Migrated to 10.0
AaronHForgeFlow Jan 31, 2017
9922d34
[FIX] readonly on OU
serpentcs-dev1 Jul 4, 2017
e5bb3d3
[FIX] when the procurement location is not internal the PO may belong…
AaronHForgeFlow Nov 22, 2017
933600d
[FIX]PYLINT mainly
AaronHForgeFlow Jun 11, 2018
645f2f8
[MIG] purchase_operating_unit: Migration to v12.0
bjeficent Dec 18, 2018
9b103eb
[UPD] Update purchase_operating_unit.pot
oca-travis Oct 30, 2019
96a3a24
[UPD] README.rst
OCA-git-bot Oct 30, 2019
f7a4e23
[IMP] purchase_operating_unit: black, isort, prettier
BT-nstuder Jan 7, 2020
2c00587
[MIG] purchase_operating_unit: Migration to 13.0
BT-nstuder Jan 8, 2020
5517af1
[UPD] Update purchase_operating_unit.pot
oca-travis Apr 30, 2020
af32973
[UPD] README.rst
OCA-git-bot Apr 30, 2020
21e2d9c
[FIX] Fixed Issue #291
nikul-serpentcs Oct 1, 2020
876f356
[UPD] README.rst
OCA-git-bot Oct 1, 2020
1ebe9a2
purchase_operating_unit 13.0.1.0.1
OCA-git-bot Oct 1, 2020
5d0b2f7
[UPD] Eficent -> ForgeFlow
MiquelRForgeFlow Oct 5, 2020
dc58b73
[UPD] README.rst
OCA-git-bot Oct 5, 2020
d83406b
[IMP] : black, isort, prettier
kittiu Dec 4, 2020
e066618
[14.0][MIG] purchase_operating_unit
kittiu Dec 4, 2020
c621986
[UPD] Update purchase_operating_unit.pot
oca-travis May 30, 2021
9934160
[UPD] README.rst
OCA-git-bot May 30, 2021
32062b4
[14.0][FIX] purchase_operating_unit, add OU when create invoice
kittiu Jun 15, 2021
d576e0f
purchase_operating_unit 14.0.1.0.1
OCA-git-bot Aug 3, 2021
3332f6e
[14.0][FIX] purchase_operating_unit
kittiu Oct 19, 2021
e2dc3ab
purchase_operating_unit 14.0.1.0.2
OCA-git-bot Oct 19, 2021
517435f
[IMP] purchase_operating_unit: black, isort, prettier
alan196 Jan 13, 2022
bdcc536
[MIG] purchase_operating_unit: Migration to 15.0
alan196 Jan 13, 2022
db7bf74
[13.0][ADD] sale_operating_unit_sequence
ps-tubtim Jun 30, 2020
cd69195
[UPD] Update sale_operating_unit_sequence.pot
oca-travis May 8, 2021
055a79b
[MIG] sale_operating_unit_sequence: Migration to 15.0
Jul 21, 2022
6a3f05f
[ADD] pos_operating_unit: new module to manage POS with operating unit
alan196 Aug 8, 2022
dbeadd4
Merge branch '15.0-mig-purchase_operating_unit' into 15.0
alan196 Feb 15, 2023
ae2a691
Merge branch '15.0-mig-purchase_request_operating_unit' into 15.0
alan196 Feb 15, 2023
6c2158e
Merge branch '15.0-mig-sale_operating_unit' into 15.0
alan196 Feb 15, 2023
ede6cf9
Merge branch '15.0-mig-sale_operating_unit_sequence' into 15.0
alan196 Feb 15, 2023
b22cde2
Merge branch '15.0-mig-sale_stock_operating_unit' into 15.0
alan196 Feb 15, 2023
5233d05
[FIX] test_requirements.txt: remove content from files
alan196 Feb 15, 2023
96af1d1
[FIX] _prepare_purchase_order meth
olveracuenca Mar 1, 2023
2b6aa64
Merge pull request #27 from Jarsa-dev/15.0-fix-purchase_request_order
EduardoJarsa Mar 2, 2023
dce4e91
[FIX] 14.0 sale_operating_unit Error sale report to add field operati…
Mar 1, 2023
014b2fb
Merge PR #540 into 14.0
Mar 1, 2023
2e8d9fa
Merge pull request #26 from Jarsa-dev/15.0-fix-pos-report
EduardoJarsa Mar 2, 2023
bcbfc14
[FIX] sale_operating_unit: create invoice with journal from ou
alan196 Mar 7, 2023
8e1cd39
[FIX] sale_operating_unit: add store to related field in sale.order.line
alan196 Mar 8, 2023
40b8c18
[FIX] sale_operating_unit: allow to generate advance invoices with ou
alan196 Mar 8, 2023
5b24371
[FIX] sale_stock_operating_unit: set the operating unit of the move, …
alan196 Mar 9, 2023
781ccfb
[FIX] purchase_operating_unit: allow to create supplier invoice
alan196 Mar 10, 2023
c3561ba
[FIX] pre-commit: fix pre-commit issues
alan196 Mar 11, 2023
da3b197
[ADD] stock_location_route_operating_unit: new module to filter route…
alan196 Mar 11, 2023
90fa2c9
[15.0][FIX] account_operating_unit: default_operating_unit_id
GuarU345 Mar 24, 2023
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
5 changes: 5 additions & 0 deletions account_operating_unit/models/account_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@

class AccountJournal(models.Model):
_inherit = "account.journal"

@api.model
def _default_operating_unit_id(self):
return self.env["res.users"].operating_unit_default_get()

operating_unit_id = fields.Many2one(
comodel_name="operating.unit",
default=_default_operating_unit_id,
help="Operating Unit that will be used in payments, "
"when this journal is used.",
)
Expand Down
84 changes: 84 additions & 0 deletions pos_operating_unit/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
=====================
Operating Unit in POS
=====================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/15.0/pos_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-15-0/operating-unit-15-0-pos_operating_unit
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/213/15.0
:alt: Try me on Runbot

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

This module introduces the following features:

- It introduces the operating unit to the pos order, pos session, pos payment and pos config.
- The operating unit is copied to the picking, invoice and all related accounting moves.
- It implements user's security rules.

**Table of contents**

.. contents::
:local:

Usage
=====

#. Open a POS Session: The POS Config Operating Unit will be assigned to the Session.
#. Create a POS Order: The Session Operating Unit will be assigned to the Order.
#. All accounting operations will be performed on the Order 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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/operating-unit/issues/new?body=module:%20pos_operating_unit%0Aversion:%2015.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
~~~~~~~

* Jarsa

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

* Alan Ramos <[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/15.0/pos_operating_unit>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions pos_operating_unit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2022 Jarsa
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from . import models
26 changes: 26 additions & 0 deletions pos_operating_unit/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2022 Jarsa
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

{
"name": "Operating Unit in POS",
"summary": "Adds the concept of operating unit (OU) in POS" "management",
"version": "15.0.1.0.0",
"author": "Jarsa," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/operating-unit",
"category": "Point of Sale",
"depends": [
"point_of_sale",
"stock_account_operating_unit",
],
"license": "LGPL-3",
"data": [
"security/pos_security.xml",
"views/pos_order_view.xml",
"views/pos_config_view.xml",
"views/pos_session_view.xml",
"views/pos_payment_view.xml",
"views/report_pos_order_view.xml",
],
"demo": [],
"installable": True,
}
11 changes: 11 additions & 0 deletions pos_operating_unit/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2022 Jarsa
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from . import account_payment
from . import pos_config
from . import pos_order_line
from . import pos_order
from . import pos_payment
from . import pos_session
from . import report_pos_order
from . import stock_picking
15 changes: 15 additions & 0 deletions pos_operating_unit/models/account_payment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2022 Jarsa
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from odoo import api, models


class AccountPayment(models.Model):
_inherit = "account.payment"

@api.model
def create(self, values):
if values.get("pos_session_id"):
session = self.env["pos.session"].browse(values["pos_session_id"])
values["operating_unit_id"] = session.operating_unit_id.id
return super().create(values)
75 changes: 75 additions & 0 deletions pos_operating_unit/models/pos_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Copyright 2022 Jarsa
# 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 PosConfig(models.Model):
_inherit = "pos.config"

operating_unit_id = fields.Many2one(
comodel_name="operating.unit",
)

@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 POS Config "
"and in the Operating Unit must be the same."
)
)

@api.constrains("operating_unit_id", "invoice_journal_id")
def _check_invoice_journal_operating_unit(self):
for rec in self:
if (
rec.invoice_journal_id
and rec.operating_unit_id
and rec.invoice_journal_id.operating_unit_id != rec.operating_unit_id
):
raise ValidationError(
_(
"Configuration error. The Operating Unit in the Invoice Journal"
" and in the POS Config must be the same."
)
)

@api.constrains("operating_unit_id", "journal_id")
def _check_journal_operating_unit(self):
for rec in self:
if (
rec.journal_id
and rec.operating_unit_id
and rec.journal_id.operating_unit_id != rec.operating_unit_id
):
raise ValidationError(
_(
"Configuration error. The Operating Unit in the POS Journal"
" and in the POS Config must be the same."
)
)

@api.constrains("operating_unit_id", "picking_type_id")
def _check_picking_type_operating_unit(self):
for rec in self:
warehouse = rec.picking_type_id.warehouse_id
if (
warehouse.operating_unit_id
and rec.picking_type_id
and rec.operating_unit_id
and warehouse.operating_unit_id != rec.operating_unit_id
):
raise ValidationError(
_(
"Configuration error. The Operating Unit in the Picking Type"
"Warehouse and in the POS Config must be the same."
)
)
51 changes: 51 additions & 0 deletions pos_operating_unit/models/pos_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright 2022 Jarsa
# 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 PosOrder(models.Model):
_inherit = "pos.order"

operating_unit_id = fields.Many2one(
comodel_name="operating.unit",
string="Operating Unit",
readonly=True,
)

def _prepare_invoice_vals(self):
vals = super()._prepare_invoice_vals()
vals["operating_unit_id"] = self.operating_unit_id.id
return vals

@api.model
def _order_fields(self, ui_order):
res = super()._order_fields(ui_order)
res["operating_unit_id"] = (
self.env["pos.session"]
.browse(ui_order["pos_session_id"])
.operating_unit_id.id
)
return res

@api.model
def _payment_fields(self, order, ui_paymentline):
res = super()._payment_fields(order, ui_paymentline)
res["operating_unit_id"] = order.operating_unit_id.id
return res

@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 POS Order "
"and in the Operating Unit must be the same."
)
)
23 changes: 23 additions & 0 deletions pos_operating_unit/models/pos_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2022 Jarsa
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from odoo import fields, models


class PosOrderLine(models.Model):
_inherit = "pos.order.line"

operating_unit_id = fields.Many2one(
comodel_name="operating.unit",
string="Operating Unit",
readonly=True,
)

def _order_line_fields(self, line, session_id=None):
res = super()._order_line_fields(line, session_id)
session = (
self.env["pos.session"].browse(session_id).exists() if session_id else None
)
if session:
res[2]["operating_unit_id"] = session.operating_unit_id.id
return res
14 changes: 14 additions & 0 deletions pos_operating_unit/models/pos_payment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2022 Jarsa
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from odoo import fields, models


class PosPayment(models.Model):
_inherit = "pos.payment"

operating_unit_id = fields.Many2one(
comodel_name="operating.unit",
string="Operating Unit",
readonly=True,
)
55 changes: 55 additions & 0 deletions pos_operating_unit/models/pos_session.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright 2022 Jarsa
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from odoo import api, fields, models


class PosSession(models.Model):
_inherit = "pos.session"

operating_unit_id = fields.Many2one(
comodel_name="operating.unit",
string="Operating Unit",
readonly=True,
)

@api.model
def create(self, values):
config_id = values.get("config_id") or self.env.context.get("default_config_id")
pos_config = self.env["pos.config"].browse(config_id)
if pos_config.operating_unit_id:
values["operating_unit_id"] = pos_config.operating_unit_id.id
return super().create(values)

def _get_sale_vals(self, key, amount, amount_converted):
res = super()._get_sale_vals(key, amount, amount_converted)
move = self.env["account.move"].browse(res["move_id"])
move.write({"operating_unit_id": self.operating_unit_id.id})
res["operating_unit_id"] = self.operating_unit_id.id
return res

def _credit_amounts(
self,
partial_move_line_vals,
amount,
amount_converted,
force_company_currency=False,
):
res = super()._credit_amounts(
partial_move_line_vals, amount, amount_converted, force_company_currency
)
res["operating_unit_id"] = self.operating_unit_id.id
return res

def _debit_amounts(
self,
partial_move_line_vals,
amount,
amount_converted,
force_company_currency=False,
):
res = super()._debit_amounts(
partial_move_line_vals, amount, amount_converted, force_company_currency
)
res["operating_unit_id"] = self.operating_unit_id.id
return res
Loading