From 0ac2a78b9cb02bae9bf987fa68bc22b04d90de11 Mon Sep 17 00:00:00 2001 From: Corentin Date: Fri, 26 Apr 2024 15:45:32 -1000 Subject: [PATCH] [ADD] Module pos_order_split_invoice_attachment_sync --- .../README.rst | 96 ++++ .../__init__.py | 3 + .../__manifest__.py | 14 + .../models/__init__.py | 3 + .../models/ir_attachment.py | 41 ++ .../pyproject.toml | 3 + .../readme/CONFIGURE.md | 1 + .../readme/CONTRIBUTORS.md | 1 + .../readme/DESCRIPTION.md | 1 + .../readme/USAGE.md | 1 + .../static/description/index.html | 435 ++++++++++++++++++ 11 files changed, 599 insertions(+) create mode 100644 pos_order_split_invoice_attachment_sync/README.rst create mode 100644 pos_order_split_invoice_attachment_sync/__init__.py create mode 100644 pos_order_split_invoice_attachment_sync/__manifest__.py create mode 100644 pos_order_split_invoice_attachment_sync/models/__init__.py create mode 100644 pos_order_split_invoice_attachment_sync/models/ir_attachment.py create mode 100644 pos_order_split_invoice_attachment_sync/pyproject.toml create mode 100644 pos_order_split_invoice_attachment_sync/readme/CONFIGURE.md create mode 100644 pos_order_split_invoice_attachment_sync/readme/CONTRIBUTORS.md create mode 100644 pos_order_split_invoice_attachment_sync/readme/DESCRIPTION.md create mode 100644 pos_order_split_invoice_attachment_sync/readme/USAGE.md create mode 100644 pos_order_split_invoice_attachment_sync/static/description/index.html diff --git a/pos_order_split_invoice_attachment_sync/README.rst b/pos_order_split_invoice_attachment_sync/README.rst new file mode 100644 index 0000000000..3c70e8b949 --- /dev/null +++ b/pos_order_split_invoice_attachment_sync/README.rst @@ -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 `_. +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* INVITU + +Contributors +------------ + +- INVITU + +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 `__: + +|maintainer-Coco Invitu| + +This module is part of the `OCA/pos `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/pos_order_split_invoice_attachment_sync/__init__.py b/pos_order_split_invoice_attachment_sync/__init__.py new file mode 100644 index 0000000000..4b76c7b2d5 --- /dev/null +++ b/pos_order_split_invoice_attachment_sync/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/pos_order_split_invoice_attachment_sync/__manifest__.py b/pos_order_split_invoice_attachment_sync/__manifest__.py new file mode 100644 index 0000000000..5c348be366 --- /dev/null +++ b/pos_order_split_invoice_attachment_sync/__manifest__.py @@ -0,0 +1,14 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Pos Order Split Invoice Attachment Sync", + "version": "17.0.1.0.0", + "category": "Point Of Sale", + "summary": "Synchronizes attachments between Pos Orders and Splitted Invoices", + "author": "INVITU,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/pos", + "license": "AGPL-3", + "depends": ["base", "pos_order_split_invoice", "pos_order_attachment"], + "data": [], + "installable": True, +} diff --git a/pos_order_split_invoice_attachment_sync/models/__init__.py b/pos_order_split_invoice_attachment_sync/models/__init__.py new file mode 100644 index 0000000000..b8d1dac7a1 --- /dev/null +++ b/pos_order_split_invoice_attachment_sync/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import ir_attachment diff --git a/pos_order_split_invoice_attachment_sync/models/ir_attachment.py b/pos_order_split_invoice_attachment_sync/models/ir_attachment.py new file mode 100644 index 0000000000..1c2e36e0b0 --- /dev/null +++ b/pos_order_split_invoice_attachment_sync/models/ir_attachment.py @@ -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 diff --git a/pos_order_split_invoice_attachment_sync/pyproject.toml b/pos_order_split_invoice_attachment_sync/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/pos_order_split_invoice_attachment_sync/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/pos_order_split_invoice_attachment_sync/readme/CONFIGURE.md b/pos_order_split_invoice_attachment_sync/readme/CONFIGURE.md new file mode 100644 index 0000000000..16dac9e434 --- /dev/null +++ b/pos_order_split_invoice_attachment_sync/readme/CONFIGURE.md @@ -0,0 +1 @@ +This has no configuration required. diff --git a/pos_order_split_invoice_attachment_sync/readme/CONTRIBUTORS.md b/pos_order_split_invoice_attachment_sync/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..ebed1f29bd --- /dev/null +++ b/pos_order_split_invoice_attachment_sync/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- INVITU \<\> diff --git a/pos_order_split_invoice_attachment_sync/readme/DESCRIPTION.md b/pos_order_split_invoice_attachment_sync/readme/DESCRIPTION.md new file mode 100644 index 0000000000..a55be9a29d --- /dev/null +++ b/pos_order_split_invoice_attachment_sync/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module synchronizes attachments between pos orders and splitted invoices. diff --git a/pos_order_split_invoice_attachment_sync/readme/USAGE.md b/pos_order_split_invoice_attachment_sync/readme/USAGE.md new file mode 100644 index 0000000000..6afc66c000 --- /dev/null +++ b/pos_order_split_invoice_attachment_sync/readme/USAGE.md @@ -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. diff --git a/pos_order_split_invoice_attachment_sync/static/description/index.html b/pos_order_split_invoice_attachment_sync/static/description/index.html new file mode 100644 index 0000000000..b7481e0db7 --- /dev/null +++ b/pos_order_split_invoice_attachment_sync/static/description/index.html @@ -0,0 +1,435 @@ + + + + + + +Pos Order Split Invoice Attachment Sync + + + +
+

Pos Order Split Invoice Attachment Sync

+ + +

Beta License: AGPL-3 OCA/pos Translate me on Weblate Try me on Runboat

+

This module synchronizes attachments between pos orders and splitted +invoices.

+

Table of contents

+ +
+

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. +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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • INVITU
  • +
+
+ +
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

Current maintainer:

+

Coco Invitu

+

This module is part of the OCA/pos project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ +