[FIX]pms: add test data pricelists configuration

This commit is contained in:
Darío Lodeiros
2022-11-29 16:06:10 +01:00
parent 9ab43cfe49
commit 1d7bc062fe
15 changed files with 47 additions and 111 deletions

View File

@@ -21,6 +21,7 @@
</record>
<record id="product.list0" model="product.pricelist">
<field name="availability_plan_id" ref="main_pms_availability_plan" />
<field name="is_pms_available" eval="True" />
</record>
<!-- default partner simplified invoices -->
<record id="various_pms_partner" model="res.partner">

View File

@@ -1,6 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data noupdate="1">
<!--Availability Plan -->
<record id="demo_pms_availability" model="pms.availability.plan">
<field name="name">Availability Plan Demo</field>
</record>
<record id="demo_pms_availability_2" model="pms.availability.plan">
<field name="name">Availability Plan Demo</field>
</record>
<record id="product.list0" model="product.pricelist">
<field name="availability_plan_id" ref="demo_pms_availability_2" />
<field name="is_pms_available" eval="True" />
</record>
<!-- Company -->
<record id="pms_company1" model="res.company">
<field name="name">Alda Company</field>
@@ -15,13 +26,6 @@
<record id="base.main_company" model="res.company">
<field name="check_min_partner_data_invoice">False</field>
</record>
<!--Availability Plan -->
<record id="demo_pms_availability" model="pms.availability.plan">
<field name="name">Availability Plan Demo</field>
</record>
<record id="product.list0" model="product.pricelist">
<field name="availability_plan_id" ref="demo_pms_availability" />
</record>
<!-- Sequence -->
<record model="ir.sequence" id="seq_pms_folio2">
<field name="name">PMS Folio 2</field>
@@ -3758,6 +3762,7 @@
<field name="name">Public Pricelist Discount 10%</field>
<field name="pricelist_type" />
<field name="availability_plan_id" ref="demo_pms_availability" />
<field name="is_pms_available" eval="True" />
</record>
<record id="pms_pricelist_item_discount_10%" model="product.pricelist.item">

View File

@@ -3925,16 +3925,6 @@ msgstr "Documento"
msgid "Document Number"
msgstr "Nº de documento"
#. module: pms
#: model:ir.model.fields,field_description:pms.field_pms_checkin_partner__document_type
#: model:ir.model.fields,field_description:pms.field_pms_folio__document_type
#: model:ir.model.fields,field_description:pms.field_pms_property__vat_document_type
#: model:ir.model.fields,field_description:pms.field_pms_reservation__document_type
#: model:ir.model.fields,field_description:pms.field_res_partner__vat_document_type
#: model:ir.model.fields,field_description:pms.field_res_users__vat_document_type
msgid "Document Type"
msgstr "Tipo de documento"
#. module: pms
#: model_terms:ir.ui.view,arch_db:pms.traveller_report
msgid "Document number"
@@ -10724,14 +10714,6 @@ msgstr "Usuario que creo la ficha"
msgid "The value of the down payment amount must be positive."
msgstr "El valor del pago inicial debe ser positivo."
#. module: pms
#: model:ir.model.fields,help:pms.field_pms_property__vat_document_type
#: model:ir.model.fields,help:pms.field_res_partner__vat_document_type
#: model:ir.model.fields,help:pms.field_res_users__vat_document_type
msgid ""
"The vat document type of the partner,\n"
" set if is a fiscal document, passport, etc..."
msgstr ""
#. module: pms
#: model_terms:ir.ui.view,arch_db:pms.portal_my_folio

View File

@@ -3607,16 +3607,6 @@ msgstr ""
msgid "Document Number"
msgstr ""
#. module: pms
#: model:ir.model.fields,field_description:pms.field_pms_checkin_partner__document_type
#: model:ir.model.fields,field_description:pms.field_pms_folio__document_type
#: model:ir.model.fields,field_description:pms.field_pms_property__vat_document_type
#: model:ir.model.fields,field_description:pms.field_pms_reservation__document_type
#: model:ir.model.fields,field_description:pms.field_res_partner__vat_document_type
#: model:ir.model.fields,field_description:pms.field_res_users__vat_document_type
msgid "Document Type"
msgstr ""
#. module: pms
#: model_terms:ir.ui.view,arch_db:pms.traveller_report
msgid "Document number"
@@ -10414,15 +10404,6 @@ msgstr ""
msgid "The value of the down payment amount must be positive."
msgstr ""
#. module: pms
#: model:ir.model.fields,help:pms.field_pms_property__vat_document_type
#: model:ir.model.fields,help:pms.field_res_partner__vat_document_type
#: model:ir.model.fields,help:pms.field_res_users__vat_document_type
msgid ""
"The vat document type of the partner,\n"
" set if is a fiscal document, passport, etc..."
msgstr ""
#. module: pms
#: model_terms:ir.ui.view,arch_db:pms.portal_my_folio
msgid "There are currently no folios for your account."

View File

@@ -230,8 +230,8 @@ class PmsRoom(models.Model):
max_number = max(numbers_name) + 1
if max_number < 10:
max_number = str(max_number).zfill(2)
short_name += max_number
return short_name
short_name += str(max_number)
return str(short_name)
# Business methods

View File

@@ -67,7 +67,7 @@ class ProductPricelist(models.Model):
is_pms_available = fields.Boolean(
string="Available in PMS",
help="If the pricelist is available in the PMS",
default=True,
default=False,
)
def _compute_price_rule_get_items(

View File

@@ -192,14 +192,6 @@ class ResPartner(models.Model):
string="Days from Checkout",
help="Days from Checkout to generate the invoice",
)
vat_document_type = fields.Selection(
string="Document Type",
help="""The vat document type of the partner,
set if is a fiscal document, passport, etc...""",
selection=lambda self: self._selection_vat_document_type(),
compute="_compute_vat_document_type",
store=True,
)
residence_street = fields.Char(
string="Street of residence",
help="Street of the guest's residence",
@@ -246,20 +238,6 @@ class ResPartner(models.Model):
comodel_name="res.country.state",
)
@api.model
def _selection_vat_document_type(self):
vat_document_types = [
("vat", _("VAT")),
]
document_categories = self.env["res.partner.id_category"].search(
[
("is_vat_equivalent", "=", False),
]
)
for doc_type in document_categories:
vat_document_types.append((doc_type.name, doc_type.name))
return vat_document_types
@api.depends("pms_checkin_partner_ids", "pms_checkin_partner_ids.gender")
def _compute_gender(self):
if hasattr(super(), "_compute_gender"):
@@ -678,27 +656,6 @@ class ResPartner(models.Model):
]
)
@api.depends(
"vat", "id_numbers", "id_numbers.category_id", "id_numbers.vat_syncronized"
)
def _compute_vat_document_type(self):
self.vat_document_type = False
for record in self.filtered("vat"):
document = record.id_numbers.filtered("vat_syncronized")
if document:
if len(document) > 1:
raise ValidationError(
_("There is more than one document with vat syncronized")
)
if record.vat:
record.vat_document_type = (
document.category_id.name
if not document.category_id.is_vat_equivalent
else "vat"
)
else:
record.vat_document_type = "vat"
def action_partner_reservations(self):
self.ensure_one()
checkin_reservation_ids = (
@@ -857,18 +814,6 @@ class ResPartner(models.Model):
return True
return False
@api.constrains("vat_document_type")
def check_vat(self):
"""
Inherit constrain to allow set vat in
document ids like passport, etc...
"""
for partner in self:
if not partner.vat_document_type or partner.vat_document_type != "vat":
continue
elif hasattr(super(), "check_vat"):
super(ResPartner, partner).check_vat()
def unlink(self):
dummy, various_partner_id = self.env["ir.model.data"].get_object_reference(
"pms", "various_pms_partner"
@@ -946,7 +891,9 @@ class ResPartner(models.Model):
pricelists configuration (%s) to allow it for PMS,
or the pricelist selected for the agencies: %s
"""
),
",".join(self.mapped("property_product_pricelis.name")),
"".join(self.mapped("name")),
)
% (
",".join(self.mapped("property_product_pricelist.name")),
"".join(self.mapped("name")),
)
)

View File

@@ -31,3 +31,7 @@ class TestPms(common.SavepointCase):
"default_code": "RTC1",
}
)
for pricelist in self.env["product.pricelist"].search([]):
if not pricelist.availability_plan_id:
pricelist.availability_plan_id = self.availability_plan1.id
pricelist.is_pms_available = True

View File

@@ -24,6 +24,7 @@ class TestPmsRoomTypeAvailabilityRules(TestPms):
(4, self.pms_property2.id),
],
"availability_plan_id": self.availability_plan1.id,
"is_pms_available": True,
}
)
# pms.sale.channel
@@ -48,6 +49,13 @@ class TestPmsRoomTypeAvailabilityRules(TestPms):
"default_pricelist_id": self.pricelist2.id,
}
)
self.pricelist2.write(
{
"pms_property_ids": [
(4, self.pms_property3.id),
],
}
)
# pms.room.type
self.test_room_type_single = self.env["pms.room.type"].create(

View File

@@ -42,6 +42,7 @@ class TestPmsMultiproperty(TestPms):
(4, self.pms_property2.id),
],
"availability_plan_id": self.availability_plan1.id,
"is_pms_available": True,
}
)
self.availability_plan1 = self.env["pms.availability.plan"].create(
@@ -202,6 +203,7 @@ class TestPmsMultiproperty(TestPms):
(4, self.pms_property2.id),
],
"availability_plan_id": self.availability_plan1.id,
"is_pms_available": True,
}
)
# create new room_type
@@ -735,6 +737,7 @@ class TestPmsMultiproperty(TestPms):
(4, self.pms_property2.id),
],
"availability_plan_id": self.availability_plan1.id,
"is_pms_available": True,
}
)
self.room_type1 = self.env["pms.room.type"].create(
@@ -783,6 +786,7 @@ class TestPmsMultiproperty(TestPms):
"name": "Pricelist Test",
"pms_property_ids": [self.pms_property1.id, self.pms_property2.id],
"cancelation_rule_id": self.cancelation_rule1.id,
"is_pms_available": True,
}
)
@@ -801,6 +805,7 @@ class TestPmsMultiproperty(TestPms):
"name": "Pricelist",
"pms_property_ids": [self.pms_property2.id],
"availability_plan_id": self.availability_plan1.id,
"is_pms_available": True,
}
)
@@ -876,6 +881,7 @@ class TestPmsMultiproperty(TestPms):
(4, self.pms_property3.id),
],
"availability_plan_id": self.availability_plan1.id,
"is_pms_available": True,
}
)

View File

@@ -54,6 +54,7 @@ class TestPmsPricelist(TestPms):
"name": "pricelist_2",
"pms_property_ids": [self.pms_property1.id, self.pms_property2.id],
"availability_plan_id": self.availability_plan1.id,
"is_pms_available": True,
}
)
# product.product 1
@@ -742,6 +743,7 @@ class TestPmsPricelist(TestPms):
"pms_property_ids": tc["pms_property_ids"],
"item_ids": [item.id],
"availability_plan_id": self.availability_plan1.id,
"is_pms_available": True,
}
)
@@ -770,6 +772,7 @@ class TestPmsPricelist(TestPms):
"pms_property_ids": [self.pms_property1.id],
"item_ids": [item.id],
"availability_plan_id": self.availability_plan1.id,
"is_pms_available": True,
}
)
self.assertTrue(self.pricelist_test, "Pricelist not created.")

View File

@@ -2261,6 +2261,7 @@ class TestPmsReservations(TestPms):
"pms_property_ids": [self.pms_property1.id],
"cancelation_rule_id": self.cancelation_rule.id,
"availability_plan_id": self.availability_plan1.id,
"is_pms_available": True,
}
)
self.host1 = self.env["res.partner"].create(
@@ -2316,6 +2317,7 @@ class TestPmsReservations(TestPms):
"pms_property_ids": [self.pms_property1.id],
"cancelation_rule_id": self.cancelation_rule.id,
"availability_plan_id": self.availability_plan1.id,
"is_pms_available": True,
}
)
self.host1 = self.env["res.partner"].create(
@@ -2369,6 +2371,7 @@ class TestPmsReservations(TestPms):
"pms_property_ids": [self.pms_property1.id],
"cancelation_rule_id": self.cancelation_rule.id,
"availability_plan_id": self.availability_plan1.id,
"is_pms_available": True,
}
)
self.host1 = self.env["res.partner"].create(

View File

@@ -682,6 +682,7 @@ class TestPmsWizardMassiveChanges(TestPms):
{
"name": "test pricelist 2",
"availability_plan_id": self.availability_plan1.id,
"is_pms_available": True,
}
)
expected_pricelists = [self.pricelist1.id, pricelist2.id]

View File

@@ -65,12 +65,6 @@
<field name="is_agency" />
</group>
</xpath>
<xpath expr="//field[@name='vat']" position="after">
<field
name="vat_document_type"
attrs="{'invisible':[('vat','=',False)]}"
/>
</xpath>
<xpath
expr="//notebook/page[@name='sales_purchases']/group/group/field[@name='company_id']"
position="after"

View File

@@ -13,6 +13,7 @@ class TestPms(common.SavepointCase):
{
"name": "Pricelist 1",
"availability_plan_id": self.availability_plan1.id,
"is_pms_available": True,
}
)
self.company1 = self.env["res.company"].create(