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 11, 2022
1 parent b339886 commit 6abd777
Show file tree
Hide file tree
Showing 13 changed files with 218 additions and 180 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
23 changes: 18 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 @@ -33,13 +33,25 @@ allowing to view and edit them in the given customer view.
.. contents::
:local:

Known issues / Roadmap
======================

Some features we would need to cover in the future:

* When the field ``name`` is set to be readonly the module must prevent the field to have red border and the possibility to have the cursor, and change the background color of the name field could be user friendly.
* In back office, the name *OR* the surname is mandatory. In front office, the name *AND* the surname is mandatory. Should be great to have a similar behaviour.
* In back office, default is "company". In front office, default is "individual". The behaviour should however depend by *B2B* or *B2C* setting in order to set the right default.
* In individual mode, in back office, it is possible to select the parent company. In individual mode, in front office, it is not possible. However we would also have to say that odoo doesn't permit the parent company selection.

The ticket referencing the above information can be read at https://github.com/OCA/pos/pull/775

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 +68,7 @@ Contributors

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

Maintainers
~~~~~~~~~~~
Expand All @@ -78,6 +91,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>
8 changes: 8 additions & 0 deletions pos_partner_firstname/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Some features we would need to cover in the future:

* When the field ``name`` is set to be readonly the module must prevent the field to have red border and the possibility to have the cursor, and change the background color of the name field could be user friendly.
* In back office, the name *OR* the surname is mandatory. In front office, the name *AND* the surname is mandatory. Should be great to have a similar behaviour.
* In back office, default is "company". In front office, default is "individual". The behaviour should however depend by *B2B* or *B2C* setting in order to set the right default.
* In individual mode, in back office, it is possible to select the parent company. In individual mode, in front office, it is not possible. However we would also have to say that odoo doesn't permit the parent company selection.

The ticket referencing the above information can be read at https://github.com/OCA/pos/pull/775
41 changes: 27 additions & 14 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,54 +367,67 @@ <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>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#bug-tracker" id="id1">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id3">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id4">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id5">Maintainers</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="id1">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#id1">Known issues / Roadmap</a></h1>
<p>Some features we would need to cover in the future:</p>
<ul class="simple">
<li>When the field <tt class="docutils literal">name</tt> is set to be readonly the module must prevent the field to have red border and the possibility to have the cursor, and change the background color of the name field could be user friendly.</li>
<li>In back office, the name <em>OR</em> the surname is mandatory. In front office, the name <em>AND</em> the surname is mandatory. Should be great to have a similar behaviour.</li>
<li>In back office, default is “company”. In front office, default is “individual”. The behaviour should however depend by <em>B2B</em> or <em>B2C</em> setting in order to set the right default.</li>
<li>In individual mode, in back office, it is possible to select the parent company. In individual mode, in front office, it is not possible. However we would also have to say that odoo doesn’t permit the parent company selection.</li>
</ul>
<p>The ticket referencing the above information can be read at <a class="reference external" href="https://github.com/OCA/pos/pull/775">https://github.com/OCA/pos/pull/775</a></p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id1">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#id2">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">
<h1><a class="toc-backref" href="#id2">Credits</a></h1>
<h1><a class="toc-backref" href="#id3">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id3">Authors</a></h2>
<h2><a class="toc-backref" href="#id4">Authors</a></h2>
<ul class="simple">
<li>Roberto Fichera</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id4">Contributors</a></h2>
<h2><a class="toc-backref" href="#id5">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">
<h2><a class="toc-backref" href="#id5">Maintainers</a></h2>
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</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
95 changes: 95 additions & 0 deletions pos_partner_firstname/static/src/js/ClientDetailsEdit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
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);
this.rpc({
model: "res.partner",
method: "get_names_order",
args: [],
}).then((res) => (this.partner_names_order = res || "last_first"));
}
_update_client_name(checked) {
if (!checked) {
const lastname = this.props.partner.lastname
? this.props.partner.lastname
: "";
const firstname = this.props.partner.firstname
? this.props.partner.firstname
: "";
let 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() {
const processedChanges = {};
for (const [key, value] of Object.entries(this.changes)) {
if (this.intFields.includes(key)) {
processedChanges[key] = parseInt(value) || false;
} else {
processedChanges[key] = value;
}
}
const checked = $(".is_company").is(":checked");
if (!checked) {
if (
(!this.props.partner.firstname &&
!processedChanges.firstname) ||
processedChanges.firstname === "" ||
(!this.props.partner.lastname && !processedChanges.lastname) ||
processedChanges.lastname === ""
) {
return this.showPopup("ErrorPopup", {
title: _t("Both Customer First and Last Name Are Required"),
});
}
if (
(!this.props.partner.name && !processedChanges.name) ||
processedChanges.name === ""
) {
this._update_client_name(false);
}
} else if (
processedChanges.is_company &&
(processedChanges.firstname || processedChanges.lastname)
) {
this.changes.lastname = this.changes.firstname = undefined;
}
super.saveChanges();
}
captureChange(event) {
super.captureChange(event);
if (event.target.name === "is_company") {
const 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";

const ClientScreen = require("point_of_sale.ClientListScreen");
const Registries = require("point_of_sale.Registries");

const PosClientScreen = (ClientScreen) =>
class extends ClientScreen {
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(ClientScreen, PosClientScreen);
return ClientScreen;
});
4 changes: 2 additions & 2 deletions pos_partner_firstname/static/src/js/models.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
odoo.define("pos_partner_firstname.models", function (require) {
"use strict";

var models = require("point_of_sale.models");

const models = require("point_of_sale.models");
models.load_fields("res.partner", ["is_company", "firstname", "lastname"]);
return models;
});
Loading

0 comments on commit 6abd777

Please sign in to comment.