diff --git a/pms/__manifest__.py b/pms/__manifest__.py index f3fc20589..c3d0f0668 100644 --- a/pms/__manifest__.py +++ b/pms/__manifest__.py @@ -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", diff --git a/pms/models/pms_folio.py b/pms/models/pms_folio.py index 814ae261b..fed992bbc 100644 --- a/pms/models/pms_folio.py +++ b/pms/models/pms_folio.py @@ -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, diff --git a/pms/models/pms_property.py b/pms/models/pms_property.py index 13948ef83..f5b6614ac 100644 --- a/pms/models/pms_property.py +++ b/pms/models/pms_property.py @@ -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 diff --git a/pms/report/invoice.xml b/pms/report/invoice.xml index a7e97acc4..a16fd8da4 100644 --- a/pms/report/invoice.xml +++ b/pms/report/invoice.xml @@ -1,30 +1,47 @@ diff --git a/pms/report/proforma_report.xml b/pms/report/proforma_report.xml new file mode 100644 index 000000000..b5212fdb2 --- /dev/null +++ b/pms/report/proforma_report.xml @@ -0,0 +1,15 @@ + + + + + PRO-FORMA Invoice + account.move + qweb-pdf + pms.report_pms_pro_forma + pms.report_pms_pro_forma + 'PRO-FORMA - %s' % (object.name) + + report + + + diff --git a/pms/report/proforma_report_templates.xml b/pms/report/proforma_report_templates.xml new file mode 100644 index 000000000..bc8ac6a2c --- /dev/null +++ b/pms/report/proforma_report_templates.xml @@ -0,0 +1,17 @@ + + + + + + diff --git a/pms/views/pms_property_views.xml b/pms/views/pms_property_views.xml index 2e25bfff8..08138f07c 100644 --- a/pms/views/pms_property_views.xml +++ b/pms/views/pms_property_views.xml @@ -10,7 +10,16 @@

+