diff --git a/pms/models/pms_property.py b/pms/models/pms_property.py index 63ff0ee50c..26eeea2d37 100644 --- a/pms/models/pms_property.py +++ b/pms/models/pms_property.py @@ -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 diff --git a/pms/models/pms_service.py b/pms/models/pms_service.py index b0add0ff58..4b3daddcb1 100644 --- a/pms/models/pms_service.py +++ b/pms/models/pms_service.py @@ -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): diff --git a/pms/models/res_company.py b/pms/models/res_company.py index cb3f5d89eb..6a69701aec 100644 --- a/pms/models/res_company.py +++ b/pms/models/res_company.py @@ -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)]", + )