Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pms/models/folio_sale_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ def _prepare_invoice_line(self, qty=False, invoice_fpos=None, **optional_values)
self.ensure_one()
taxes = invoice_fpos.map_tax(
self.product_id.taxes_id.filtered(
lambda t, r=self.folio_id: t.company_id == r.env.company
lambda t, r=self.folio_id: t.company_id == r.company_id
)
)
if self.is_downpayment:
Expand Down
2 changes: 1 addition & 1 deletion pms/models/pms_reservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1523,7 +1523,7 @@ def _compute_tax_ids(self):
fiscal_position = record.folio_id.fiscal_position_id
record.tax_ids = fiscal_position.map_tax(
product.taxes_id.filtered(
lambda t, r=record: t.company_id == r.env.company
lambda t, r=record: t.company_id == r.company_id
)
)

Expand Down
2 changes: 1 addition & 1 deletion pms/wizards/folio_make_invoice_advance.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def _prepare_invoice_values(self, order, name, amount, line):
product = line.product_id
taxes = fiscal_position.map_tax(
product.taxes_id.filtered(
lambda t, r=order: t.company_id == r.env.company
lambda t, r=order: t.company_id == r.company_id
)
)
invoice_vals = {
Expand Down
6 changes: 1 addition & 5 deletions pms_partner_identification/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

==========================
PMS partner identification
==========================
Expand All @@ -17,7 +13,7 @@ PMS partner identification
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpms-lightgray.png?logo=github
Expand Down
1 change: 1 addition & 0 deletions pms_partner_identification/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"author": "Commit [Sun], Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": [
"base_vat",
"pms",
"partner_identification",
],
Expand Down
1 change: 0 additions & 1 deletion pms_partner_identification/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from . import res_partner_id_category
from . import pms_checkin_partner
from . import res_partner_id_number
from . import res_partner
41 changes: 34 additions & 7 deletions pms_partner_identification/models/pms_checkin_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def _get_partner_by_document(self, document_number, document_type):
.env["res.partner.id_number"]
.search(
[
("name", "=", document_number),
("name", "=ilike", document_number),
("category_id", "=", document_type.id),
]
)
Expand All @@ -168,6 +168,16 @@ def _get_partner_by_document(self, document_number, document_type):
self.sudo().env["res.partner"].search([("id", "=", number.partner_id.id)])
)

def _completed_partner_creation_fields(self):
self.ensure_one()
if (
not self.document_number
or not self.document_type
or not self.document_country_id
):
return False
return super()._completed_partner_creation_fields()

def set_partner_id(self):
for record in self:
if not record.partner_id:
Expand All @@ -179,6 +189,9 @@ def set_partner_id(self):
record.partner_id = partner
else:
super(PmsCheckinPartner, record).set_partner_id()
if record.partner_id:
if record._completed_partner_creation_fields():
record._create_or_update_partner_document()
return True

@api.model
Expand All @@ -194,25 +207,39 @@ def _checkin_manual_fields(self, country=False):

def _create_or_update_partner_document(self):
for record in self:
if (
not record.document_number
or not record.document_type
or not record.document_country_id
):
continue
document_id = (
self.sudo()
.env["res.partner.id_number"]
.search(
[
("partner_id", "=", record.partner_id.id),
("name", "=", record.document_number),
("category_id", "=", record.document_type.id),
("country_id", "=", record.document_country_id.id),
],
limit=1,
)
)
document_vals = record.get_document_vals()
if document_id:
document_vals = record.get_document_vals()
document_id.write(document_vals)
else:
document_vals = record.get_document_vals()
self.env["res.partner.id_number"].create(document_vals)

def action_on_board(self):
self._create_or_update_partner_document()
return super().action_on_board()
def write(self, vals):
res = super().write(vals)
document_fields = [
"document_number",
"document_type",
"document_expedition_date",
"document_country_id",
]
for record in self:
if vals.keys() & document_fields and record.partner_id:
record._create_or_update_partner_document()
return res
12 changes: 0 additions & 12 deletions pms_partner_identification/models/res_partner.py

This file was deleted.

26 changes: 10 additions & 16 deletions pms_partner_identification/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>PMS partner identification</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,21 +360,16 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="pms-partner-identification">
<h1 class="title">PMS partner identification</h1>


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="pms-partner-identification">
<h1>PMS partner identification</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:25dd50206da82f9763e687293f06900e6c44251c1141f7d4481c3bda81ec68b2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" 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 image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/pms/tree/16.0/pms_partner_identification"><img alt="OCA/pms" src="https://img.shields.io/badge/github-OCA%2Fpms-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/pms-16-0/pms-16-0-pms_partner_identification"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/pms&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" 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 image-reference" 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 image-reference" href="https://github.com/OCA/pms/tree/16.0/pms_partner_identification"><img alt="OCA/pms" src="https://img.shields.io/badge/github-OCA%2Fpms-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/pms-16-0/pms-16-0-pms_partner_identification"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/pms&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module extends the functionality of PMS to support various identification numbers in partners.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
Expand All @@ -390,34 +385,34 @@ <h1>PMS partner identification</h1>
</ul>
</div>
<div class="section" id="use-cases-context">
<h2><a class="toc-backref" href="#toc-entry-1">Use Cases / Context</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Use Cases / Context</a></h1>
<p>There are different needs within the hotel industry when it comes to complying with KYC (Know Your Customer) local laws which require collecting various data about the guests.
This module is part of a series that adds different fields to the PMS models, allowing the different localizations to use only the fields they need.</p>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/pms/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 to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/pms/issues/new?body=module:%20pms_partner_identification%0Aversion:%2016.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">
<h2><a class="toc-backref" href="#toc-entry-3">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-4">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
<ul class="simple">
<li>Commit [Sun]</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<ul class="simple">
<li>Jesús Ventosinos Mayor &lt;<a class="reference external" href="mailto:jesus&#64;roomdoo.com">jesus&#64;roomdoo.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-6">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" />
Expand All @@ -430,6 +425,5 @@ <h3><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h3>
</div>
</div>
</div>
</div>
</body>
</html>
13 changes: 11 additions & 2 deletions pms_partner_identification/tests/test_pms_checkin_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,28 @@ def test_add_partner_if_exists_from_checkin(self):

def test_compute_document_data(self):
"""Test document data is computed from partner"""

self.host2 = self.env["res.partner"].create(
{
"name": "Miguel",
"email": "miguel@example.com",
"birthdate_date": "1995-12-10",
"gender": "male",
}
)
self.env["res.partner.id_number"].create(
{
"name": "67890",
"category_id": self.doc_type.id,
"partner_id": self.host1.id,
"partner_id": self.host2.id,
"valid_from": "2023-02-01",
"country_id": self.country.id,
}
)

new_checkin = self.env["pms.checkin.partner"].create(
{
"partner_id": self.host1.id,
"partner_id": self.host2.id,
"reservation_id": self.reservation_1.id,
}
)
Expand Down