Skip to content

Commit

Permalink
[MIG] Migrate module pos_partner_firstname to v14.
Browse files Browse the repository at this point in the history
  • Loading branch information
robyf70 committed Apr 1, 2022
1 parent 546f6d9 commit 4815442
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 165 deletions.
2 changes: 1 addition & 1 deletion oca_dependencies.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# See https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#oca_dependencies-txt
partner-contact
11 changes: 6 additions & 5 deletions pos_partner_firstname/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ POS Partner Firstname
: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/12.0/pos_partner_firstname
:target: https://github.com/OCA/pos/tree/14.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-12-0/pos-12-0-pos_partner_firstname
:target: https://translation.odoo-community.org/projects/pos-14-0/pos-14-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/12.0
:target: https://runbot.odoo-community.org/runbot/184/14.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand All @@ -39,7 +39,7 @@ 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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/pos/issues/new?body=module:%20pos_partner_firstname%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/pos/issues/new?body=module:%20pos_partner_firstname%0Aversion:%2014.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.

Expand All @@ -56,6 +56,7 @@ Contributors

* Roberto Fichera <roberto.fichera@levelprime.com>
* Lorenzo Battistini (https://takobi.online)
* Dhara Solanki <dhara.solanki@initos.com>

Maintainers
~~~~~~~~~~~
Expand All @@ -78,6 +79,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-robyf70|

This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/12.0/pos_partner_firstname>`_ project on GitHub.
This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/14.0/pos_partner_firstname>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 2 additions & 1 deletion pos_partner_firstname/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Copyright 2021 initOS Gmbh
# 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": "12.0.1.1.1",
"version": "14.0.1.0.0",
"development_status": "Beta",
"category": "Point Of Sale",
"website": "https://github.com/OCA/pos",
Expand Down
6 changes: 0 additions & 6 deletions pos_partner_firstname/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
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)

@api.model
def get_names_order(self):
"""Allow POS frontend to retrieve 'partner_names_order'"""
Expand Down
1 change: 1 addition & 0 deletions pos_partner_firstname/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
* Roberto Fichera <roberto.fichera@levelprime.com>
* Lorenzo Battistini (https://takobi.online)
* Dhara Solanki <dhara.solanki@initos.com>
9 changes: 5 additions & 4 deletions pos_partner_firstname/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>POS Partner Firstname</title>
<style type="text/css">

Expand Down Expand Up @@ -367,7 +367,7 @@ <h1 class="title">POS Partner Firstname</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/pos/tree/12.0/pos_partner_firstname"><img alt="OCA/pos" src="https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/pos-12-0/pos-12-0-pos_partner_firstname"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/184/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/pos/tree/14.0/pos_partner_firstname"><img alt="OCA/pos" src="https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/pos-14-0/pos-14-0-pos_partner_firstname"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/184/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>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.</p>
<p><strong>Table of contents</strong></p>
Expand All @@ -387,7 +387,7 @@ <h1><a class="toc-backref" href="#id1">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/pos/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/pos/issues/new?body=module:%20pos_partner_firstname%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/pos/issues/new?body=module:%20pos_partner_firstname%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -403,6 +403,7 @@ <h2><a class="toc-backref" href="#id4">Contributors</a></h2>
<ul class="simple">
<li>Roberto Fichera &lt;<a class="reference external" href="mailto:roberto.fichera&#64;levelprime.com">roberto.fichera&#64;levelprime.com</a>&gt;</li>
<li>Lorenzo Battistini (<a class="reference external" href="https://takobi.online">https://takobi.online</a>)</li>
<li>Dhara Solanki &lt;<a class="reference external" href="mailto:dhara.solanki&#64;initos.com">dhara.solanki&#64;initos.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand All @@ -414,7 +415,7 @@ <h2><a class="toc-backref" href="#id5">Maintainers</a></h2>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/robyf70"><img alt="robyf70" src="https://github.com/robyf70.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/pos/tree/12.0/pos_partner_firstname">OCA/pos</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/pos/tree/14.0/pos_partner_firstname">OCA/pos</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
74 changes: 74 additions & 0 deletions pos_partner_firstname/static/src/js/ClientDetailsEdit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
odoo.define("pos_partner_firstname.ClientDetailsEdit", function (require) {
"use strict";

const {_t} = require("web.core");
const ClientDetailsEdit = require("point_of_sale.ClientDetailsEdit");
const Registries = require("point_of_sale.Registries");

const PosClientDetailsEdit = (ClientDetailsEdit) =>
class extends ClientDetailsEdit {
constructor() {
super(...arguments);
var self = this;
this.partner_names_order = "last_first";
this.rpc({
model: "res.partner",
method: "get_names_order",
args: [],
}).then(function (partner_names_order) {
if (partner_names_order) {
self.partner_names_order = partner_names_order;
}
});
}
_update_client_name(checked) {
if (!checked) {
var lastname = this.props.partner.lastname;
var firstname = this.props.partner.firstname;
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;
}
this.props.partner.name = name.trim();
}
}
saveChanges() {
if (!this.props.partner.is_company) {
if (!this.props.partner.firstname || !this.props.partner.lastname) {
return this.showPopup("ErrorPopup", {
title: _t("Both Customer First and Last Name Are Required"),
});
}
if (!this.props.partner.name) {
this._update_client_name(false);
}
}
super.saveChanges();
}
captureChange(event) {
super.captureChange(event);
if (event.target.name === "is_company") {
var checked = event.currentTarget.checked;
$(".is_person")
.toArray()
.forEach(function (el) {
$(el).css("display", !checked ? "block" : "none");
});

this.changes[event.target.name] = checked;
$(".client-name").attr("readonly", !checked);
if (!checked) {
this._update_client_name(checked);
}
}
}
};

Registries.Component.extend(ClientDetailsEdit, PosClientDetailsEdit);

return ClientDetailsEdit;
});
20 changes: 20 additions & 0 deletions pos_partner_firstname/static/src/js/ClientScreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
odoo.define("pos_partner_firstname.ClientScreen", function (require) {
"use strict";

var ClientScreenEdit = require("point_of_sale.ClientListScreen");
const Registries = require("point_of_sale.Registries");

const PosClientScreenEdit = (ClientScreenEdit) =>
class extends ClientScreenEdit {
back() {
super.back();
if (this.props.client) {
if (this.props.client.id == this.state.selectedClient.id) {
this.props.client.name = this.state.selectedClient.name;
}
}
}
};
Registries.Component.extend(ClientScreenEdit, PosClientScreenEdit);
return ClientScreenEdit;
});
79 changes: 0 additions & 79 deletions pos_partner_firstname/static/src/js/screens.js

This file was deleted.

Loading

0 comments on commit 4815442

Please sign in to comment.