diff --git a/pos_default_partner/README.rst b/pos_default_partner/README.rst new file mode 100644 index 0000000000..404627d892 --- /dev/null +++ b/pos_default_partner/README.rst @@ -0,0 +1,88 @@ +============================= +Point Of Sale Default Partner +============================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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-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/13.0/pos_default_partner + :alt: OCA/pos +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/pos-13-0/pos-13-0-pos_default_partner + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/184/13.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Define a default partner for Point Of Sale order on each company. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +Go to Point of Sale's settings page and select a default customer for a +specific PoS configuration. + +Known issues / Roadmap +====================== + +Set the default customer also on the PoS UI. + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Akretion + +Contributors +~~~~~~~~~~~~ + +* Akretion + + * David Beal +* Foram Shah + + +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_default_partner/__init__.py b/pos_default_partner/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/pos_default_partner/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pos_default_partner/__manifest__.py b/pos_default_partner/__manifest__.py new file mode 100644 index 0000000000..c393e265d0 --- /dev/null +++ b/pos_default_partner/__manifest__.py @@ -0,0 +1,16 @@ +# copyright 2020 Akretion David BEAL +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Point Of Sale Default Partner", + "summary": "Add a default customer in pos order", + "license": "AGPL-3", + "version": "14.0.1.0.0", + "author": "Akretion," "Odoo Community Association (OCA)", + "maintainer": "Akretion", + "category": "Point of sale", + "depends": ["point_of_sale"], + "data": ["views/pos_config.xml"], + "website": "https://github.com/OCA/pos", + "installable": True, +} diff --git a/pos_default_partner/i18n/es.po b/pos_default_partner/i18n/es.po new file mode 100644 index 0000000000..1cfba47860 --- /dev/null +++ b/pos_default_partner/i18n/es.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_default_partner +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-07-27 11:19+0000\n" +"Last-Translator: Daniel Martinez Vila \n" +"Language-Team: none\n" +"Language: es\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 3.10\n" + +#. module: pos_default_partner +#: model_terms:ir.ui.view,arch_db:pos_default_partner.pos_config_view_form +msgid "Customers" +msgstr "Clientes" + +#. module: pos_default_partner +#: model:ir.model.fields,field_description:pos_default_partner.field_pos_config__default_partner_id +#: model_terms:ir.ui.view,arch_db:pos_default_partner.pos_config_view_form +msgid "Default Customer" +msgstr "Cliente predeterminado" + +#. module: pos_default_partner +#: model_terms:ir.ui.view,arch_db:pos_default_partner.pos_config_view_form +msgid "Default customer to use if none is set" +msgstr "Cliente predeterminado para usar si no se establece ninguno" + +#. module: pos_default_partner +#: model:ir.model,name:pos_default_partner.model_pos_config +msgid "Point of Sale Configuration" +msgstr "Configuración del punto de venta" + +#. module: pos_default_partner +#: model:ir.model,name:pos_default_partner.model_pos_order +msgid "Point of Sale Orders" +msgstr "Pedidos de Punto de Venta" diff --git a/pos_default_partner/i18n/pos_default_partner.pot b/pos_default_partner/i18n/pos_default_partner.pot new file mode 100644 index 0000000000..6d726fdac4 --- /dev/null +++ b/pos_default_partner/i18n/pos_default_partner.pot @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_default_partner +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.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_default_partner +#: model_terms:ir.ui.view,arch_db:pos_default_partner.pos_config_view_form +msgid "Customers" +msgstr "" + +#. module: pos_default_partner +#: model:ir.model.fields,field_description:pos_default_partner.field_pos_config__default_partner_id +#: model_terms:ir.ui.view,arch_db:pos_default_partner.pos_config_view_form +msgid "Default Customer" +msgstr "" + +#. module: pos_default_partner +#: model_terms:ir.ui.view,arch_db:pos_default_partner.pos_config_view_form +msgid "Default customer to use if none is set" +msgstr "" + +#. module: pos_default_partner +#: model:ir.model,name:pos_default_partner.model_pos_config +msgid "Point of Sale Configuration" +msgstr "" + +#. module: pos_default_partner +#: model:ir.model,name:pos_default_partner.model_pos_order +msgid "Point of Sale Orders" +msgstr "" diff --git a/pos_default_partner/models/__init__.py b/pos_default_partner/models/__init__.py new file mode 100644 index 0000000000..7723e42ab6 --- /dev/null +++ b/pos_default_partner/models/__init__.py @@ -0,0 +1,2 @@ +from . import pos_order +from . import pos_config diff --git a/pos_default_partner/models/pos_config.py b/pos_default_partner/models/pos_config.py new file mode 100644 index 0000000000..0745a81d35 --- /dev/null +++ b/pos_default_partner/models/pos_config.py @@ -0,0 +1,14 @@ +# Copyright 2020 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class PosConfig(models.Model): + + _inherit = "pos.config" + + default_partner_id = fields.Many2one( + comodel_name="res.partner", + string="Default Customer", + ) diff --git a/pos_default_partner/models/pos_order.py b/pos_default_partner/models/pos_order.py new file mode 100644 index 0000000000..a4441f3876 --- /dev/null +++ b/pos_default_partner/models/pos_order.py @@ -0,0 +1,15 @@ +# copyright 2020 Akretion David BEAL +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, models + + +class PosOrder(models.Model): + _inherit = "pos.order" + + @api.model + def _complete_values_from_session(self, session, values): + result = super()._complete_values_from_session(session, values) + if session.config_id.default_partner_id and not result.get("partner_id"): + result["partner_id"] = session.config_id.default_partner_id.id + return result diff --git a/pos_default_partner/readme/CONFIGURE.rst b/pos_default_partner/readme/CONFIGURE.rst new file mode 100644 index 0000000000..896aabcf06 --- /dev/null +++ b/pos_default_partner/readme/CONFIGURE.rst @@ -0,0 +1,2 @@ +Go to Point of Sale's settings page and select a default customer for a +specific PoS configuration. diff --git a/pos_default_partner/readme/CONTRIBUTORS.rst b/pos_default_partner/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..f4377f281f --- /dev/null +++ b/pos_default_partner/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* Akretion + + * David Beal +* Foram Shah diff --git a/pos_default_partner/readme/DESCRIPTION.rst b/pos_default_partner/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..aea9cc115c --- /dev/null +++ b/pos_default_partner/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Define a default partner for Point Of Sale order on each company. diff --git a/pos_default_partner/readme/ROADMAP.rst b/pos_default_partner/readme/ROADMAP.rst new file mode 100644 index 0000000000..44ddb1d969 --- /dev/null +++ b/pos_default_partner/readme/ROADMAP.rst @@ -0,0 +1 @@ +Set the default customer also on the PoS UI. diff --git a/pos_default_partner/static/description/icon.png b/pos_default_partner/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/pos_default_partner/static/description/icon.png differ diff --git a/pos_default_partner/static/description/index.html b/pos_default_partner/static/description/index.html new file mode 100644 index 0000000000..7d16b73773 --- /dev/null +++ b/pos_default_partner/static/description/index.html @@ -0,0 +1,436 @@ + + + + + + +Point Of Sale Default Partner + + + +
+

Point Of Sale Default Partner

+ + +

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

+

Define a default partner for Point Of Sale order on each company.

+

Table of contents

+ +
+

Configuration

+

Go to Point of Sale’s settings page and select a default customer for a +specific PoS configuration.

+
+
+

Known issues / Roadmap

+

Set the default customer also on the PoS UI.

+
+
+

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 smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Akretion
  • +
+
+
+

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_default_partner/tests/__init__.py b/pos_default_partner/tests/__init__.py new file mode 100644 index 0000000000..94abdc77ec --- /dev/null +++ b/pos_default_partner/tests/__init__.py @@ -0,0 +1 @@ +from . import test_pos_default_partner diff --git a/pos_default_partner/tests/test_pos_default_partner.py b/pos_default_partner/tests/test_pos_default_partner.py new file mode 100644 index 0000000000..0988477c76 --- /dev/null +++ b/pos_default_partner/tests/test_pos_default_partner.py @@ -0,0 +1,119 @@ +from odoo import fields +from odoo.tests.common import SavepointCase + + +class TestPosDefaultPartner(SavepointCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.config = cls.env["pos.config"].create({"name": "DEMO Config"}) + cls.PosOrder = cls.env["pos.order"] + cls.AccountPayment = cls.env["account.payment"] + + # Get Object + cls.pos_product = cls.env["product.product"].create( + {"name": "Test POS Product"} + ) + cls.pricelist = cls.env["product.pricelist"].create( + { + "name": "Test pricelist", + "currency_id": cls.env.user.company_id.currency_id.id, + "item_ids": [ + ( + 0, + 0, + { + "applied_on": "3_global", + "compute_price": "formula", + "base": "list_price", + }, + ) + ], + } + ) + cls.partner_01 = cls.env["res.partner"].create({"name": "Test partner 1"}) + cls.partner_02 = cls.env["res.partner"].create({"name": "Test partner 2"}) + + def _create_order(self, partner_id=False): + self.config.open_session_cb() + session = self.config.current_session_id + account_receivable_id = ( + self.env.user.partner_id.property_account_receivable_id.id + ) + payment_methods = session.payment_method_ids + # Create order + order_data = { + "id": "0006-001-0010", + "to_invoice": True, + "data": { + "pricelist_id": self.pricelist.id, + "user_id": 1, + "name": "Order 0006-001-0010", + "partner_id": partner_id, + "amount_paid": 0.9, + "pos_session_id": session.id, + "lines": [ + [ + 0, + 0, + { + "product_id": self.pos_product.id, + "price_unit": 0.9, + "qty": 1, + "price_subtotal": 0.9, + "price_subtotal_incl": 0.9, + }, + ] + ], + "statement_ids": [ + [ + 0, + 0, + { + "journal_id": session.statement_ids[0].journal_id.id, + "amount": 0.9, + "name": fields.Datetime.now(), + "account_id": account_receivable_id, + "statement_id": session.statement_ids[0].id, + "payment_method_id": payment_methods.filtered( + lambda pm: pm.is_cash_count + and not pm.split_transactions + )[0].id, + }, + ] + ], + "creation_date": u"2018-09-27 15:51:03", + "amount_tax": 0, + "fiscal_position_id": False, + "uid": u"00001-001-0001", + "amount_return": 0, + "sequence_number": 1, + "amount_total": 0.9, + }, + } + + result = self.PosOrder.create_from_ui([order_data]) + order = self.PosOrder.browse(result[0]["id"]) + return order + + def test_no_default_partner(self): + order = self._create_order() + self.assertTrue(order) + self.assertFalse(order.partner_id) + + def test_no_default_partner_assigned_partner(self): + order = self._create_order(self.partner_01.id) + self.assertTrue(order) + self.assertEqual(order.partner_id, self.partner_01) + + def test_default_partner(self): + self.config.default_partner_id = self.partner_02 + order = self._create_order() + self.assertTrue(order) + self.assertEqual(order.partner_id, self.partner_02) + + def test_default_partner_assigned_partner(self): + self.config.default_partner_id = self.partner_02 + order = self._create_order(self.partner_01.id) + self.assertTrue(order) + self.assertEqual(order.partner_id, self.partner_01) diff --git a/pos_default_partner/views/pos_config.xml b/pos_default_partner/views/pos_config.xml new file mode 100644 index 0000000000..f1c206e11a --- /dev/null +++ b/pos_default_partner/views/pos_config.xml @@ -0,0 +1,28 @@ + + + + + pos.config.form (in pos_default_partner) + pos.config + + + +

Customers

+
+
+
+
+
+
+
+
+
+
diff --git a/setup/pos_default_partner/odoo/addons/pos_default_partner b/setup/pos_default_partner/odoo/addons/pos_default_partner new file mode 120000 index 0000000000..1cf907a179 --- /dev/null +++ b/setup/pos_default_partner/odoo/addons/pos_default_partner @@ -0,0 +1 @@ +../../../../pos_default_partner \ No newline at end of file diff --git a/setup/pos_default_partner/setup.py b/setup/pos_default_partner/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/pos_default_partner/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)