mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD]pms: Self billing folios configuration
This commit is contained in:
@@ -894,6 +894,11 @@ class PmsProperty(models.Model):
|
||||
def _get_folio_default_journal(self, partner_invoice_id):
|
||||
self.ensure_one()
|
||||
partner = self.env["res.partner"].browse(partner_invoice_id)
|
||||
if (
|
||||
self.company_id.partner_id.id == partner.id
|
||||
and self.company_id.self_billed_journal_id
|
||||
):
|
||||
return self.company_id.self_billed_journal_id
|
||||
if (
|
||||
not partner
|
||||
or partner.id == self.env.ref("pms.various_pms_partner").id
|
||||
|
||||
@@ -1490,16 +1490,22 @@ class PmsReservation(models.Model):
|
||||
record.checkin_partner_count = 0
|
||||
record.checkin_partner_pending_count = 0
|
||||
|
||||
@api.depends("room_type_id")
|
||||
@api.depends("room_type_id", "partner_id")
|
||||
def _compute_tax_ids(self):
|
||||
for record in self:
|
||||
record = record.with_company(record.company_id)
|
||||
product = self.env["product.product"].browse(
|
||||
record.room_type_id.product_id.id
|
||||
)
|
||||
record.tax_ids = product.taxes_id.filtered(
|
||||
lambda t: t.company_id == record.env.company
|
||||
)
|
||||
if (
|
||||
record.partner_id == record.company_id.partner_id
|
||||
and record.company_id.self_billed_tax_ids
|
||||
):
|
||||
record.tax_ids = record.company_id.self_billed_tax_ids
|
||||
else:
|
||||
product = self.env["product.product"].browse(
|
||||
record.room_type_id.product_id.id
|
||||
)
|
||||
record.tax_ids = product.taxes_id.filtered(
|
||||
lambda t: t.company_id == record.env.company
|
||||
)
|
||||
|
||||
@api.depends("reservation_line_ids", "reservation_line_ids.room_id")
|
||||
def _compute_rooms(self):
|
||||
|
||||
@@ -225,12 +225,24 @@ class PmsService(models.Model):
|
||||
)
|
||||
|
||||
# Compute and Search methods
|
||||
@api.depends("product_id")
|
||||
@api.depends("product_id", "folio_id.partner_id", "reservation_id.partner_id")
|
||||
def _compute_tax_ids(self):
|
||||
for service in self:
|
||||
service.tax_ids = service.product_id.taxes_id.filtered(
|
||||
lambda r: not service.company_id or r.company_id == service.company_id
|
||||
partner = (
|
||||
service.reservation_id.partner_id
|
||||
if service.reservation_id
|
||||
else service.folio_id.partner_id
|
||||
)
|
||||
if (
|
||||
service.folio_id.partner_id == service.company_id.partner_id
|
||||
and service.company_id.self_billed_tax_ids
|
||||
):
|
||||
service.tax_ids = service.company_id.self_billed_tax_ids
|
||||
else:
|
||||
service.tax_ids = service.product_id.taxes_id.filtered(
|
||||
lambda r: not service.company_id
|
||||
or r.company_id == service.company_id
|
||||
)
|
||||
|
||||
@api.depends("service_line_ids", "service_line_ids.day_qty")
|
||||
def _compute_product_qty(self):
|
||||
|
||||
@@ -58,3 +58,20 @@ class ResCompany(models.Model):
|
||||
index=True,
|
||||
ondelete="restrict",
|
||||
)
|
||||
|
||||
self_billed_journal_id = fields.Many2one(
|
||||
string="Self billed journal",
|
||||
help="Journal used to create self billing",
|
||||
comodel_name="account.journal",
|
||||
index=True,
|
||||
ondelete="restrict",
|
||||
)
|
||||
self_billed_tax_ids = fields.Many2many(
|
||||
string="Self billed taxes",
|
||||
help="Taxes used to create self billing",
|
||||
comodel_name="account.tax",
|
||||
relation="company_autoinvoicing_tax_rel",
|
||||
column1="company_id",
|
||||
column2="tax_id",
|
||||
domain="[('company_id', '=', id)]",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user