-
-
Notifications
You must be signed in to change notification settings - Fork 596
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
218 additions
and
180 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
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 <roberto.fichera@levelprime.com> | ||
* Lorenzo Battistini (https://takobi.online) | ||
* Dhara Solanki <dhara.solanki@initos.com> |
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,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; | ||
}); |
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.