From c2535c84800f2fb6829b269aaeb2cc031ca5a3f3 Mon Sep 17 00:00:00 2001 From: Roberto Fichera Date: Fri, 13 Dec 2019 19:32:12 +0100 Subject: [PATCH] [NEW][10.0] POS partner firstname support --- oca_dependencies.txt | 1 + pos_partner_firstname/README.rst | 82 ++++ pos_partner_firstname/__init__.py | 3 + pos_partner_firstname/__manifest__.py | 28 ++ pos_partner_firstname/models/__init__.py | 3 + pos_partner_firstname/models/res_partner.py | 15 + pos_partner_firstname/readme/CONTRIBUTORS.rst | 1 + pos_partner_firstname/readme/DESCRIPTION.rst | 2 + .../static/description/index.html | 422 ++++++++++++++++++ pos_partner_firstname/static/src/js/models.js | 8 + .../static/src/js/screens.js | 77 ++++ pos_partner_firstname/static/src/xml/pos.xml | 66 +++ pos_partner_firstname/views/assets.xml | 11 + 13 files changed, 719 insertions(+) create mode 100644 pos_partner_firstname/README.rst create mode 100644 pos_partner_firstname/__init__.py create mode 100644 pos_partner_firstname/__manifest__.py create mode 100644 pos_partner_firstname/models/__init__.py create mode 100644 pos_partner_firstname/models/res_partner.py create mode 100644 pos_partner_firstname/readme/CONTRIBUTORS.rst create mode 100644 pos_partner_firstname/readme/DESCRIPTION.rst create mode 100644 pos_partner_firstname/static/description/index.html create mode 100644 pos_partner_firstname/static/src/js/models.js create mode 100644 pos_partner_firstname/static/src/js/screens.js create mode 100644 pos_partner_firstname/static/src/xml/pos.xml create mode 100644 pos_partner_firstname/views/assets.xml diff --git a/oca_dependencies.txt b/oca_dependencies.txt index 4c894df8..780cffbd 100644 --- a/oca_dependencies.txt +++ b/oca_dependencies.txt @@ -1 +1,2 @@ stock-logistics-workflow +partner-contact diff --git a/pos_partner_firstname/README.rst b/pos_partner_firstname/README.rst new file mode 100644 index 00000000..04a7abed --- /dev/null +++ b/pos_partner_firstname/README.rst @@ -0,0 +1,82 @@ +===================== +POS Partner Firstname +===================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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/10.0/pos_partner_firstname + :alt: OCA/pos +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/pos-10-0/pos-10-0-pos_partner_firstname + :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/10.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +The module adds the support of the fields of the partner_firstname module within the point of sale interface, +allowing to view and edit them in the given customer 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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Roberto Fichera + +Contributors +~~~~~~~~~~~~ + +* Roberto Fichera + +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-robyf70| image:: https://github.com/robyf70.png?size=40px + :target: https://github.com/robyf70 + :alt: robyf70 + +Current `maintainer `__: + +|maintainer-robyf70| + +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_partner_firstname/__init__.py b/pos_partner_firstname/__init__.py new file mode 100644 index 00000000..23ac4f95 --- /dev/null +++ b/pos_partner_firstname/__init__.py @@ -0,0 +1,3 @@ +# coding=utf-8 + +from . import models diff --git a/pos_partner_firstname/__manifest__.py b/pos_partner_firstname/__manifest__.py new file mode 100644 index 00000000..922a9aeb --- /dev/null +++ b/pos_partner_firstname/__manifest__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Roberto Fichera +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "POS Partner Firstname", + "summary": "POS Support of partner firstname", + "version": "10.0.1.0.0", + "development_status": "Beta", + "category": "Point Of Sale", + "website": "https://github.com/OCA/pos", + "author": "Roberto Fichera, Odoo Community Association (OCA)", + "maintainers": ["robyf70"], + "license": "AGPL-3", + "application": False, + "installable": True, + "auto_install": True, + "depends": [ + "point_of_sale", + "partner_firstname", + ], + 'qweb': [ + 'static/src/xml/pos.xml' + ], + 'data': [ + 'views/assets.xml', + ], +} diff --git a/pos_partner_firstname/models/__init__.py b/pos_partner_firstname/models/__init__.py new file mode 100644 index 00000000..dd1c32cb --- /dev/null +++ b/pos_partner_firstname/models/__init__.py @@ -0,0 +1,3 @@ +# coding=utf-8 + +from . import res_partner diff --git a/pos_partner_firstname/models/res_partner.py b/pos_partner_firstname/models/res_partner.py new file mode 100644 index 00000000..28812c49 --- /dev/null +++ b/pos_partner_firstname/models/res_partner.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Roberto Fichera +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, models + + +class ResPartner(models.Model): + _inherit = 'res.partner' + + @api.model + def create_from_ui(self, partner): + if 'is_company' in partner: + partner['is_company'] = partner['is_company'] == 'true' + return super(ResPartner, self).create_from_ui(partner) diff --git a/pos_partner_firstname/readme/CONTRIBUTORS.rst b/pos_partner_firstname/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..1577ff91 --- /dev/null +++ b/pos_partner_firstname/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Roberto Fichera diff --git a/pos_partner_firstname/readme/DESCRIPTION.rst b/pos_partner_firstname/readme/DESCRIPTION.rst new file mode 100644 index 00000000..9bfb0cd6 --- /dev/null +++ b/pos_partner_firstname/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +The module adds the support of the fields of the partner_firstname module within the point of sale interface, +allowing to view and edit them in the given customer view. diff --git a/pos_partner_firstname/static/description/index.html b/pos_partner_firstname/static/description/index.html new file mode 100644 index 00000000..554d2386 --- /dev/null +++ b/pos_partner_firstname/static/description/index.html @@ -0,0 +1,422 @@ + + + + + + +POS Partner Firstname + + + +
+

POS Partner Firstname

+ + +

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

+

The module adds the support of the fields of the partner_firstname module within the point of sale interface, +allowing to view and edit them in the given customer 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 smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Roberto Fichera
  • +
+
+
+

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.

+

Current maintainer:

+

robyf70

+

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_partner_firstname/static/src/js/models.js b/pos_partner_firstname/static/src/js/models.js new file mode 100644 index 00000000..4d5051ca --- /dev/null +++ b/pos_partner_firstname/static/src/js/models.js @@ -0,0 +1,8 @@ +odoo.define('pos_partner_firstname.models', function (require) { + "use strict"; + + var models = require('point_of_sale.models'); + + models.load_fields("res.partner", ["is_company", "firstname", "lastname"]); + +}); diff --git a/pos_partner_firstname/static/src/js/screens.js b/pos_partner_firstname/static/src/js/screens.js new file mode 100644 index 00000000..4e0975ab --- /dev/null +++ b/pos_partner_firstname/static/src/js/screens.js @@ -0,0 +1,77 @@ +odoo.define('pos_partner_firstname.screens', function (require) { + "use strict"; + + var Screens = require('point_of_sale.screens'); + var Model = require('web.Model'); + + Screens.ClientListScreenWidget.include({ + + partner_names_order: 'last_first', + + init: function(parent, options){ + var self = this; + this._super(parent, options); + var P = new Model('ir.config_parameter'); + P.call('get_param', ['partner_names_order']).then(function(partner_names_order) { + if (partner_names_order != false) { + self.partner_names_order = partner_names_order; + } + }); + }, + + _update_client_name: function(checked){ + if (!checked) { + var lastname = $('.lastname').val() || ''; + var firstname = $('.firstname').val() || ''; + var name = null; + if (this.partner_names_order === 'last_first_comma') { + name = lastname + ', ' + firstname; + } + else if (this.partner_names_order === 'first_last') { + name = firstname + ' ' + lastname; + } + else + { + name = lastname + ' ' + firstname; + } + $('.client-name').val(name); + } + }, + + display_client_details: function(visibility,partner,clickpos){ + var self = this; + this._super.apply(self, arguments); + if (visibility === 'edit') { + if (!$('.is_company').is(':checked')) { + $('.client-name').attr('readonly', true); + } + this.$('.person').off('keyup').on('keyup', function(event) { + var checked = $('.is_company').is(':checked'); + $('.client-name').attr('readonly', !checked); + if (!checked) { + self._update_client_name(checked); + } + }); + this.$('.checkbox').off('change').on('change', function(event) { + this.value = this.checked; + if (this.name === 'is_company') { + var checked = this.checked; + $('.is_person').toArray().forEach(function(el) { + $(el).css('display', !checked ? 'block' : 'none'); + }); + var clientname = $('.client-name'); + clientname.attr('readonly', !checked); + if (!checked) { + self._update_client_name(checked); + } + else + { + $('.lastname').val(clientname.val()); + $('.firstname').val(''); + } + }; + }); + } + }, + }); +}); diff --git a/pos_partner_firstname/static/src/xml/pos.xml b/pos_partner_firstname/static/src/xml/pos.xml new file mode 100644 index 00000000..12e7f7e8 --- /dev/null +++ b/pos_partner_firstname/static/src/xml/pos.xml @@ -0,0 +1,66 @@ + + + + + +
+
+ Company + +
+
+
+ + +
+
+ First Name + +
+
+
+
+ + +
+
+ Last Name + +
+
+
+
+
+ + + +
+
+ Company + +
+
+
+ +
+
+ First Name + +
+
+
+ +
+
+ Last Name + +
+
+
+
+ +
diff --git a/pos_partner_firstname/views/assets.xml b/pos_partner_firstname/views/assets.xml new file mode 100644 index 00000000..9b9d6b16 --- /dev/null +++ b/pos_partner_firstname/views/assets.xml @@ -0,0 +1,11 @@ + + + +