Skip to content
Closed
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
3 changes: 2 additions & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Do NOT update manually; changes here will be overwritten by Copier
_commit: v1.21.1
_commit: v1.29
_src_path: gh:oca/oca-addons-repo-template
ci: GitHub
convert_readme_fragments_to_markdown: false
enable_checklog_odoo: false
generate_requirements_txt: true
github_check_license: true
github_ci_extra_env: {}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
pre-commit:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Get python version
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
name: Detect unreleased dependencies
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: |
for reqfile in requirements.txt test-requirements.txt ; do
if [ -f ${reqfile} ] ; then
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
ports:
- 5432:5432
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install addons and dependencies
Expand Down
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ var/
*.egg
*.eggs

# Windows installers
*.msi

# Debian packages
*.deb

# Redhat packages
*.rpm

# MacOS packages
*.dmg
*.pkg

# Installer logs
pip-log.txt
pip-delete-this-directory.txt
Expand Down
32 changes: 22 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exclude: |
# Files and folders generated by bots, to avoid loops
^setup/|/static/description/index\.html$|
# We don't want to mess with tool-generated files
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|^eslint.config.cjs|^prettier.config.cjs|
# Maybe reactivate this when all README files include prettier ignore tags?
^README\.md$|
# Library files can have extraneous formatting (even minimized)
Expand Down Expand Up @@ -39,7 +39,7 @@ repos:
language: fail
files: '[a-zA-Z0-9_]*/i18n/en\.po$'
- repo: https://github.com/oca/maintainer-tools
rev: 9a170331575a265c092ee6b24b845ec508e8ef75
rev: d5fab7ee87fceee858a3d01048c78a548974d935
hooks:
# update the NOT INSTALLABLE ADDONS section above
- id: oca-update-pre-commit-excluded-addons
Expand All @@ -58,6 +58,8 @@ repos:
hooks:
- id: oca-checks-odoo-module
- id: oca-checks-po
args:
- --disable=po-pretty-format
- repo: https://github.com/myint/autoflake
rev: v1.6.1
hooks:
Expand All @@ -73,25 +75,35 @@ repos:
rev: 22.8.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
- repo: local
hooks:
- id: prettier
name: prettier (with plugin-xml)
entry: prettier
args:
- --write
- --list-different
- --ignore-unknown
types: [text]
files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$
language: node
additional_dependencies:
- "[email protected]"
- "@prettier/[email protected]"
args:
- --plugin=@prettier/plugin-xml
files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.24.0
- repo: local
hooks:
- id: eslint
verbose: true
name: eslint
entry: eslint
args:
- --color
- --fix
verbose: true
types: [javascript]
language: node
additional_dependencies:
- "[email protected]"
- "eslint-plugin-jsdoc@"
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
Expand Down
4 changes: 2 additions & 2 deletions multi_pms_properties/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ def _valid_field_parameter(self, field, name):

@api.model_create_multi
def create(self, vals_list):
records = super(BaseModel, self).create(vals_list)
records = super().create(vals_list)
if self._check_pms_properties_auto:
records._check_pms_properties()
return records

def write(self, vals):
res = super(BaseModel, self).write(vals)
res = super().write(vals)
check_pms_properties = False
for fname in vals:
field = self._fields.get(fname)
Expand Down
4 changes: 2 additions & 2 deletions multi_pms_properties/tests/test_multi_pms_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@


@common.tagged("-at_install", "post_install")
class TestMultiPMSProperties(common.SavepointCase):
class TestMultiPMSProperties(common.TransactionCase):
@classmethod
def setUpClass(cls):
super(TestMultiPMSProperties, cls).setUpClass()
super().setUpClass()
model_classes = [ParentTester, ChildTester]
setup_test_model(cls.env, model_classes)
for mdl_cls in model_classes:
Expand Down
1 change: 0 additions & 1 deletion pms/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
"views/res_company_views.xml",
"views/traveller_report_template.xml",
"wizards/wizard_split_join_swap_reservation.xml",
"views/precheckin_portal_templates.xml",
"wizards/wizard_massive_changes.xml",
"wizards/wizard_advanced_filters.xml",
"wizards/folio_payment_link_views.xml",
Expand Down
21 changes: 10 additions & 11 deletions pms/init_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@


def pre_init_hook(cr):
with Environment.manage():
env = Environment(cr, SUPERUSER_ID, {})
ResConfig = env["res.config.settings"]
default_values = ResConfig.default_get(list(ResConfig.fields_get()))
default_values.update(
{"group_product_pricelist": True, "group_sale_pricelist": True}
)
ResConfig.sudo().create(default_values).execute()
env["ir.config_parameter"].sudo().set_param(
"product.product_pricelist_setting", "advanced"
)
env = Environment(cr, SUPERUSER_ID, {})
ResConfig = env["res.config.settings"]
default_values = ResConfig.default_get(list(ResConfig.fields_get()))
default_values.update(
{"group_product_pricelist": True, "group_sale_pricelist": True}
)
ResConfig.sudo().create(default_values).execute()
env["ir.config_parameter"].sudo().set_param(
"product.product_pricelist_setting", "advanced"
)
16 changes: 12 additions & 4 deletions pms/models/account_analytic_line.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from odoo import fields, models, api
from odoo import api, fields, models


class AccountAnalyticDistribution(models.Model):
Expand All @@ -14,15 +14,23 @@ class AccountAnalyticDistribution(models.Model):
@api.model
def default_get(self, fields):
res = super().default_get(fields)
if "pms_property_id" in fields and self.env.context.get("default_analytic_distribution"):
if "pms_property_id" in fields and self.env.context.get(
"default_analytic_distribution"
):
distribution = self.env.context["default_analytic_distribution"]
if distribution.keys():
property_ids = self.env["pms.property"].search(
[("analytic_account_id", "in", [int(x) for x in distribution.keys()])]
[
(
"analytic_account_id",
"in",
[int(x) for x in distribution.keys()],
)
]
)
if property_ids:
res["pms_property_id"] = property_ids[0].id
res['company_id'] = property_ids[0].company_id.id
res["company_id"] = property_ids[0].company_id.id
return res

def _get_distribution(self, vals):
Expand Down
20 changes: 0 additions & 20 deletions pms/models/account_bank_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,10 @@ class AccountBankStatement(models.Model):
check_pms_properties=True,
)

# pylint: disable=W8110
@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]
elif not record.pms_property_id:
record.pms_property_id = False

def button_post(self):
"""
Override the default method to add autoreconcile payments and statement lines
"""
lines_of_moves_to_post = self.line_ids.filtered(
lambda line: line.move_id.state != "posted"
)
super(AccountBankStatement, self).button_post()
for line in lines_of_moves_to_post:
payment_move_line = line._get_payment_move_lines_to_reconcile()
statement_move_line = line.move_id.line_ids.filtered(
lambda line: line.account_id.reconcile
or line.account_id == line.journal_id.suspense_account_id
)
if payment_move_line and statement_move_line:
statement_move_line.account_id = payment_move_line.account_id
lines_to_reconcile = payment_move_line + statement_move_line
lines_to_reconcile.reconcile()
34 changes: 1 addition & 33 deletions pms/models/account_bank_statement_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ class AccountBankStatementLine(models.Model):

@api.model
def _prepare_move_line_default_vals(self, counterpart_account_id=None):
line_vals_list = super(
AccountBankStatementLine, self
)._prepare_move_line_default_vals(counterpart_account_id)
line_vals_list = super()._prepare_move_line_default_vals(counterpart_account_id)
if self.folio_ids:
for line in line_vals_list:
line.update(
Expand All @@ -49,36 +47,6 @@ def _prepare_move_line_default_vals(self, counterpart_account_id=None):
)
return line_vals_list

def _get_payment_move_lines_to_reconcile(self):
self.ensure_one()
payment_move_line = False
folio_ids = self.folio_ids and self.folio_ids.ids or False
domain = [("move_id.folio_ids", "in", folio_ids)] if folio_ids else []
domain.extend(
[
("move_id.ref", "=", self.payment_ref),
("date", "=", self.date),
("reconciled", "=", False),
"|",
(
"account_id",
"=",
self.journal_id.payment_debit_account_id.id,
),
(
"account_id",
"=",
self.journal_id.payment_credit_account_id.id,
),
("journal_id", "=", self.journal_id.id),
]
)
to_reconcile_move_lines = self.env["account.move.line"].search(domain)
# We try to reconcile by amount
for record in to_reconcile_move_lines:
payment_move_line = record if record.balance == self.amount else False
return payment_move_line

def _create_counterpart_and_new_aml(
self, counterpart_moves, counterpart_aml_dicts, new_aml_dicts
):
Expand Down
26 changes: 13 additions & 13 deletions pms/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ class AccountMoveLine(models.Model):
_inherit = "account.move.line"
_check_pms_properties_auto = True

# Fields declaration
# TODO: REVIEW why not a Many2one?
name = fields.Char(
compute="_compute_name",
store=True,
Expand Down Expand Up @@ -59,7 +57,6 @@ class AccountMoveLine(models.Model):
)
move_id = fields.Many2one(check_pms_properties=True)

# pylint: disable=W8110
@api.depends("account_id", "partner_id", "product_id", "pms_property_id")
def _compute_analytic_distribution(self):
properties = self.mapped("pms_property_id")
Expand All @@ -70,6 +67,7 @@ def _compute_analytic_distribution(self):
super(
AccountMoveLine, records.with_context(pms_property_id=pms_property.id)
)._compute_analytic_distribution()
return

@api.depends("move_id.payment_reference", "quantity")
def _compute_name(self):
Expand Down Expand Up @@ -130,7 +128,7 @@ def reconcile(self):
Reconcile the account move
"""
# Update partner in payments and statement lines
res = super(AccountMoveLine, self).reconcile()
res = super().reconcile()
for record in self:
if record.payment_id:
old_payment_partner = record.payment_id.partner_id
Expand All @@ -145,10 +143,11 @@ def reconcile(self):
if old_payment_partner:
record.payment_id.message_post(
body=_(
f"""
Partner modify automatically from invoice:
{old_payment_partner.name} to {new_payment_partner.name}
"""
"Partner modify automatically from"
" invoice: {old_partner} to {new_partner}"
).format(
old_partner=old_payment_partner.name,
new_partner=new_payment_partner.name,
)
)
if record.statement_line_id:
Expand All @@ -164,10 +163,11 @@ def reconcile(self):
if old_statement_partner:
record.statement_line_id.message_post(
body=_(
f"""
Partner modify automatically from invoice:
{old_statement_partner.name} to {new_payment_partner.name}
"""
"Partner modify automatically from "
"invoice: {old_partner} to {new_partner}"
).format(
old_partner=old_statement_partner.name,
new_partner=new_payment_partner.name,
)
)
return res
Expand All @@ -176,7 +176,7 @@ def _get_lock_date_protected_fields(self):
"""Inherited from account.move.line
to avoid to lock partner_id in reconciliation_fnames
"""
lock_types = super(AccountMoveLine, self)._get_lock_date_protected_fields()
lock_types = super()._get_lock_date_protected_fields()
reconciliation_fnames = lock_types.get("reconciliation", [])
# Remove partner_id from reconciliation_fnames
# because it is not a protected field
Expand Down
Loading
Loading