Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] pre-commit #183

Open
wants to merge 6 commits into
base: 18.0
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Do NOT update manually; changes here will be overwritten by Copier
_commit: 719579f
_src_path: https://github.com/ingadhoc/addons-repo-template.git
description: ADHOC Odoo multi-company Modules
is_private: false
name: ADHOC multi-company
odoo_version: 18.0
pre_commit_ignore: []
slug: ''

34 changes: 34 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# ⚠️ DO NOT EDIT THIS FILE, IT IS GENERATED BY COPIER ⚠️
# Changes here will be lost on a future update.
# See: https://github.com/ingadhoc/addons-repo-template

name: pre-commit

on:
push:
branches: "*.0"
pull_request:

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
id: setup-python
name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
-
name: Pre-commit cache
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ steps.setup-python.outputs.python-version }}|${{ hashFiles('.pre-commit-config.yaml') }}
-
name: Pre-commit
uses: pre-commit/[email protected]
12 changes: 10 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# ⚠️ DO NOT EDIT THIS FILE, IT IS GENERATED BY COPIER ⚠️
# Changes here will be lost on a future update.
# See: https://github.com/ingadhoc/addons-repo-template

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -37,6 +41,12 @@ coverage.xml
# Translations
*.mo

# Ensure we never commit pgdumps
*.dump
*.sql
*.pg
*.pg.gpg

# Mr Developer
.mr.developer.cfg
.project
Expand All @@ -50,5 +60,3 @@ coverage.xml

# Sphinx documentation
docs/_build/
#
.idea/
69 changes: 69 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# ⚠️ DO NOT EDIT THIS FILE, IT IS GENERATED BY COPIER ⚠️
# Changes here will be lost on a future update.
# See: https://github.com/ingadhoc/addons-repo-template

exclude: |
(?x)

# We don't want to mess with tool-generated files
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|^eslint.config.cjs|^prettier.config.cjs|
# Library files can have extraneous formatting (even minimized)
/static/(src/)?lib/|
# Ignore build and dist directories in addons
/build/|/dist/|
# Ignore test files in addons
/tests/samples/.*|
# You don't usually want a bot to modify your legal texts
(LICENSE.*|COPYING.*)

# Keep in sync with .github/workflows/pre-commit.yml
default_language_version:
python: python3

repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-symlinks
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
args: ["--fix=lf"]
- id: trailing-whitespace
# exclude autogenerated files
exclude: \.pot?$

- repo: https://github.com/OCA/odoo-pre-commit-hooks
rev: v0.0.35
hooks:
- id: oca-checks-odoo-module
args:
- --disable=xml-dangerous-qweb-replace-low-priority,xml-view-dangerous-replace-low-priority,xml-oe-structure-missing-id
- id: oca-checks-po
args:
- --disable=po-pretty-format

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.8
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format

- repo: https://github.com/OCA/pylint-odoo
rev: v9.1.3
hooks:
- id: pylint_odoo

- repo: https://github.com/rstcheck/rstcheck
rev: v6.2.1
hooks:
- id: rstcheck
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
[![Code Climate](https://codeclimate.com/github/ingadhoc/multi-company/badges/gpa.svg)](https://codeclimate.com/github/ingadhoc/multi-company)
[![Coverage Status](https://coveralls.io/repos/ingadhoc//badge.png?branch=18.0)](https://coveralls.io/r/ingadhoc/?branch=18.0)
[![Code Climate](https://codeclimate.com/github/ingadhoc//badges/gpa.svg)](https://codeclimate.com/github/ingadhoc/)

# ADHOC multi-company

ADHOC Odoo multi-company Modules

[//]: # (addons)
[//]: # (end addons)

Translation Status
------------------
[![Transifex Status](https://www.transifex.com/projects/p/ingadhoc-multi-company-15-0/chart/image_png)](https://www.transifex.com/projects/p/ingadhoc-multi-company-15-0)

----

<img alt="ADHOC" src="http://fotos.subefotos.com/83fed853c1e15a8023b86b2b22d6145bo.png" />
**Adhoc SA** - www.adhoc.com.ar
.
46 changes: 23 additions & 23 deletions account_multicompany_ux/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,29 @@
#
##############################################################################
{
'name': 'Account Multicompany Usability',
'version': "18.0.1.0.0",
'author': 'ADHOC SA',
'website': 'www.adhoc.com.ar',
'license': 'AGPL-3',
'depends': [
'account',
'account_reports',
"name": "Account Multicompany Usability",
"version": "18.0.1.0.0",
"author": "ADHOC SA",
"website": "www.adhoc.com.ar",
"license": "AGPL-3",
"depends": [
"account",
"account_reports",
],
'data': [
'views/res_company_property_views.xml',
'views/res_company_views.xml',
'views/res_partner_views.xml',
'views/product_category_views.xml',
'views/product_template_views.xml',
'views/product_product_views.xml',
'views/account_journal_dashboard_views.xml',
'wizards/account_change_company_views.xml',
'views/account_move_views.xml',
'security/account_multicompany_ux_security.xml',
'security/ir.model.access.csv',
"data": [
"views/res_company_property_views.xml",
"views/res_company_views.xml",
"views/res_partner_views.xml",
"views/product_category_views.xml",
"views/product_template_views.xml",
"views/product_product_views.xml",
"views/account_journal_dashboard_views.xml",
"wizards/account_change_company_views.xml",
"views/account_move_views.xml",
"security/account_multicompany_ux_security.xml",
"security/ir.model.access.csv",
],
'demo': [],
'installable': True,
'auto_install': False,
"demo": [],
"installable": True,
"auto_install": False,
}
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,3 @@ msgstr ""
#: model:ir.model,name:account_mutlicompany_usability.model_account_tax_code
msgid "Tax Code"
msgstr ""

11 changes: 6 additions & 5 deletions account_multicompany_ux/models/account_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@


class AccountAccount(models.Model):

_inherit = 'account.account'
_inherit = "account.account"

def _compute_display_name(self):
"""
Agregamos sufijo de compañía en reportes financieros si hay más de una compañía seleccionada
"""
if self._context.get('report_id') and len(self._context.get('company_ids', self.env.companies.ids)) > 1:
if self._context.get("report_id") and len(self._context.get("company_ids", self.env.companies.ids)) > 1:
for account in self:
if account.code:
company = self.env['res.company'].browse(self._context['allowed_company_ids'][0])
account.display_name = f"{account.with_company(company).code} {account.name}{company.get_company_sufix()}"
company = self.env["res.company"].browse(self._context["allowed_company_ids"][0])
account.display_name = (
f"{account.with_company(company).code} {account.name}{company.get_company_sufix()}"
)
else:
account.display_name = account.name
else:
Expand Down
7 changes: 3 additions & 4 deletions account_multicompany_ux/models/account_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@


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

_inherit = 'account.journal'

@api.depends('name', 'currency_id', 'company_id', 'company_id.currency_id')
@api.depends("name", "currency_id", "company_id", "company_id.currency_id")
def _compute_display_name(self):
"""
Este método lo que haría es agregar el nombre de la compañía entre paréntesis al final del nombre del diario
Este método lo que haría es agregar el nombre de la compañía entre paréntesis al final del nombre del diario
cuando uno ingresa a la vista form esto lo hace en el nombre que está en el menú hamburguesa.
en caso de que {journal.company_id.get_company_sufix()} sea False llamamos a super para mantener el comportamiento
nativo de odoo
Expand Down
9 changes: 4 additions & 5 deletions account_multicompany_ux/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import api, models, fields, _
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError


class AccountMove(models.Model):
_inherit = 'account.move'
_inherit = "account.move"

reversed_entry_id = fields.Many2one(check_company=False)
company_id = fields.Many2one(tracking=True)

@api.constrains('company_id')
@api.constrains("company_id")
def check_company(self):
for move in self:
if move.company_id.consolidation_company:
raise ValidationError(_(
'You can not create entries on a consolidation company'))
raise ValidationError(_("You can not create entries on a consolidation company"))
29 changes: 24 additions & 5 deletions account_multicompany_ux/models/account_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,33 @@
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import models, fields
from odoo import models


class AccountReport(models.Model):
_inherit = 'account.report'
_inherit = "account.report"

def _expand_unfoldable_line(self, expand_function_name, line_dict_id, groupby, options, progress, offset, horizontal_split_side, unfold_all_batch_data=None):
""" Agregamos sufijo de compañía en reportes financieros si hay más de una compañía seleccionada en el método _compute_display_name de account.account pero necesitamos agregar por contexto el id del reporte porque si no lo hacemos al momento de hacer un unfold de algún rubro en el reporte las cuentas se muestran sin dicho sufijo. Ver ticket 43453 para ver más info acerca de la funcionalidad que necesitamos. """
def _expand_unfoldable_line(
self,
expand_function_name,
line_dict_id,
groupby,
options,
progress,
offset,
horizontal_split_side,
unfold_all_batch_data=None,
):
"""Agregamos sufijo de compañía en reportes financieros si hay más de una compañía seleccionada en el método _compute_display_name de account.account pero necesitamos agregar por contexto el id del reporte porque si no lo hacemos al momento de hacer un unfold de algún rubro en el reporte las cuentas se muestran sin dicho sufijo. Ver ticket 43453 para ver más info acerca de la funcionalidad que necesitamos."""
self = self.with_context(report_id=self.id)

return super()._expand_unfoldable_line(expand_function_name, line_dict_id, groupby, options, progress, offset, horizontal_split_side, unfold_all_batch_data)
return super()._expand_unfoldable_line(
expand_function_name,
line_dict_id,
groupby,
options,
progress,
offset,
horizontal_split_side,
unfold_all_batch_data,
)
29 changes: 11 additions & 18 deletions account_multicompany_ux/models/product_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,30 @@


class ProductCategory(models.Model):

_name = 'product.category'
_inherit = ['product.category', 'res.company.property.mixin']
_property_fields = {'property_account_income_categ_ids', 'property_account_expense_categ_ids'}

_name = "product.category"
_inherit = ["product.category", "res.company.property.mixin"]
_property_fields = {"property_account_income_categ_ids", "property_account_expense_categ_ids"}

property_account_income_categ_ids = fields.Many2many(
'res.company.property',
"res.company.property",
string="Income Accounts",
compute='_compute_properties',
compute="_compute_properties",
)
property_account_expense_categ_ids = fields.Many2many(
'res.company.property',
"res.company.property",
string="Expense Accounts",
compute='_compute_properties',
compute="_compute_properties",
)

@api.depends()
def _compute_properties(self):
company_property = self.env['res.company.property']
company_property = self.env["res.company.property"]
property_fields = dict(
property_account_income_categ_ids=(
'property_account_income_categ_id'),
property_account_expense_categ_ids=(
'property_account_expense_categ_id'),
property_account_income_categ_ids=("property_account_income_categ_id"),
property_account_expense_categ_ids=("property_account_expense_categ_id"),
)

for rec in self:

company_properties = company_property.with_context(
active_model=self._name,
active_id=rec.id)
company_properties = company_property.with_context(active_model=self._name, active_id=rec.id)
for newfield, oldfield in property_fields.items():
rec[newfield] = company_properties.with_context(property_field=oldfield)._get_companies()
Loading