-
-
Notifications
You must be signed in to change notification settings - Fork 587
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] Module pos_order_split_invoice_attachment_sync
- Loading branch information
1 parent
b8fc8e2
commit ec0a027
Showing
11 changed files
with
601 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,96 @@ | ||
======================================= | ||
Pos Order Split Invoice Attachment Sync | ||
======================================= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:ca9c49fed5f3d1ec49af503e3c27a6050b53caa748b5acf2af739e93def63c50 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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%2Fpos-lightgray.png?logo=github | ||
:target: https://github.com/OCA/pos/tree/17.0/pos_order_split_invoice_attachment_sync | ||
:alt: OCA/pos | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/pos-17-0/pos-17-0-pos_order_split_invoice_attachment_sync | ||
: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/pos&target_branch=17.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module synchronizes attachments between pos orders and splitted | ||
invoices. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
This has no configuration required. | ||
|
||
Usage | ||
===== | ||
|
||
You have nothing to do, all the attachments in a pos order linked to a | ||
splitted invoice are syncronized with in the splitted invoice. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/pos/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/pos/issues/new?body=module:%20pos_order_split_invoice_attachment_sync%0Aversion:%2017.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 | ||
------- | ||
|
||
* INVITU | ||
|
||
Contributors | ||
------------ | ||
|
||
- INVITU <[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. | ||
|
||
.. |maintainer-Coco Invitu| image:: https://github.com/Coco Invitu.png?size=40px | ||
:target: https://github.com/Coco Invitu | ||
:alt: Coco Invitu | ||
|
||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: | ||
|
||
|maintainer-Coco Invitu| | ||
|
||
This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/17.0/pos_order_split_invoice_attachment_sync>`_ 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 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import models |
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,16 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
"name": "Pos Order Split Invoice Attachment Sync", | ||
"version": "1.0", | ||
"author": "INVITU", | ||
"maintainers": [ | ||
"Coco Invitu", | ||
], | ||
"category": "", | ||
"website": "https://github.com/OCA/pos", | ||
"depends": ["base", "pos_order_split_invoice", "pos_order_attachment"], | ||
"data": [], | ||
"license": "AGPL-3", | ||
"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,3 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import ir_attachment |
41 changes: 41 additions & 0 deletions
41
pos_order_split_invoice_attachment_sync/models/ir_attachment.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,41 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, models | ||
|
||
|
||
class IrAttachment(models.Model): | ||
_name = "ir.attachment" | ||
_inherit = ["ir.attachment"] | ||
|
||
@api.model_create_multi | ||
def create(self, vals_list): | ||
res = super().create(vals_list) | ||
for attachment in res: | ||
if attachment.res_model == "pos.order": | ||
pos_order = self.env["pos.order"].search( | ||
[("id", "=", attachment.res_id)] | ||
) | ||
if pos_order.splitting_move_id: | ||
linked_account_move = pos_order.splitting_move_id | ||
res.copy( | ||
{"res_model": "account.move", "res_id": linked_account_move.id} | ||
) | ||
return res | ||
|
||
def unlink(self): | ||
for attachment in self: | ||
if attachment.res_model == "pos.order": | ||
pos_order = self.env["pos.order"].search( | ||
[("id", "=", attachment.res_id)] | ||
) | ||
linked_account_move = pos_order.splitting_move_id | ||
link_attachment = self.env["ir.attachment"].search( | ||
[ | ||
("res_id", "=", linked_account_move.id), | ||
("res_model", "=", "account.move"), | ||
("checksum", "=", attachment.checksum), | ||
] | ||
) | ||
link_attachment.unlink() | ||
res = super().unlink() | ||
return res |
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" |
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 @@ | ||
This has no configuration required. |
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 @@ | ||
- INVITU \<<[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 @@ | ||
This module synchronizes attachments between pos orders and splitted invoices. |
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 @@ | ||
You have nothing to do, all the attachments in a pos order linked to a splitted invoice are syncronized with in the splitted invoice. |
Oops, something went wrong.