-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] Migrate module pos_partner_firstname to v14.
- Loading branch information
Showing
13 changed files
with
223 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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| | ||
|
@@ -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. | ||
|
||
|
@@ -56,6 +68,7 @@ Contributors | |
|
||
* Roberto Fichera <[email protected]> | ||
* Lorenzo Battistini (https://takobi.online) | ||
* Dhara Solanki <[email protected]> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
* Roberto Fichera <[email protected]> | ||
* Lorenzo Battistini (https://takobi.online) | ||
* Dhara Solanki <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
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(lastname, 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; | ||
} | ||
return 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.props.partner.name = this._update_client_name( | ||
processedChanges.lastname, | ||
processedChanges.firstname | ||
); | ||
} | ||
} 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) { | ||
const lastname = this.props.partner.lastname | ||
? this.props.partner.lastname | ||
: ""; | ||
const firstname = this.props.partner.firstname | ||
? this.props.partner.firstname | ||
: ""; | ||
this.props.partner.name = this._update_client_name( | ||
lastname, | ||
firstname | ||
); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
Registries.Component.extend(ClientDetailsEdit, PosClientDetailsEdit); | ||
|
||
return ClientDetailsEdit; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}); |
Oops, something went wrong.