mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]added tests for pms_reservation, pms_folio and pms_checkin_partner
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from odoo import api, fields, models, _
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
@@ -16,26 +16,22 @@ class SeveralPartners(models.TransientModel):
|
||||
)
|
||||
|
||||
checkin_partner_id = fields.Many2one(
|
||||
string="Checkin Partner",
|
||||
comodel_name="pms.checkin.partner"
|
||||
string="Checkin Partner", comodel_name="pms.checkin.partner"
|
||||
)
|
||||
possible_existing_customer_ids = fields.Many2many(
|
||||
string="Customers",
|
||||
comodel_name="res.partner",
|
||||
store=True,
|
||||
readonly=False
|
||||
string="Customers", comodel_name="res.partner", store=True, readonly=False
|
||||
)
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
res = super(SeveralPartners, self).default_get(fields)
|
||||
possibles_customers_ids = self.env["res.partner"].browse(self._context.get("possible_existing_customer_ids"))
|
||||
res.update(
|
||||
{
|
||||
"possible_existing_customer_ids": possibles_customers_ids
|
||||
}
|
||||
possibles_customers_ids = self.env["res.partner"].browse(
|
||||
self._context.get("possible_existing_customer_ids")
|
||||
)
|
||||
res.update({"possible_existing_customer_ids": possibles_customers_ids})
|
||||
reservation = self.env["pms.reservation"].browse(
|
||||
self._context.get("reservation_id")
|
||||
)
|
||||
reservation = self.env["pms.reservation"].browse(self._context.get("reservation_id"))
|
||||
if reservation:
|
||||
res.update(
|
||||
{
|
||||
@@ -49,7 +45,9 @@ class SeveralPartners(models.TransientModel):
|
||||
"folio_id": folio.id,
|
||||
}
|
||||
)
|
||||
checkin_partner = self.env["pms.checkin.partner"].browse(self._context.get("checkin_partner_id"))
|
||||
checkin_partner = self.env["pms.checkin.partner"].browse(
|
||||
self._context.get("checkin_partner_id")
|
||||
)
|
||||
if checkin_partner:
|
||||
res.update(
|
||||
{
|
||||
@@ -61,12 +59,20 @@ class SeveralPartners(models.TransientModel):
|
||||
def add_partner(self):
|
||||
for record in self:
|
||||
if len(record.possible_existing_customer_ids) == 0:
|
||||
raise ValidationError(_("You must select a client to be able to add it to the reservation "))
|
||||
raise ValidationError(
|
||||
_(
|
||||
"You must select a client to be able to add it to the reservation "
|
||||
)
|
||||
)
|
||||
if len(record.possible_existing_customer_ids) > 1:
|
||||
raise ValidationError(_("Only one customer can be added to the reservation"))
|
||||
raise ValidationError(
|
||||
_("Only one customer can be added to the reservation")
|
||||
)
|
||||
if record.reservation_id:
|
||||
record.reservation_id.partner_id = record.possible_existing_customer_ids
|
||||
elif record.folio_id:
|
||||
record.folio_id.partner_id = record.possible_existing_customer_ids
|
||||
elif record.checkin_partner_id:
|
||||
record.checkin_partner_id.partner_id = record.possible_existing_customer_ids
|
||||
record.checkin_partner_id.partner_id = (
|
||||
record.possible_existing_customer_ids
|
||||
)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<form string="Possibles customers" colspan="4">
|
||||
<h6> Choose a customer if you want to add it to the reservation</h6>
|
||||
<group>
|
||||
<field name="possible_existing_customer_ids"/>
|
||||
<field name="possible_existing_customer_ids" />
|
||||
</group>
|
||||
<footer>
|
||||
<button
|
||||
@@ -25,7 +25,7 @@
|
||||
<field name="name">Open Several Partners</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">pms.several.partners.wizard</field>
|
||||
<field name="view_id" ref="several_partners_wizard"/>
|
||||
<field name="view_id" ref="several_partners_wizard" />
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user