Skip to content

Commit

Permalink
[IMP]pms: property checks
Browse files Browse the repository at this point in the history
  • Loading branch information
DarioLodeiros committed Feb 19, 2022
1 parent d8aad95 commit 07ee49c
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 22 deletions.
3 changes: 1 addition & 2 deletions pms/models/account_bank_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ 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")
def _compute_pms_property_id(self):
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):
Expand Down
4 changes: 4 additions & 0 deletions pms/models/account_bank_statement_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

class AccountBankStatementLine(models.Model):
_inherit = "account.bank.statement.line"
_check_pms_properties_auto = True

folio_ids = fields.Many2many(
string="Folios",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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
Expand Down
5 changes: 1 addition & 4 deletions pms/models/account_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

class AccountJournal(models.Model):
_inherit = "account.journal"
_check_pms_properties_auto = True

pms_property_ids = fields.Many2many(
string="Properties",
Expand All @@ -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(
Expand Down
10 changes: 8 additions & 2 deletions pms/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

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",
Expand All @@ -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):
Expand All @@ -39,7 +45,7 @@ def _compute_pms_property_id(self):
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")
Expand Down
16 changes: 15 additions & 1 deletion pms/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class AccountMoveLine(models.Model):
_inherit = "account.move.line"
_check_pms_properties_auto = True

# Fields declaration
# TODO: REVIEW why not a Many2one?
Expand All @@ -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",
Expand All @@ -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):
Expand Down
1 change: 0 additions & 1 deletion pms/models/account_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
class AccountPayment(models.Model):
_inherit = "account.payment"

# Fields declaration
folio_ids = fields.Many2many(
string="Folios",
comodel_name="pms.folio",
Expand Down
2 changes: 0 additions & 2 deletions pms/models/folio_sale_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions pms/models/payment_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

class PaymentTransaction(models.Model):
_inherit = "payment.transaction"
_check_pms_properties_auto = True

folio_ids = fields.Many2many(
string="Folios",
Expand Down
1 change: 0 additions & 1 deletion pms/models/pms_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion pms/models/product_pricelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 1 addition & 3 deletions pms/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class ProductTemplate(models.Model):
_inherit = "product.template"
_check_pms_properties_auto = True

pms_property_ids = fields.Many2many(
string="Properties",
Expand All @@ -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",
Expand Down
3 changes: 0 additions & 3 deletions pms/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion pms/views/account_move_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
<field name="arch" type="xml">
<xpath expr="//field[@name='invoice_date']" position="after">
<field name="folio_ids" widget="many2many_tags" />
<field name="pms_property_id" invisible="1" />
<field name="pms_property_id" />
</xpath>

<xpath expr="//field[@name='quantity']" position="before">
<field name="name_changed_by_user" invisible="1" />
<field
name="pms_property_id"
attrs="{'column_invisible':[('parent.pms_property_id','!=',False)]}"
/>
</xpath>
</field>
</record>
Expand Down
2 changes: 1 addition & 1 deletion pms_l10n_es/wizards/traveller_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def generate_checkin_list(self, property_id, date_target=False):
# 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),
Expand Down

0 comments on commit 07ee49c

Please sign in to comment.