-
-
Notifications
You must be signed in to change notification settings - Fork 621
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] pos_partner_firstname: Migration 17.0
Refactoring to OWL 2.0 Disabling an extra connection to server
- Loading branch information
Showing
13 changed files
with
140 additions
and
193 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 |
---|---|---|
|
@@ -85,6 +85,7 @@ Contributors | |
- Lorenzo Battistini | ||
(`https://takobi.online <https://takobi.online>`__) | ||
- Dhara Solanki <[email protected]> | ||
- Enric Tobella (`https://www.dixmit.com <https://www.dixmit.com>`__) | ||
|
||
Maintainers | ||
----------- | ||
|
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,2 @@ | ||
from . import res_partner | ||
from . import pos_session | ||
from . import pos_config |
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,16 @@ | ||
# Copyright 2024 Dixmit | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class PosConfig(models.Model): | ||
_inherit = "pos.config" | ||
|
||
partner_names_order = fields.Char(compute="_compute_partner_names_order") | ||
|
||
@api.depends() | ||
def _compute_partner_names_order(self): | ||
order = self.env["res.partner"]._get_names_order() | ||
for record in self: | ||
record.partner_names_order = order |
This file was deleted.
Oops, something went wrong.
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,3 +1,4 @@ | ||
- Roberto Fichera \<<[email protected]>\> | ||
- Lorenzo Battistini (<https://takobi.online>) | ||
- Dhara Solanki \<<[email protected]>\> | ||
- Enric Tobella (<https://www.dixmit.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
61 changes: 61 additions & 0 deletions
61
pos_partner_firstname/static/src/app/PartnerDetailsEdit.esm.js
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,61 @@ | ||
/** @odoo-module **/ | ||
import {ErrorPopup} from "@point_of_sale/app/errors/popups/error_popup"; | ||
import {PartnerDetailsEdit} from "@point_of_sale/app/screens/partner_list/partner_editor/partner_editor"; | ||
import {_t} from "@web/core/l10n/translation"; | ||
import {patch} from "@web/core/utils/patch"; | ||
import {useService} from "@web/core/utils/hooks"; | ||
|
||
patch(PartnerDetailsEdit.prototype, { | ||
setup() { | ||
super.setup(...arguments); | ||
this.popup = useService("popup"); | ||
this.partner_names_order = this.pos.config.partner_names_order; | ||
this.changes.is_company = this.props.partner.is_company; | ||
this.changes.firstname = this.props.partner.firstname; | ||
this.changes.lastname = this.props.partner.lastname; | ||
}, | ||
get isCompanyIcon() { | ||
if (this.changes.is_company) { | ||
return "fa-building"; | ||
} | ||
return "fa-user"; | ||
}, | ||
toggleIsCompany() { | ||
this.changes.is_company = !this.changes.is_company; | ||
}, | ||
checkPartnerPersonName() { | ||
/* We add this hook in order to check second last name later */ | ||
return !this.changes.firstname && !this.changes.lastname; | ||
}, | ||
saveChanges() { | ||
if (this.changes.is_company) { | ||
this.changes.lastname = this.changes.firstname = undefined; | ||
} else { | ||
if (this.checkPartnerPersonName()) { | ||
return this.popup.add(ErrorPopup, { | ||
title: _t("Missing information"), | ||
body: _t("Customer firstname or lastname is required"), | ||
}); | ||
} | ||
this.changes.name = this._updatePartnerName(this.changes); | ||
} | ||
super.saveChanges(); | ||
}, | ||
_updatePartnerName({lastname, firstname}) { | ||
let name = null; | ||
if (!lastname) { | ||
return firstname; | ||
} | ||
if (!firstname) { | ||
return lastname; | ||
} | ||
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(); | ||
}, | ||
}); |
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,3 @@ | ||
.partner_is_company { | ||
width: 64px; | ||
} |
51 changes: 51 additions & 0 deletions
51
pos_partner_firstname/static/src/app/PartnerDetailsEdit.xml
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,51 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates id="template" xml:space="preserve"> | ||
|
||
<t t-inherit="point_of_sale.PartnerDetailsEdit" t-inherit-mode="extension"> | ||
<xpath expr="//input[@name='name']" position="attributes"> | ||
<attribute name="t-att-readonly">!changes.is_company</attribute> | ||
</xpath> | ||
<xpath expr="//div[hasclass('partner-details-header')]" position="inside"> | ||
<img | ||
t-attf-class="fa {{isCompanyIcon}} fa-4x partner_is_company" | ||
t-on-click="toggleIsCompany" | ||
/> | ||
</xpath> | ||
|
||
<xpath expr="//div[hasclass('partner-details-box')]/t" position="before"> | ||
<!-- | ||
<div class="partner-detail col"> | ||
<label class="form-label label" for="is_company">Is Company</label> | ||
<input | ||
type='checkbox' | ||
class="detail form-control" | ||
name='is_company' | ||
t-att-checked="changes.is_company ? 'checked' : null" | ||
t-model="changes.is_company" | ||
/> | ||
</div> | ||
--> | ||
<div class="partner-detail col" t-if="!changes.is_company"> | ||
<label class="form-label label" for="is_company">Lastname</label> | ||
<input | ||
class="detail form-control" | ||
name="lastname" | ||
t-model="changes.lastname" | ||
t-att-value="changes.lastname || ''" | ||
placeholder="Lastname" | ||
/> | ||
</div> | ||
<div class="partner-detail col" t-if="!changes.is_company"> | ||
<label class="form-label label" for="is_company">Firstname</label> | ||
<input | ||
class="detail form-control" | ||
name="firstname" | ||
t-model="changes.firstname" | ||
t-att-value="changes.firstname || ''" | ||
placeholder="Firstname" | ||
/> | ||
</div> | ||
</xpath> | ||
</t> | ||
|
||
</templates> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.