mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[REF]Change possible_existing_customer field from boolean to many2one
This commit is contained in:
@@ -469,9 +469,11 @@ class PmsFolio(models.Model):
|
|||||||
ondelete="restrict",
|
ondelete="restrict",
|
||||||
)
|
)
|
||||||
|
|
||||||
is_possible_existing_customer = fields.Boolean(
|
is_possible_existing_customer_id = fields.Many2one(
|
||||||
string="Possible existing customer",
|
string="Possible existing customer",
|
||||||
compute="_compute_is_possible_existing_customer",
|
readonly=False,
|
||||||
|
store=True,
|
||||||
|
compute="_compute_is_possible_existing_customer_id",
|
||||||
)
|
)
|
||||||
|
|
||||||
add_possible_customer = fields.Boolean(string="Add possible Customer")
|
add_possible_customer = fields.Boolean(string="Add possible Customer")
|
||||||
@@ -682,16 +684,7 @@ class PmsFolio(models.Model):
|
|||||||
def _compute_partner_id(self):
|
def _compute_partner_id(self):
|
||||||
for folio in self:
|
for folio in self:
|
||||||
if folio.add_possible_customer:
|
if folio.add_possible_customer:
|
||||||
partner = False
|
folio.partner_id = folio.is_possible_existing_customer_id.id
|
||||||
if folio.email:
|
|
||||||
partner = self.env["res.partner"].search(
|
|
||||||
[("email", "=", folio.email)]
|
|
||||||
)
|
|
||||||
elif folio.mobile:
|
|
||||||
partner = self.env["res.partner"].search(
|
|
||||||
[("mobile", "=", folio.mobile)]
|
|
||||||
)
|
|
||||||
folio.partner_id = partner.id
|
|
||||||
elif folio.reservation_type == "out":
|
elif folio.reservation_type == "out":
|
||||||
folio.partner_id = False
|
folio.partner_id = False
|
||||||
elif folio.agency_id and folio.agency_id.invoice_to_agency:
|
elif folio.agency_id and folio.agency_id.invoice_to_agency:
|
||||||
@@ -1048,9 +1041,9 @@ class PmsFolio(models.Model):
|
|||||||
self._apply_document_id(record)
|
self._apply_document_id(record)
|
||||||
|
|
||||||
@api.depends("email", "mobile")
|
@api.depends("email", "mobile")
|
||||||
def _compute_is_possible_existing_customer(self):
|
def _compute_is_possible_existing_customer_id(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
self._apply_is_possible_existing_customer(record)
|
self._apply_is_possible_existing_customer_id(record)
|
||||||
|
|
||||||
def _search_invoice_ids(self, operator, value):
|
def _search_invoice_ids(self, operator, value):
|
||||||
if operator == "in" and value:
|
if operator == "in" and value:
|
||||||
@@ -1812,16 +1805,17 @@ class PmsFolio(models.Model):
|
|||||||
record.email = False
|
record.email = False
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _apply_is_possible_existing_customer(self, record):
|
def _apply_is_possible_existing_customer_id(self, record):
|
||||||
partner = False
|
|
||||||
if record.email and not record.partner_id:
|
if record.email and not record.partner_id:
|
||||||
partner = self.env["res.partner"].search([("email", "=", record.email)])
|
record.is_possible_existing_customer_id = (
|
||||||
|
self.env["res.partner"].search([("email", "=", record.email)]).id
|
||||||
|
)
|
||||||
elif record.mobile and not record.partner_id:
|
elif record.mobile and not record.partner_id:
|
||||||
partner = self.env["res.partner"].search([("mobile", "=", record.mobile)])
|
record.is_possible_existing_customer_id = (
|
||||||
if partner:
|
self.env["res.partner"].search([("mobile", "=", record.mobile)]).id
|
||||||
record.is_possible_existing_customer = True
|
)
|
||||||
else:
|
else:
|
||||||
record.is_possible_existing_customer = False
|
record.is_possible_existing_customer_id = False
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _apply_document_id(self, record):
|
def _apply_document_id(self, record):
|
||||||
|
|||||||
@@ -635,9 +635,11 @@ class PmsReservation(models.Model):
|
|||||||
ondelete="restrict",
|
ondelete="restrict",
|
||||||
)
|
)
|
||||||
|
|
||||||
is_possible_existing_customer = fields.Boolean(
|
is_possible_existing_customer_id = fields.Many2one(
|
||||||
string="Possible existing customer",
|
string="Possible existing customer",
|
||||||
compute="_compute_is_possible_existing_customer",
|
readonly=False,
|
||||||
|
store=True,
|
||||||
|
compute="_compute_is_possible_existing_customer_id",
|
||||||
)
|
)
|
||||||
|
|
||||||
add_possible_customer = fields.Boolean(string="Add possible Customer")
|
add_possible_customer = fields.Boolean(string="Add possible Customer")
|
||||||
@@ -829,16 +831,9 @@ class PmsReservation(models.Model):
|
|||||||
for reservation in self:
|
for reservation in self:
|
||||||
if not reservation.partner_id:
|
if not reservation.partner_id:
|
||||||
if reservation.add_possible_customer:
|
if reservation.add_possible_customer:
|
||||||
partner = False
|
reservation.partner_id = (
|
||||||
if reservation.email:
|
reservation.is_possible_existing_customer_id.id
|
||||||
partner = self.env["res.partner"].search(
|
)
|
||||||
[("email", "=", reservation.email)]
|
|
||||||
)
|
|
||||||
elif reservation.mobile:
|
|
||||||
partner = self.env["res.partner"].search(
|
|
||||||
[("mobile", "=", reservation.mobile)]
|
|
||||||
)
|
|
||||||
reservation.partner_id = partner.id
|
|
||||||
elif reservation.reservation_type == "out":
|
elif reservation.reservation_type == "out":
|
||||||
reservation.partner_id = False
|
reservation.partner_id = False
|
||||||
elif reservation.folio_id and reservation.folio_id.partner_id:
|
elif reservation.folio_id and reservation.folio_id.partner_id:
|
||||||
@@ -876,7 +871,7 @@ class PmsReservation(models.Model):
|
|||||||
}
|
}
|
||||||
self.env["res.partner.id_number"].create(number_values)
|
self.env["res.partner.id_number"].create(number_values)
|
||||||
reservation.partner_id = partner
|
reservation.partner_id = partner
|
||||||
else:
|
elif not reservation.partner_id:
|
||||||
reservation.partner_id = False
|
reservation.partner_id = False
|
||||||
|
|
||||||
@api.depends("checkin", "checkout")
|
@api.depends("checkin", "checkout")
|
||||||
@@ -1363,7 +1358,7 @@ class PmsReservation(models.Model):
|
|||||||
else:
|
else:
|
||||||
record.partner_name = record.out_service_description
|
record.partner_name = record.out_service_description
|
||||||
|
|
||||||
@api.depends("partner_id", "partner_id.email", "agency_id")
|
@api.depends("partner_id", "partner_id.email", "agency_id", "add_possible_customer")
|
||||||
def _compute_email(self):
|
def _compute_email(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
self.env["pms.folio"]._apply_email(record)
|
self.env["pms.folio"]._apply_email(record)
|
||||||
@@ -1460,9 +1455,9 @@ class PmsReservation(models.Model):
|
|||||||
self.env["pms.folio"]._apply_document_id(record)
|
self.env["pms.folio"]._apply_document_id(record)
|
||||||
|
|
||||||
@api.depends("email", "mobile")
|
@api.depends("email", "mobile")
|
||||||
def _compute_is_possible_existing_customer(self):
|
def _compute_is_possible_existing_customer_id(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
self.env["pms.folio"]._apply_is_possible_existing_customer(record)
|
self.env["pms.folio"]._apply_is_possible_existing_customer_id(record)
|
||||||
|
|
||||||
def _search_allowed_checkin(self, operator, value):
|
def _search_allowed_checkin(self, operator, value):
|
||||||
if operator not in ("=",):
|
if operator not in ("=",):
|
||||||
|
|||||||
@@ -59,13 +59,13 @@
|
|||||||
class="alert alert-warning"
|
class="alert alert-warning"
|
||||||
role="alert"
|
role="alert"
|
||||||
style="margin-bottom:0px;"
|
style="margin-bottom:0px;"
|
||||||
attrs="{'invisible': [('is_possible_existing_customer','=',False)]}"
|
attrs="{'invisible': [('is_possible_existing_customer_id','=',False)]}"
|
||||||
>
|
>
|
||||||
There is a customer with this email or mobile, do you want to add it to the reservation?
|
There is a customer with this email or mobile, do you want to add it to the reservation?
|
||||||
<field name="is_possible_existing_customer" invisible="1" />
|
<field name="is_possible_existing_customer_id" invisible="1" />
|
||||||
<field
|
<field
|
||||||
name="add_possible_customer"
|
name="add_possible_customer"
|
||||||
attrs="{'invisible': [('is_possible_existing_customer','=',False)]}"
|
attrs="{'invisible': [('is_possible_existing_customer_id','=',False)]}"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<sheet>
|
<sheet>
|
||||||
|
|||||||
@@ -120,13 +120,13 @@
|
|||||||
class="alert alert-warning"
|
class="alert alert-warning"
|
||||||
role="alert"
|
role="alert"
|
||||||
style="margin-bottom:0px;"
|
style="margin-bottom:0px;"
|
||||||
attrs="{'invisible': [('is_possible_existing_customer','=',False)]}"
|
attrs="{'invisible': [('is_possible_existing_customer_id','=',False)]}"
|
||||||
>
|
>
|
||||||
There is a customer with this email or mobile, do you want to add it to the reservation?
|
There is a customer with this email or mobile, do you want to add it to the reservation?
|
||||||
<field name="is_possible_existing_customer" invisible="1" />
|
<field name="is_possible_existing_customer_id" invisible="1" />
|
||||||
<field
|
<field
|
||||||
name="add_possible_customer"
|
name="add_possible_customer"
|
||||||
attrs="{'invisible': [('is_possible_existing_customer','=',False)]}"
|
attrs="{'invisible': [('is_possible_existing_customer_id','=',False)]}"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<sheet>
|
<sheet>
|
||||||
|
|||||||
Reference in New Issue
Block a user