Merge PR #181 into 14.0

Signed-off-by DarioLodeiros
This commit is contained in:
OCA-git-bot
2022-11-02 17:51:10 +00:00
9 changed files with 178 additions and 24 deletions

View File

@@ -92,6 +92,8 @@
"views/res_partner_id_category.xml",
"views/payment_transaction_views.xml",
"views/account_move_line_views.xml",
"report/proforma_report_templates.xml",
"report/proforma_report.xml",
],
"demo": [
"demo/pms_master_data.xml",

View File

@@ -2019,9 +2019,13 @@ class PmsFolio(models.Model):
_("Please define an accounting sales journal for the company %s (%s).")
% (self.company_id.name, self.company_id.id)
)
ref = ""
if self.name:
ref = self.name
if self.external_reference:
ref += " - " + self.external_reference
invoice_vals = {
"ref": self.name or "",
"ref": ref,
"move_type": "out_invoice",
"narration": self.note,
"currency_id": self.pricelist_id.currency_id.id,

View File

@@ -28,6 +28,10 @@ class PmsProperty(models.Model):
required=True,
ondelete="cascade",
)
pms_property_code = fields.Char(
string="Property Code",
help="Short name property",
)
company_id = fields.Many2one(
string="Company",
help="The company that owns or operates this property.",
@@ -444,6 +448,41 @@ class PmsProperty(models.Model):
return False
return True
@api.constrains("ref")
def _check_unique_property_ref(self):
for record in self:
if record.ref:
duplicated = self.env["pms.property"].search(
[("ref", "=", record.ref), ("id", "!=", record.id)]
)
if duplicated:
raise ValidationError(
_(
"Alreay exist other property with this ref: %s (%s)",
duplicated.name,
duplicated.ref,
)
)
@api.constrains("pms_property_code")
def _check_unique_property_code(self):
for record in self:
if record.pms_property_code:
duplicated = self.env["pms.property"].search(
[
("pms_property_code", "=", record.pms_property_code),
("id", "!=", record.id),
]
)
if duplicated:
raise ValidationError(
_(
"Alreay exist other property with this code: %s (%s)",
duplicated.name,
duplicated.pms_property_code,
)
)
@api.constrains("default_arrival_hour")
def _check_arrival_hour(self):
for record in self:
@@ -719,3 +758,38 @@ class PmsProperty(models.Model):
return 0
revpar = round(sum_group_price[0]["price"] / count_available_room_days, 2)
return revpar
@api.model
def _name_search(
self, name, args=None, operator="ilike", limit=100, name_get_uid=None
):
args = args or []
domain = []
if name:
domain = [
"|",
"|",
("ref", "=ilike", name.split(" ")[0] + "%"),
("pms_property_code", "=ilike", name.split(" ")[0] + "%"),
("name", operator, name),
]
if operator in expression.NEGATIVE_TERM_OPERATORS:
domain = ["&", "!"] + domain[1:]
return self._search(
expression.AND([domain, args]), limit=limit, access_rights_uid=name_get_uid
)
def name_get(self):
result = []
for record in self:
if self.env.context.get("only_code", False) and record.pms_property_code:
result.append((record.id, record.pms_property_code))
elif (
self.env.context.get("only_name", False) or not record.pms_property_code
):
result.append((record.id, record.name))
else:
result.append(
(record.id, record.name + " (" + record.pms_property_code + ")")
)
return result

View File

@@ -1,30 +1,47 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="report_invoice_document" inherit_id="account.report_invoice_document">
<xpath expr="//address" position="before">
<t t-if="o.pms_property_id">
<t t-set="information_block">
<div name="pms_property_address_block">
<div
t-field="o.pms_property_id.partner_id"
t-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;], &quot;no_marker&quot;: True}"
/>
</div>
</t>
</t>
</xpath>
<xpath expr="//div[@class='page']//h2" position="replace">
<h2>
<span
t-if="o.move_type == 'out_invoice' and o.is_simplified_invoice and o.state == 'posted'"
>Simplified Invoice</span>
<span
t-if="o.move_type == 'out_invoice' and o.is_simplified_invoice and o.state == 'draft'"
>Draft Simplified Invoice</span>
<span
t-if="o.move_type == 'out_invoice' and o.is_simplified_invoice and o.state == 'cancel'"
>Cancelled Simplified Invoice</span>
<span
t-if="o.move_type == 'out_invoice' and not o.is_simplified_invoice and o.state == 'posted'"
>Invoice</span>
<span
t-if="o.move_type == 'out_invoice' and not o.is_simplified_invoice and o.state == 'draft'"
>Draft Invoice</span>
<span
t-if="o.move_type == 'out_invoice' and not o.is_simplified_invoice and o.state == 'cancel'"
>Cancelled Invoice</span>
<span t-if="o.move_type == 'out_refund'">Credit Note</span>
<span t-if="o.move_type == 'in_refund'">Vendor Credit Note</span>
<span t-if="o.move_type == 'in_invoice'">Vendor Bill</span>
<span t-if="o.name != '/'" t-field="o.name" />
<t t-if="not (env.context.get('proforma', False) or is_pro_forma)">
<span
t-if="o.move_type == 'out_invoice' and o.is_simplified_invoice and o.state == 'posted'"
>Simplified Invoice</span>
<span
t-if="o.move_type == 'out_invoice' and o.is_simplified_invoice and o.state == 'draft'"
>Draft Simplified Invoice</span>
<span
t-if="o.move_type == 'out_invoice' and o.is_simplified_invoice and o.state == 'cancel'"
>Cancelled Simplified Invoice</span>
<span
t-if="o.move_type == 'out_invoice' and not o.is_simplified_invoice and o.state == 'posted'"
>Invoice</span>
<span
t-if="o.move_type == 'out_invoice' and not o.is_simplified_invoice and o.state == 'draft'"
>Draft Invoice</span>
<span
t-if="o.move_type == 'out_invoice' and not o.is_simplified_invoice and o.state == 'cancel'"
>Cancelled Invoice</span>
<span t-if="o.move_type == 'out_refund'">Credit Note</span>
<span t-if="o.move_type == 'in_refund'">Vendor Credit Note</span>
<span t-if="o.move_type == 'in_invoice'">Vendor Bill</span>
<span t-if="o.name != '/'" t-field="o.name" />
</t>
<t t-if="env.context.get('proforma', False) or is_pro_forma">
<span>Pro-Forma Invoice # </span>
</t>
</h2>
</xpath>
</template>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data>
<record id="action_report_pms_pro_forma_invoice" model="ir.actions.report">
<field name="name">PRO-FORMA Invoice</field>
<field name="model">account.move</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">pms.report_pms_pro_forma</field>
<field name="report_file">pms.report_pms_pro_forma</field>
<field name="print_report_name">'PRO-FORMA - %s' % (object.name)</field>
<field name="binding_model_id" ref="model_account_move" />
<field name="binding_type">report</field>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="report_pms_pro_forma">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-set="is_pro_forma" t-value="True" />
<t t-set="o" t-value="o.with_context(proforma=True)" />
<t
t-call="account.report_invoice_document"
t-lang="o.partner_id.lang"
/>
</t>
</t>
</template>
</odoo>

View File

@@ -10,7 +10,16 @@
<h1>
<field name="name" class="oe_inline" />
</h1>
<label for="company_id" />
<field name="company_id" class="oe_inline" />
<div class="col-6">
<label for="ref" />
<field name="ref" />
</div>
<div class="col-6">
<label for="pms_property_code" />
<field name="pms_property_code" />
</div>
<notebook>
<page string="General Information" name="property_general">
<group>

View File

@@ -42,6 +42,7 @@
"views/precheckin_portal_templates.xml",
"wizards/traveller_report.xml",
"wizards/wizard_ine.xml",
"reports/invoice.xml",
],
"installable": True,
}

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="report_invoice_document" inherit_id="account.report_invoice_document">
<xpath expr="//div[@t-if='o.partner_id.vat']" position="after">
<div
t-if="not o.partner_id.vat and o.partner_id.aeat_identification_type"
class="mt16"
>
<t><span t-field="o.partner_id.aeat_identification_type" /></t>: <span
t-field="o.partner_id.aeat_identification"
/>
</div>
</xpath>
</template>
</odoo>