Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD]pms: Self billing folios configuration #310

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pms/models/pms_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,11 @@ def _check_journal_simplified_invoice(self):
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
Expand Down
20 changes: 13 additions & 7 deletions pms/models/pms_reservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1490,16 +1490,22 @@ def _compute_checkin_partner_count(self):
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):
Expand Down
18 changes: 15 additions & 3 deletions pms/models/pms_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
17 changes: 17 additions & 0 deletions pms/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]",
)
Loading