diff --git a/pos_order_copy/README.rst b/pos_order_copy/README.rst new file mode 100644 index 0000000000..aefc4309ef --- /dev/null +++ b/pos_order_copy/README.rst @@ -0,0 +1,83 @@ +============== +Pos Order Copy +============== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:e364bed966a3064bc5f20442ec0663ea0678e280b5904781033072fedf94b4b0 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/18.0/pos_order_copy + :alt: OCA/pos +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/pos-18-0/pos-18-0-pos_order_copy + :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=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Copy orders on point of sale view. + +**Table of contents** + +.. contents:: + :local: + +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 +------- + +* Dixmit +* INVITU + +Contributors +------------ + +- Dixmit + + - Enric Tobella + +- `Heliconia Solutions Pvt. Ltd. `__ + + - Bhavesh Heliconia + +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/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_copy/__init__.py b/pos_order_copy/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/pos_order_copy/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pos_order_copy/__manifest__.py b/pos_order_copy/__manifest__.py new file mode 100644 index 0000000000..91c44465b9 --- /dev/null +++ b/pos_order_copy/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2024 Dixmit,INVITU +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Pos Order Copy", + "summary": """ + Copy Orders from PoS Frontend""", + "version": "18.0.1.0.0", + "license": "AGPL-3", + "author": "Dixmit,INVITU,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/pos", + "depends": ["point_of_sale"], + "assets": { + "point_of_sale._assets_pos": [ + "pos_order_copy/static/src/**/*.js", + "pos_order_copy/static/src/**/*.xml", + ], + }, + "data": [], + "demo": [], +} diff --git a/pos_order_copy/i18n/it.po b/pos_order_copy/i18n/it.po new file mode 100644 index 0000000000..7835f46c75 --- /dev/null +++ b/pos_order_copy/i18n/it.po @@ -0,0 +1,115 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_order_copy +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-11-04 11:06+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\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 5.6.2\n" + +#. module: pos_order_copy +#: model:ir.model.fields,help:pos_order_copy.field_pos_order__ticket_code +msgid "" +"5 digits alphanumeric code to be used by portal user to request an invoice" +msgstr "" +"Codice alfanumerico di 5 cifre utilizzabile da un utente portale per " +"richiedere una fattura" + +#. module: pos_order_copy +#: model:ir.model.fields,help:pos_order_copy.field_pos_order__sequence_number +msgid "A session-unique sequence number for the order" +msgstr "Un numero sequenza univoco per sessione per l'ordine" + +#. module: pos_order_copy +#: model:ir.model.fields,field_description:pos_order_copy.field_pos_order__date_order +msgid "Date" +msgstr "Data" + +#. module: pos_order_copy +#. odoo-javascript +#: code:addons/pos_order_copy/static/src/app/product_screen/CopyOrderButton.xml:0 +#: code:addons/pos_order_copy/static/src/app/ticket_screen/ticket_screen.xml:0 +#: code:addons/pos_order_copy/static/src/app/ticket_screen/ticket_screen.xml:0 +#, python-format +msgid "Duplicate Order" +msgstr "Duplica ordine" + +#. module: pos_order_copy +#: model:ir.model.fields,field_description:pos_order_copy.field_pos_order__is_tipped +msgid "Is this already tipped?" +msgstr "Questo è già con mancia?" + +#. module: pos_order_copy +#: model:ir.model.fields,field_description:pos_order_copy.field_pos_order__last_order_preparation_change +msgid "Last preparation change" +msgstr "Cambio ultima preparazione" + +#. module: pos_order_copy +#: model:ir.model.fields,help:pos_order_copy.field_pos_order__last_order_preparation_change +msgid "Last printed state of the order" +msgstr "Ultimo stato stampato dell'ordine" + +#. module: pos_order_copy +#. odoo-javascript +#: code:addons/pos_order_copy/static/src/app/store/pos_store.esm.js:0 +#, python-format +msgid "Order %s" +msgstr "Ordine %s" + +#. module: pos_order_copy +#: model:ir.model.fields,help:pos_order_copy.field_pos_order__user_id +msgid "" +"Person who uses the cash register. It can be a reliever, a student or an " +"interim employee." +msgstr "" +"Persona che utilizza il registratore di cassa. Può essere un sostituto, uno " +"studente o un dipendente provvisorio." + +#. module: pos_order_copy +#: model:ir.model,name:pos_order_copy.model_pos_order +msgid "Point of Sale Orders" +msgstr "Ordini punto vendita" + +#. module: pos_order_copy +#: model:ir.model,name:pos_order_copy.model_pos_session +msgid "Point of Sale Session" +msgstr "Sessione punto vendita" + +#. module: pos_order_copy +#: model:ir.model.fields,field_description:pos_order_copy.field_pos_order__user_id +msgid "Responsible" +msgstr "Responsabile" + +#. module: pos_order_copy +#: model:ir.model.fields,field_description:pos_order_copy.field_pos_order__sequence_number +msgid "Sequence Number" +msgstr "Numero sequenza" + +#. module: pos_order_copy +#: model:ir.model.fields,field_description:pos_order_copy.field_pos_order__session_id +msgid "Session" +msgstr "Sessione" + +#. module: pos_order_copy +#: model:ir.model.fields,field_description:pos_order_copy.field_pos_order__shipping_date +msgid "Shipping Date" +msgstr "Data spedizione" + +#. module: pos_order_copy +#: model:ir.model.fields,field_description:pos_order_copy.field_pos_order__ticket_code +msgid "Ticket Code" +msgstr "Codice ticket" + +#. module: pos_order_copy +#: model:ir.model.fields,field_description:pos_order_copy.field_pos_order__tip_amount +msgid "Tip Amount" +msgstr "Valore mancia" diff --git a/pos_order_copy/i18n/pos_order_copy.pot b/pos_order_copy/i18n/pos_order_copy.pot new file mode 100644 index 0000000000..d05b5b97cf --- /dev/null +++ b/pos_order_copy/i18n/pos_order_copy.pot @@ -0,0 +1,108 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_order_copy +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.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: pos_order_copy +#: model:ir.model.fields,help:pos_order_copy.field_pos_order__ticket_code +msgid "" +"5 digits alphanumeric code to be used by portal user to request an invoice" +msgstr "" + +#. module: pos_order_copy +#: model:ir.model.fields,help:pos_order_copy.field_pos_order__sequence_number +msgid "A session-unique sequence number for the order" +msgstr "" + +#. module: pos_order_copy +#: model:ir.model.fields,field_description:pos_order_copy.field_pos_order__date_order +msgid "Date" +msgstr "" + +#. module: pos_order_copy +#. odoo-javascript +#: code:addons/pos_order_copy/static/src/app/product_screen/CopyOrderButton.xml:0 +#: code:addons/pos_order_copy/static/src/app/ticket_screen/ticket_screen.xml:0 +#: code:addons/pos_order_copy/static/src/app/ticket_screen/ticket_screen.xml:0 +#, python-format +msgid "Duplicate Order" +msgstr "" + +#. module: pos_order_copy +#: model:ir.model.fields,field_description:pos_order_copy.field_pos_order__is_tipped +msgid "Is this already tipped?" +msgstr "" + +#. module: pos_order_copy +#: model:ir.model.fields,field_description:pos_order_copy.field_pos_order__last_order_preparation_change +msgid "Last preparation change" +msgstr "" + +#. module: pos_order_copy +#: model:ir.model.fields,help:pos_order_copy.field_pos_order__last_order_preparation_change +msgid "Last printed state of the order" +msgstr "" + +#. module: pos_order_copy +#. odoo-javascript +#: code:addons/pos_order_copy/static/src/app/store/pos_store.esm.js:0 +#, python-format +msgid "Order %s" +msgstr "" + +#. module: pos_order_copy +#: model:ir.model.fields,help:pos_order_copy.field_pos_order__user_id +msgid "" +"Person who uses the cash register. It can be a reliever, a student or an " +"interim employee." +msgstr "" + +#. module: pos_order_copy +#: model:ir.model,name:pos_order_copy.model_pos_order +msgid "Point of Sale Orders" +msgstr "" + +#. module: pos_order_copy +#: model:ir.model,name:pos_order_copy.model_pos_session +msgid "Point of Sale Session" +msgstr "" + +#. module: pos_order_copy +#: model:ir.model.fields,field_description:pos_order_copy.field_pos_order__user_id +msgid "Responsible" +msgstr "" + +#. module: pos_order_copy +#: model:ir.model.fields,field_description:pos_order_copy.field_pos_order__sequence_number +msgid "Sequence Number" +msgstr "" + +#. module: pos_order_copy +#: model:ir.model.fields,field_description:pos_order_copy.field_pos_order__session_id +msgid "Session" +msgstr "" + +#. module: pos_order_copy +#: model:ir.model.fields,field_description:pos_order_copy.field_pos_order__shipping_date +msgid "Shipping Date" +msgstr "" + +#. module: pos_order_copy +#: model:ir.model.fields,field_description:pos_order_copy.field_pos_order__ticket_code +msgid "Ticket Code" +msgstr "" + +#. module: pos_order_copy +#: model:ir.model.fields,field_description:pos_order_copy.field_pos_order__tip_amount +msgid "Tip Amount" +msgstr "" diff --git a/pos_order_copy/models/__init__.py b/pos_order_copy/models/__init__.py new file mode 100644 index 0000000000..b2f4b5e054 --- /dev/null +++ b/pos_order_copy/models/__init__.py @@ -0,0 +1,2 @@ +from . import pos_order +from . import pos_session diff --git a/pos_order_copy/models/pos_order.py b/pos_order_copy/models/pos_order.py new file mode 100644 index 0000000000..6044d37b39 --- /dev/null +++ b/pos_order_copy/models/pos_order.py @@ -0,0 +1,18 @@ +# Copyright 2024 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class PosOrder(models.Model): + _inherit = "pos.order" + + date_order = fields.Datetime(copy=False) + user_id = fields.Many2one(copy=False) + last_order_preparation_change = fields.Char(copy=False) + sequence_number = fields.Integer(copy=False) + session_id = fields.Many2one(copy=False) + shipping_date = fields.Date(copy=False) + is_tipped = fields.Boolean(copy=False) + tip_amount = fields.Float(copy=False) + ticket_code = fields.Char(copy=False) diff --git a/pos_order_copy/models/pos_session.py b/pos_order_copy/models/pos_session.py new file mode 100644 index 0000000000..699b728425 --- /dev/null +++ b/pos_order_copy/models/pos_session.py @@ -0,0 +1,22 @@ +# Copyright 2024 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class PosSession(models.Model): + _inherit = "pos.session" + + def _load_pos_data(self, data): + sessions = super()._load_pos_data(data) + sessions["data"][0]["_pos_order_copy_fields"] = [ + field_name + for field_name, field in self.env["pos.order"]._fields.items() + if field.copy and field.store and not field.automatic and not field.compute + ] + sessions["data"][0]["_pos_order_line_copy_fields"] = [ + field_name + for field_name, field in self.env["pos.order.line"]._fields.items() + if field.copy and field.store and not field.automatic and not field.compute + ] + return sessions diff --git a/pos_order_copy/pyproject.toml b/pos_order_copy/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/pos_order_copy/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/pos_order_copy/readme/CONTRIBUTORS.md b/pos_order_copy/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..bbfe33de2b --- /dev/null +++ b/pos_order_copy/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ + - Dixmit + - Enric Tobella +- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io) + - Bhavesh Heliconia diff --git a/pos_order_copy/readme/DESCRIPTION.md b/pos_order_copy/readme/DESCRIPTION.md new file mode 100644 index 0000000000..9d959d90f8 --- /dev/null +++ b/pos_order_copy/readme/DESCRIPTION.md @@ -0,0 +1 @@ +Copy orders on point of sale view. diff --git a/pos_order_copy/static/description/icon.png b/pos_order_copy/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/pos_order_copy/static/description/icon.png differ diff --git a/pos_order_copy/static/description/index.html b/pos_order_copy/static/description/index.html new file mode 100644 index 0000000000..6cbe228cca --- /dev/null +++ b/pos_order_copy/static/description/index.html @@ -0,0 +1,431 @@ + + + + + +Pos Order Copy + + + +
+

Pos Order Copy

+ + +

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

+

Copy orders on point of sale view.

+

Table of contents

+ +
+

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

+
    +
  • Dixmit
  • +
  • INVITU
  • +
+
+
+

Contributors

+ +
+
+

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.

+

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_copy/static/src/app/product_screen/CopyOrderButton.esm.js b/pos_order_copy/static/src/app/product_screen/CopyOrderButton.esm.js new file mode 100644 index 0000000000..a0e3d88144 --- /dev/null +++ b/pos_order_copy/static/src/app/product_screen/CopyOrderButton.esm.js @@ -0,0 +1,16 @@ +/** @odoo-module */ +/* + Copyright 2024 Dixmit + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +*/ + +import {ControlButtons} from "@point_of_sale/app/screens/product_screen/control_buttons/control_buttons"; +import {patch} from "@web/core/utils/patch"; + +patch(ControlButtons.prototype, { + onClickCopyOrderButton() { + var order = this.pos.get_order(); + this.pos.copy_on_new_order(order); + this.pos.showScreen("ProductScreen"); + }, +}); diff --git a/pos_order_copy/static/src/app/product_screen/CopyOrderButton.xml b/pos_order_copy/static/src/app/product_screen/CopyOrderButton.xml new file mode 100644 index 0000000000..edd845ec7a --- /dev/null +++ b/pos_order_copy/static/src/app/product_screen/CopyOrderButton.xml @@ -0,0 +1,19 @@ + + + + + + + + + diff --git a/pos_order_copy/static/src/app/store/pos_store.esm.js b/pos_order_copy/static/src/app/store/pos_store.esm.js new file mode 100644 index 0000000000..352b66b473 --- /dev/null +++ b/pos_order_copy/static/src/app/store/pos_store.esm.js @@ -0,0 +1,46 @@ +/** @odoo-module */ +/* + Copyright 2024 Dixmit + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +*/ +import {PosStore} from "@point_of_sale/app/store/pos_store"; +import {_t} from "@web/core/l10n/translation"; +import {patch} from "@web/core/utils/patch"; +import {uuidv4} from "@point_of_sale/utils"; +import {serializeDateTime} from "@web/core/l10n/dates"; + +patch(PosStore.prototype, { + async copy_on_new_order(currentOrder) { + if (!currentOrder) { + return; + } + if (this.isOpenOrderShareable()) { + this.sendDraftToServer(); + } + var json = currentOrder; + if (this.selectedOrder) { + this.selectedOrder.firstDraft = false; + this.selectedOrder.updateSavedQuantity(); + } + var newJson = { + lines: [], + statement_ids: [], + }; + for (var field of Object.values(this.session._pos_order_copy_fields)) { + if (field !== "lines" && json[field] !== undefined) { + newJson[field] = json[field]; + } + } + const newOrder = this.createNewOrder(newJson); + // We need to enforce some fields to be the standard ones + newOrder.date_order = serializeDateTime(luxon.DateTime.now()); + var step = this.currentSequenceNumber; + newOrder.sequence_number = step++; + newOrder.access_token = uuidv4(); + newOrder.ticketCode = newOrder._generateTicketCode(); + newOrder.uid = newOrder.generate_unique_id(); + newOrder.name = _t("Order %s", newOrder.uid); + this.selectedOrderUuid = newOrder.uuid; + return newOrder; + }, +}); diff --git a/pos_order_copy/static/src/app/ticket_screen/ticket_screen.esm.js b/pos_order_copy/static/src/app/ticket_screen/ticket_screen.esm.js new file mode 100644 index 0000000000..f55475c565 --- /dev/null +++ b/pos_order_copy/static/src/app/ticket_screen/ticket_screen.esm.js @@ -0,0 +1,14 @@ +/** @odoo-module */ +/* + Copyright 2024 Dixmit + License OPL-1.0 or later (https://www.odoo.com/documentation/15.0/es/legal/licenses.html#odoo-apps). +*/ +import {TicketScreen} from "@point_of_sale/app/screens/ticket_screen/ticket_screen"; +import {patch} from "@web/core/utils/patch"; + +patch(TicketScreen.prototype, { + _copyOrder(order) { + this.pos.copy_on_new_order(order); + this.pos.showScreen("ProductScreen"); + }, +}); diff --git a/pos_order_copy/static/src/app/ticket_screen/ticket_screen.xml b/pos_order_copy/static/src/app/ticket_screen/ticket_screen.xml new file mode 100644 index 0000000000..4b446d66f5 --- /dev/null +++ b/pos_order_copy/static/src/app/ticket_screen/ticket_screen.xml @@ -0,0 +1,26 @@ + + + + + + + + + + +