diff --git a/pms/models/account_bank_statement.py b/pms/models/account_bank_statement.py index 0232c9267..18c1a8398 100644 --- a/pms/models/account_bank_statement.py +++ b/pms/models/account_bank_statement.py @@ -15,7 +15,6 @@ class AccountBankStatement(models.Model): copy=False, check_pms_properties=True, ) - company_id = fields.Many2one(check_pms_properties=True) journal_id = fields.Many2one(check_pms_properties=True) @api.depends("journal_id") @@ -23,7 +22,7 @@ class AccountBankStatement(models.Model): for record in self: if len(record.journal_id.pms_property_ids) == 1: record.pms_property_id = record.journal_id.pms_property_ids[0] - else: + elif not record.pms_property_id: record.pms_property_id = False def button_post(self): diff --git a/pms/models/account_bank_statement_line.py b/pms/models/account_bank_statement_line.py index 3a4c76050..03ec91a54 100644 --- a/pms/models/account_bank_statement_line.py +++ b/pms/models/account_bank_statement_line.py @@ -3,6 +3,7 @@ from odoo import api, fields, models class AccountBankStatementLine(models.Model): _inherit = "account.bank.statement.line" + _check_pms_properties_auto = True folio_ids = fields.Many2many( string="Folios", @@ -11,6 +12,7 @@ class AccountBankStatementLine(models.Model): relation="account_bank_statement_folio_rel", column1="account_journal_id", column2="folio_id", + check_pms_properties=True, ) reservation_ids = fields.Many2many( string="Reservations", @@ -20,6 +22,7 @@ class AccountBankStatementLine(models.Model): relation="account_bank_statement_reservation_rel", column1="account_bank_statement_id", column2="reservation_id", + check_pms_properties=True, ) service_ids = fields.Many2many( string="Services", @@ -29,6 +32,7 @@ class AccountBankStatementLine(models.Model): relation="account_bank_statement_service_rel", column1="account_bank_statement_id", column2="service_id", + check_pms_properties=True, ) @api.model diff --git a/pms/models/account_journal.py b/pms/models/account_journal.py index c7afb21cf..9edb82d3c 100644 --- a/pms/models/account_journal.py +++ b/pms/models/account_journal.py @@ -3,6 +3,7 @@ from odoo import fields, models class AccountJournal(models.Model): _inherit = "account.journal" + _check_pms_properties_auto = True pms_property_ids = fields.Many2many( string="Properties", @@ -13,10 +14,6 @@ class AccountJournal(models.Model): relation="account_journal_pms_property_rel", column1="account_journal_id", column2="pms_property_id", - ) - company_id = fields.Many2one( - string="Company", - help="The company for Account Jouarnal", check_pms_properties=True, ) allowed_pms_payments = fields.Boolean( diff --git a/pms/models/account_move.py b/pms/models/account_move.py index 4cc1ef2bb..dc07672e5 100644 --- a/pms/models/account_move.py +++ b/pms/models/account_move.py @@ -9,8 +9,8 @@ from odoo.exceptions import UserError class AccountMove(models.Model): _inherit = "account.move" + _check_pms_properties_auto = True - # Field Declarations folio_ids = fields.Many2many( string="Folios", help="Folios where the account move are included", @@ -31,6 +31,12 @@ class AccountMove(models.Model): readonly=False, check_pms_properties=True, ) + journal_id = fields.Many2one(check_pms_properties=True) + + @api.onchange("pms_property_id") + def _onchange_pms_property_id(self): + for move in self: + move.journal_id = move._get_default_journal() @api.depends("journal_id", "folio_ids") def _compute_pms_property_id(self): @@ -39,7 +45,7 @@ class AccountMove(models.Model): move.pms_property_id = move.folio_ids.mapped("pms_property_id") elif len(move.journal_id.mapped("pms_property_ids")) == 1: move.pms_property_id = move.journal_id.mapped("pms_property_ids")[0] - else: + elif not move.pms_property_id: move.pms_property_id = False @api.depends("line_ids", "line_ids.folio_ids") diff --git a/pms/models/account_move_line.py b/pms/models/account_move_line.py index d917e5f68..ca1bb49a5 100644 --- a/pms/models/account_move_line.py +++ b/pms/models/account_move_line.py @@ -6,6 +6,7 @@ from odoo import api, fields, models class AccountMoveLine(models.Model): _inherit = "account.move.line" + _check_pms_properties_auto = True # Fields declaration # TODO: REVIEW why not a Many2one? @@ -17,12 +18,14 @@ class AccountMoveLine(models.Model): relation="folio_sale_line_invoice_rel", column1="invoice_line_id", column2="sale_line_id", + check_pms_properties=True, ) folio_ids = fields.Many2many( comodel_name="pms.folio", string="Folios", compute="_compute_folio_ids", store=True, + check_pms_properties=True, ) name_changed_by_user = fields.Boolean( string="Custom label", @@ -34,9 +37,20 @@ class AccountMoveLine(models.Model): pms_property_id = fields.Many2one( name="Property", comodel_name="pms.property", - related="move_id.pms_property_id", + compute="_compute_pms_property_id", store=True, + readonly=False, + check_pms_properties=True, ) + move_id = fields.Many2one(check_pms_properties=True) + + @api.depends("move_id") + def _compute_pms_property_id(self): + for rec in self: + if rec.move_id and rec.move_id.pms_property_id: + rec.pms_property_id = rec.move_id.pms_property_id + elif not rec.pms_property_id: + rec.pms_property_id = False @api.depends("name") def _compute_name_changed_by_user(self): diff --git a/pms/models/account_payment.py b/pms/models/account_payment.py index cd06dd8cd..1d72cb2e1 100644 --- a/pms/models/account_payment.py +++ b/pms/models/account_payment.py @@ -6,7 +6,6 @@ from odoo import api, fields, models class AccountPayment(models.Model): _inherit = "account.payment" - # Fields declaration folio_ids = fields.Many2many( string="Folios", comodel_name="pms.folio", diff --git a/pms/models/folio_sale_line.py b/pms/models/folio_sale_line.py index 67f90f735..99c94b880 100644 --- a/pms/models/folio_sale_line.py +++ b/pms/models/folio_sale_line.py @@ -12,7 +12,6 @@ class FolioSaleLine(models.Model): _name = "folio.sale.line" _description = "Folio Sale Line" _order = "folio_id, sequence, reservation_order desc, service_order, date_order" - _check_company_auto = True folio_id = fields.Many2one( @@ -254,7 +253,6 @@ class FolioSaleLine(models.Model): store=True, index=True, related="folio_id.company_id", - check_pms_properties=True, ) folio_partner_id = fields.Many2one( string="Customer", diff --git a/pms/models/payment_transaction.py b/pms/models/payment_transaction.py index fff13a0e4..a674b2c9f 100644 --- a/pms/models/payment_transaction.py +++ b/pms/models/payment_transaction.py @@ -3,6 +3,7 @@ from odoo import _, fields, models class PaymentTransaction(models.Model): _inherit = "payment.transaction" + _check_pms_properties_auto = True folio_ids = fields.Many2many( string="Folios", diff --git a/pms/models/pms_property.py b/pms/models/pms_property.py index 09dea5d82..317f12e02 100644 --- a/pms/models/pms_property.py +++ b/pms/models/pms_property.py @@ -32,7 +32,6 @@ class PmsProperty(models.Model): help="The company that owns or operates this property.", comodel_name="res.company", required=True, - check_pms_properties=True, ) user_ids = fields.Many2many( string="Accepted Users", diff --git a/pms/models/product_pricelist.py b/pms/models/product_pricelist.py index 0feb51de7..f7b00e6b5 100644 --- a/pms/models/product_pricelist.py +++ b/pms/models/product_pricelist.py @@ -33,7 +33,6 @@ class ProductPricelist(models.Model): company_id = fields.Many2one( string="Company", help="Company to which the pricelist belongs", - check_pms_properties=True, ) cancelation_rule_id = fields.Many2one( string="Cancelation Policy", diff --git a/pms/models/product_template.py b/pms/models/product_template.py index b52733fa1..0b5c7a538 100644 --- a/pms/models/product_template.py +++ b/pms/models/product_template.py @@ -6,6 +6,7 @@ from odoo import fields, models class ProductTemplate(models.Model): _inherit = "product.template" + _check_pms_properties_auto = True pms_property_ids = fields.Many2many( string="Properties", @@ -19,9 +20,6 @@ class ProductTemplate(models.Model): ondelete="restrict", check_pms_properties=True, ) - company_id = fields.Many2one( - check_pms_properties=True, - ) per_day = fields.Boolean( string="Unit increment per day", help="Indicates that the product is sold by days", diff --git a/pms/models/res_partner.py b/pms/models/res_partner.py index ced9d231e..7ef209c1f 100644 --- a/pms/models/res_partner.py +++ b/pms/models/res_partner.py @@ -52,9 +52,6 @@ class ResPartner(models.Model): ondelete="restrict", check_pms_properties=True, ) - company_id = fields.Many2one( - check_pms_properties=True, - ) pms_checkin_partner_ids = fields.One2many( string="Checkin Partners", help="Associated checkin partners", diff --git a/pms/views/account_move_views.xml b/pms/views/account_move_views.xml index 0776f0c53..1b344e23a 100644 --- a/pms/views/account_move_views.xml +++ b/pms/views/account_move_views.xml @@ -6,10 +6,15 @@ - + + + diff --git a/pms_l10n_es/wizards/traveller_report.py b/pms_l10n_es/wizards/traveller_report.py index a82651891..4e4882bbe 100644 --- a/pms_l10n_es/wizards/traveller_report.py +++ b/pms_l10n_es/wizards/traveller_report.py @@ -89,7 +89,7 @@ class TravellerReport(models.TransientModel): # get checkin partners info to send lines = self.env["pms.checkin.partner"].search( [ - ("state", "=", "onboard", "done"), + ("state", "in", ["onboard", "done"]), ("arrival", ">=", str(date_target) + " 0:00:00"), ("arrival", "<=", str(date_target) + " 23:59:59"), ("pms_property_id", "=", property_id),