[IMP] Base partner fields compute on folio&reservation

This commit is contained in:
Dario Lodeiros
2021-06-19 10:02:06 +02:00
parent 6581d0fd38
commit ce4063c735
11 changed files with 119 additions and 49 deletions

View File

@@ -317,14 +317,26 @@ class PmsFolio(models.Model):
],
tracking=True,
)
partner_name = fields.Char(
string="Name",
help="Customer Name",
store=True,
readonly=False,
compute="_compute_partner_name",
)
email = fields.Char(
string="E-mail", help="Partner Email", related="partner_id.email"
string="E-mail",
help="Customer E-mail",
store=True,
readonly=False,
compute="_compute_email",
)
mobile = fields.Char(
string="Mobile", help="Partner Mobile", related="partner_id.mobile"
)
phone = fields.Char(
string="Phone", help="Partner Phone", related="partner_id.phone"
string="Mobile",
help="Customer Mobile",
store=True,
readonly=False,
compute="_compute_mobile",
)
partner_internal_comment = fields.Text(
string="Internal Partner Notes",
@@ -734,6 +746,30 @@ class PmsFolio(models.Model):
else:
order.invoice_status = "no"
@api.depends("partner_id", "partner_id.name")
def _compute_partner_name(self):
for record in self:
if record.partner_id and not record.partner_name:
record.partner_name = record.partner_id.name
elif not record.partner_name:
record.partner_name = False
@api.depends("partner_id", "partner_id.email")
def _compute_email(self):
for record in self:
if record.partner_id and not record.email:
record.email = record.partner_id.email
elif not record.email:
record.email = False
@api.depends("partner_id", "partner_id.mobile")
def _compute_mobile(self):
for record in self:
if record.partner_id and not record.mobile:
record.mobile = record.partner_id.mobile
elif not record.mobile:
record.mobile = False
@api.depends("sale_line_ids.price_total")
def _compute_amount_all(self):
"""

View File

@@ -459,20 +459,26 @@ class PmsReservation(models.Model):
help="Used to notify is the reservation folio has other reservations/services",
compute="_compute_shared_folio",
)
partner_name = fields.Char(
string="Name",
help="Customer Name",
store=True,
readonly=False,
compute="_compute_partner_name",
)
partner_email = fields.Char(
string="E-mail",
help="E-mail of the checkin partner associated to the reservation",
related="partner_id.email",
help="Customer E-mail",
store=True,
readonly=False,
compute="_compute_email",
)
partner_mobile = fields.Char(
string="Mobile",
help="Mobile of the checkin partner associated to the reservation",
related="partner_id.mobile",
)
partner_phone = fields.Char(
string="Phone",
help="Phone of the checkin partner associated to the reservation",
related="partner_id.phone",
help="Customer Mobile",
store=True,
readonly=False,
compute="_compute_mobile",
)
partner_internal_comment = fields.Text(
string="Internal Partner Notes",
@@ -483,7 +489,6 @@ class PmsReservation(models.Model):
string="Partner Requests",
help="Guest requests",
)
folio_internal_comment = fields.Text(
string="Internal Folio Notes",
help="Internal comment for folio",
@@ -1147,6 +1152,30 @@ class PmsReservation(models.Model):
else:
record.shared_folio = False
@api.depends("partner_id", "partner_id.name")
def _compute_partner_name(self):
for record in self:
if record.partner_id and not record.partner_name:
record.partner_name = record.partner_id.name
elif not record.partner_name:
record.partner_name = False
@api.depends("partner_id", "partner_id.email")
def _compute_email(self):
for record in self:
if record.partner_id and not record.partner_email:
record.partner_email = record.partner_id.email
elif not record.partner_email:
record.partner_email = False
@api.depends("partner_id", "partner_id.mobile")
def _compute_mobile(self):
for record in self:
if record.partner_id and not record.partner_mobile:
record.partner_mobile = record.partner_id.mobile
elif not record.partner_mobile:
record.partner_mobile = False
def _compute_checkin_partner_count(self):
for record in self:
if record.reservation_type != "out":

View File

@@ -263,7 +263,6 @@ class ResPartner(models.Model):
args = []
domain = [
"|",
("phone", operator, name),
("mobile", operator, name),
]
partners = self.search(

View File

@@ -11,7 +11,7 @@
>
<div
t-field="doc.partner_invoice_ids[0]"
t-options='{"widget": "contact", "fields": ["address", "name", "phone"], "no_marker": True, "phone_icons": True}'
t-options='{"widget": "contact", "fields": ["address", "name", "mobile"], "no_marker": True, "phone_icons": True}'
/>
</t>
</div>

View File

@@ -51,7 +51,7 @@ class TestPmsCheckinPartner(TestPms):
self.host1 = self.env["res.partner"].create(
{
"name": "Miguel",
"phone": "654667733",
"mobile": "654667733",
"email": "miguel@example.com",
"birthdate_date": "1995-12-10",
"gender": "male",
@@ -107,7 +107,7 @@ class TestPmsCheckinPartner(TestPms):
host2 = self.env["res.partner"].create(
{
"name": "Carlos",
"phone": "654667733",
"mobile": "654667733",
"email": "carlos@example.com",
"birthdate_date": "1995-12-10",
"gender": "male",
@@ -224,7 +224,7 @@ class TestPmsCheckinPartner(TestPms):
host2 = self.env["res.partner"].create(
{
"name": "Carlos",
"phone": "654667733",
"mobile": "654667733",
"email": "carlos@example.com",
"birthdate_date": "1995-12-10",
"gender": "male",
@@ -241,7 +241,7 @@ class TestPmsCheckinPartner(TestPms):
host3 = self.env["res.partner"].create(
{
"name": "Enmanuel",
"phone": "654667733",
"mobile": "654667733",
"email": "enmanuel@example.com",
"birthdate_date": "1995-12-10",
"gender": "male",
@@ -258,7 +258,7 @@ class TestPmsCheckinPartner(TestPms):
host4 = self.env["res.partner"].create(
{
"name": "Enrique",
"phone": "654667733",
"mobile": "654667733",
"email": "enrique@example.com",
"birthdate_date": "1995-12-10",
"gender": "male",
@@ -314,7 +314,7 @@ class TestPmsCheckinPartner(TestPms):
self.host2 = self.env["res.partner"].create(
{
"name": "Carlos",
"phone": "654667733",
"mobile": "654667733",
"email": "carlos@example.com",
"birthdate_date": "1995-12-10",
"gender": "male",
@@ -331,7 +331,7 @@ class TestPmsCheckinPartner(TestPms):
self.host3 = self.env["res.partner"].create(
{
"name": "Enmanuel",
"phone": "654667733",
"mobile": "654667733",
"email": "enmanuel@example.com",
"birthdate_date": "1995-12-10",
"gender": "male",
@@ -389,7 +389,7 @@ class TestPmsCheckinPartner(TestPms):
self.host2 = self.env["res.partner"].create(
{
"name": "Carlos",
"phone": "654667733",
"mobile": "654667733",
"email": "carlos@example.com",
"birthdate_date": "1995-12-10",
"gender": "male",
@@ -442,7 +442,7 @@ class TestPmsCheckinPartner(TestPms):
self.host2 = self.env["res.partner"].create(
{
"name": "Carlos",
"phone": "654667733",
"mobile": "654667733",
"email": "carlos@example.com",
"birthdate_date": "1995-12-10",
"gender": "male",
@@ -459,7 +459,7 @@ class TestPmsCheckinPartner(TestPms):
self.host3 = self.env["res.partner"].create(
{
"name": "Enmanuel",
"phone": "654667733",
"mobile": "654667733",
"email": "enmanuel@example.com",
"birthdate_date": "1995-12-10",
"gender": "male",
@@ -476,7 +476,7 @@ class TestPmsCheckinPartner(TestPms):
self.host4 = self.env["res.partner"].create(
{
"name": "Enrique",
"phone": "654667733",
"mobile": "654667733",
"email": "enrique@example.com",
"birthdate_date": "1995-12-10",
"gender": "male",
@@ -889,7 +889,7 @@ class TestPmsCheckinPartner(TestPms):
host = self.env["res.partner"].create(
{
"name": "Ricardo",
"phone": "666555666",
"mobile": "666555666",
"email": "ricardo@example.com",
"birthdate_date": "1995-11-14",
"gender": "male",

View File

@@ -832,7 +832,7 @@ class TestPmsReservations(common.SavepointCase):
host = self.env["res.partner"].create(
{
"name": "Miguel",
"phone": "654667733",
"mobile": "654667733",
"email": "miguel@example.com",
"birthdate_date": "1995-12-10",
"gender": "male",
@@ -1015,7 +1015,7 @@ class TestPmsReservations(common.SavepointCase):
host = self.env["res.partner"].create(
{
"name": "Miguel",
"phone": "654667733",
"mobile": "654667733",
"email": "miguel@example.com",
"birthdate_date": "1995-12-10",
"gender": "male",
@@ -1076,7 +1076,7 @@ class TestPmsReservations(common.SavepointCase):
host = self.env["res.partner"].create(
{
"name": "Miguel",
"phone": "654667733",
"mobile": "654667733",
"email": "miguel@example.com",
}
)
@@ -1292,7 +1292,7 @@ class TestPmsReservations(common.SavepointCase):
self.host1 = self.env["res.partner"].create(
{
"name": "Miguel",
"phone": "654667733",
"mobile": "654667733",
"email": "miguel@example.com",
"birthdate_date": "1995-12-10",
"gender": "male",
@@ -1309,7 +1309,7 @@ class TestPmsReservations(common.SavepointCase):
self.host2 = self.env["res.partner"].create(
{
"name": "Brais",
"phone": "654437733",
"mobile": "654437733",
"email": "brais@example.com",
"birthdate_date": "1995-12-10",
"gender": "male",
@@ -1661,14 +1661,14 @@ class TestPmsReservations(common.SavepointCase):
self.host1 = self.env["res.partner"].create(
{
"name": "Miguel",
"phone": "654667733",
"mobile": "654667733",
"email": "miguel@example.com",
}
)
self.host2 = self.env["res.partner"].create(
{
"name": "Brais",
"phone": "654437733",
"mobile": "654437733",
"email": "brais@example.com",
}
)
@@ -1709,14 +1709,14 @@ class TestPmsReservations(common.SavepointCase):
self.host1 = self.env["res.partner"].create(
{
"name": "Miguel",
"phone": "654667733",
"mobile": "654667733",
"email": "miguel@example.com",
}
)
self.host2 = self.env["res.partner"].create(
{
"name": "Brais",
"phone": "654437733",
"mobile": "654437733",
"email": "brais@example.com",
}
)
@@ -1761,7 +1761,7 @@ class TestPmsReservations(common.SavepointCase):
host = self.env["res.partner"].create(
{
"name": "Miguel",
"phone": "654667733",
"mobile": "654667733",
"email": "miguel@example.com",
}
)

View File

@@ -164,7 +164,7 @@ class TestPmsWizardMassiveChanges(common.SavepointCase):
self.partner_id = self.env["res.partner"].create(
{
"name": "Miguel",
"phone": "654667733",
"mobile": "654667733",
"email": "miguel@example.com",
}
)

View File

@@ -74,6 +74,7 @@
</form>
</field>
</record>
<record id="pms_checkin_partner_reservation_view_tree" model="ir.ui.view">
<field name="name">pms.checkin.partner.reservation.view.tree</field>
<field name="model">pms.checkin.partner</field>

View File

@@ -158,7 +158,7 @@
</h2>
<h1>
<field
name="partner_id"
name="partner_name"
placeholder="Guest"
attrs="{'invisible':[('reservation_type','in',('out'))]}"
/>
@@ -177,7 +177,6 @@
>
<field name="email" placeholder="email" />
<field name="mobile" placeholder="mobile" />
<field name="phone" />
<field name="partner_internal_comment" />
<field
name="segmentation_ids"
@@ -253,6 +252,7 @@
</group>
<group invisible="1">
<field name="partner_id" invisible="1" />
<field name="payment_state" invisible="1" force_save="1" />
<field name="move_ids" invisible="1" />
<field name="invoice_status" invisible="1" />
@@ -485,7 +485,8 @@
default_order="create_date desc"
>
<field name="name" />
<field name="partner_id" select="1" />
<field name="partner_id" invisible="1" />
<field name="partner_name" select="1" />
<field name="date_order" select="1" />
<field name="user_id" widget="many2one_avatar_user" optional="show" />
<field name="reservation_ids" widget="many2many_tags" optional="show" />
@@ -551,7 +552,8 @@
<field name="arch" type="xml">
<kanban class="o_res_partner_kanban" limit="80">
<field name="name" />
<field name="partner_id" />
<field name="partner_id" invisible="1" />
<field name="partner_name" />
<field name="reservation_ids" />
<field name="service_ids" />
<field name="pending_amount" />
@@ -569,7 +571,8 @@
/>
<div class="oe_kanban_details">
<strong class="oe_partner_heading">
<field name="partner_id" />
<field name="partner_name" />
<field name="partner_id" invisible="1" />
</strong>
<div class="oe_kanban_partner_links" />
</div>

View File

@@ -229,12 +229,13 @@
style="margin-right: 30px;"
/>
<field
name="partner_id"
name="partner_name"
default_focus="1"
placeholder="Lastname, Firstname"
attrs="{'invisible':[('reservation_type','in',('out'))]}"
required="1"
/>
<field name="partner_id" invisible="1" />
<field
name="closure_reason_id"
default_focus="1"
@@ -666,7 +667,8 @@
/>
<field name="folio_id" decoration-bf="1" />
<field name="allowed_room_ids" invisible="1" />
<field name="partner_id" />
<field name="partner_id" invisible="1" />
<field name="partner_name" />
<field name="room_type_id" optional="show" />
<field name="adults" optional="show" />
<field name="ratio_checkin_data" widget="progressbar" optional="show" />
@@ -752,7 +754,7 @@
>
<attribute name="invisible">True</attribute>
</xpath> -->
<xpath expr="//field[@name='partner_id']" position="attributes">
<xpath expr="//field[@name='partner_name']" position="attributes">
<attribute name="invisible">True</attribute>
</xpath>
<xpath expr="//field[@name='folio_pending_amount']" position="attributes">

View File

@@ -259,7 +259,7 @@
<div class="col pl-md-0">
<div
t-field="reservation.partner_id"
t-options='{"widget": "contact", "fields": ["name", "partner_email", "partner_phone"]}'
t-options='{"widget": "contact", "fields": ["name", "partner_email", "partner_mobile"]}'
/>
</div>
</div>