Skip to content

Commit

Permalink
[ADD]pms: Self billing folios configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
DarioLodeiros committed Jan 8, 2025
1 parent 66772d8 commit d7b748c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
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

Check warning on line 901 in pms/models/pms_property.py

View check run for this annotation

Codecov / codecov/patch

pms/models/pms_property.py#L901

Added line #L901 was not covered by tests
if (
not partner
or partner.id == self.env.ref("pms.various_pms_partner").id
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

Check warning on line 240 in pms/models/pms_service.py

View check run for this annotation

Codecov / codecov/patch

pms/models/pms_service.py#L240

Added line #L240 was not covered by tests
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)]",
)

0 comments on commit d7b748c

Please sign in to comment.