Compare commits
6 Commits
762af53f49
...
18.0
| Author | SHA1 | Date | |
|---|---|---|---|
| bb6891d825 | |||
| 64b8e45af1 | |||
| 93de63c290 | |||
| 1f53587a3f | |||
| e45ad867c0 | |||
| 95dc32803f |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
*.*~
|
||||
*.pyc
|
||||
.ruff_cache/
|
||||
|
||||
@@ -49,12 +49,9 @@ repos:
|
||||
$(git rev-parse --show-toplevel))"'
|
||||
- id: oca-gen-addon-readme
|
||||
entry:
|
||||
bash -c 'oca-gen-addon-readme
|
||||
--addons-dir=.
|
||||
--branch=$(git symbolic-ref
|
||||
bash -c 'oca-gen-addon-readme --addons-dir=. --branch=$(git symbolic-ref
|
||||
refs/remotes/origin/HEAD | sed "s@^refs/remotes/origin/@@")
|
||||
--repo-name=$(basename $(git rev-parse --show-toplevel))
|
||||
--org-name="Elabore"
|
||||
--repo-name=$(basename $(git rev-parse --show-toplevel)) --org-name="Elabore"
|
||||
--if-source-changed --keep-source-digest'
|
||||
|
||||
- repo: https://github.com/OCA/odoo-pre-commit-hooks
|
||||
|
||||
@@ -5,25 +5,19 @@
|
||||
"name": "account_advanced_protection_features",
|
||||
"version": "18.0.1.0.0",
|
||||
"author": "Elabore",
|
||||
"website": "https://elabore.coop",
|
||||
"website": "https://git.elabore.coop/elabore/account-tools",
|
||||
"maintainer": "Quentin Mondot",
|
||||
"license": "AGPL-3",
|
||||
"category": "Tools",
|
||||
"summary": "Add several protection features about accounting",
|
||||
# any module necessary for this one to work correctly
|
||||
"depends": [
|
||||
"base",
|
||||
"account"
|
||||
],
|
||||
"depends": ["base", "account"],
|
||||
"qweb": [],
|
||||
"external_dependencies": {
|
||||
"python": [],
|
||||
},
|
||||
# always loaded
|
||||
"data": [
|
||||
"security/res_groups.xml",
|
||||
"views/account_journal_views.xml"
|
||||
],
|
||||
"data": ["security/res_groups.xml", "views/account_journal_views.xml"],
|
||||
# only loaded in demonstration mode
|
||||
"demo": [],
|
||||
"js": [],
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from odoo import models, _
|
||||
from odoo import _, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class AccountBankStatement(models.Model):
|
||||
_inherit = "account.bank.statement"
|
||||
|
||||
@@ -8,12 +9,16 @@ class AccountBankStatement(models.Model):
|
||||
for statement in self:
|
||||
if not statement.journal_id.allow_bank_statement_deletion:
|
||||
raise UserError(
|
||||
_("The deletion of bank statements is not allowed for the journal %s.") % statement.journal_id.display_name
|
||||
_(
|
||||
"The deletion of bank statements is "
|
||||
"not allowed for the journal %s."
|
||||
)
|
||||
% statement.journal_id.display_name
|
||||
)
|
||||
# we delete all the statement lines before deleting the statement itself
|
||||
for line in statement.line_ids:
|
||||
line.unlink()
|
||||
return super(AccountBankStatement, self).unlink()
|
||||
return super().unlink()
|
||||
|
||||
|
||||
class AccountBankStatementLine(models.Model):
|
||||
@@ -23,6 +28,10 @@ class AccountBankStatementLine(models.Model):
|
||||
for line in self:
|
||||
if not line.journal_id.allow_bank_statement_deletion:
|
||||
raise UserError(
|
||||
_("The deletion of bank statement lines is not allowed for the journal %s.") % line.journal_id.display_name
|
||||
_(
|
||||
"The deletion of bank statement lines is "
|
||||
"not allowed for the journal %s."
|
||||
)
|
||||
return super(AccountBankStatementLine, self).unlink()
|
||||
% line.journal_id.display_name
|
||||
)
|
||||
return super().unlink()
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
from odoo import models, fields
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class AccountJournal(models.Model):
|
||||
_inherit = "account.journal"
|
||||
|
||||
prevent_reset_to_draft_sent_invoice = fields.Boolean("Prevent to reset to draft a sent invoice")
|
||||
prevent_deletion_of_posted_account_move = fields.Boolean("Prevent to delete an already posted account move")
|
||||
prevent_reset_to_draft_sent_invoice = fields.Boolean(
|
||||
"Prevent to reset to draft a sent invoice"
|
||||
)
|
||||
prevent_deletion_of_posted_account_move = fields.Boolean(
|
||||
"Prevent to delete an already posted account move"
|
||||
)
|
||||
allow_bank_statement_deletion = fields.Boolean(
|
||||
"Allow bank statements deletion",
|
||||
help="Users with group Show Full Accounting Features (id: group_account_user) will be allowed to delete account bank statements "
|
||||
"and bank statement lines."
|
||||
help="Users with group Show Full Accounting Features (id: group_account_user) "
|
||||
"will be allowed to delete account bank statements "
|
||||
"and bank statement lines.",
|
||||
)
|
||||
|
||||
@@ -1,23 +1,34 @@
|
||||
from odoo import models, api, fields, _
|
||||
from odoo import _, api, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
_inherit = 'account.move'
|
||||
_inherit = "account.move"
|
||||
|
||||
def button_draft(self):
|
||||
if self.is_move_sent and self.journal_id.prevent_reset_to_draft_sent_invoice:
|
||||
raise UserError(_(
|
||||
"You cannot reset to draft this invoice because it has been sent by email."
|
||||
))
|
||||
return super(AccountMove, self).button_draft()
|
||||
raise UserError(
|
||||
_(
|
||||
"You cannot reset to draft this invoice because it "
|
||||
"has been sent by email."
|
||||
)
|
||||
)
|
||||
return super().button_draft()
|
||||
|
||||
@api.ondelete(at_uninstall=False)
|
||||
def _check_posted(self):
|
||||
""" Prevent deletion of an account move if it has already been posted and
|
||||
journal parameter prevent_deletion_of_posted_account_move is activated
|
||||
"""
|
||||
Prevent deletion of an account move if it has already been posted and journal
|
||||
parameter prevent_deletion_of_posted_account_move is activated.
|
||||
"""
|
||||
for rec in self:
|
||||
if rec.posted_before and rec.journal_id.prevent_deletion_of_posted_account_move:
|
||||
raise UserError(_(
|
||||
"You cannot delete this account move because it has already been posted."
|
||||
))
|
||||
if (
|
||||
rec.posted_before
|
||||
and rec.journal_id.prevent_deletion_of_posted_account_move
|
||||
):
|
||||
raise UserError(
|
||||
_(
|
||||
"You cannot delete this account move because it "
|
||||
"has already been posted."
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="group_account_protection_manager" model="res.groups">
|
||||
<field name="name">Access to account advanced protection features</field>
|
||||
<field name="category_id" ref="base.module_category_hidden"/>
|
||||
<field name="category_id" ref="base.module_category_hidden" />
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="view_account_journal_form_inherit_prevent_reset_to_draft" model="ir.ui.view">
|
||||
<record
|
||||
id="view_account_journal_form_inherit_prevent_reset_to_draft"
|
||||
model="ir.ui.view"
|
||||
>
|
||||
<field name="name">account.journal.form</field>
|
||||
<field name="model">account.journal</field>
|
||||
<field name="inherit_id" ref="account.view_account_journal_form"/>
|
||||
<field name="inherit_id" ref="account.view_account_journal_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='restrict_mode_hash_table']" position="after">
|
||||
<field
|
||||
|
||||
51
account_sub_accounts/README.rst
Normal file
51
account_sub_accounts/README.rst
Normal file
@@ -0,0 +1,51 @@
|
||||
====================
|
||||
account_sub_accounts
|
||||
====================
|
||||
|
||||
Add sub-account fields in res.partners and account.move.line, and sync them.
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
Use Odoo normal module installation procedure to install
|
||||
``account_sub_account``.
|
||||
|
||||
Description
|
||||
===========
|
||||
|
||||
- adds sub_account_customer and sub_account_supplier to res.partner model
|
||||
- adds sub_account_customer and sub_account_supplier to account.move.line model
|
||||
- when a account.move.line is created, sub_account_customer and sub_account_supplier fields are sync with the parner_id corresponding values
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
|
||||
None yet.
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `our issues website <https://github.com/elabore-coop/account-tools/issues>`_. In case of
|
||||
trouble, please check there if your issue has already been
|
||||
reported. If you spotted it first, help us smashing it by providing a
|
||||
detailed and welcomed feedback.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Stéphan Sainléger - https://github.com/stephansainleger
|
||||
|
||||
Funders
|
||||
-------
|
||||
|
||||
The development of this module has been financially supported by:
|
||||
* Elabore (https://elabore.coop)
|
||||
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
This module is maintained by Elabore.
|
||||
1
account_sub_accounts/__init__.py
Normal file
1
account_sub_accounts/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
22
account_sub_accounts/__manifest__.py
Normal file
22
account_sub_accounts/__manifest__.py
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "Account Sub-accounts",
|
||||
"version": "18.0.1.0.0",
|
||||
"summary": "Add sub-account fields in res.partners and account.move.line, "
|
||||
"and sync them.",
|
||||
"author": "Elabore",
|
||||
"website": "https://git.elabore.coop/elabore/account-tools",
|
||||
"license": "AGPL-3",
|
||||
"category": "Accounting",
|
||||
"depends": [
|
||||
"account",
|
||||
"base",
|
||||
],
|
||||
"data": [
|
||||
"views/res_partner_views.xml",
|
||||
"views/account_move_line_views.xml",
|
||||
],
|
||||
"installable": True,
|
||||
"auto_install": False,
|
||||
"application": False,
|
||||
"assets": {},
|
||||
}
|
||||
45
account_sub_accounts/i18n/account_sub_accounts.pot
Normal file
45
account_sub_accounts/i18n/account_sub_accounts.pot
Normal file
@@ -0,0 +1,45 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * account_sub_accounts
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 16.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2025-04-25 08:27+0000\n"
|
||||
"PO-Revision-Date: 2025-04-25 08:27+0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: account_sub_accounts
|
||||
#: model:ir.model,name:account_sub_accounts.model_res_partner
|
||||
msgid "Contact"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_sub_accounts
|
||||
#: model:ir.model.fields,field_description:account_sub_accounts.field_account_move_line__sub_account_customer
|
||||
#: model:ir.model.fields,field_description:account_sub_accounts.field_res_partner__sub_account_customer
|
||||
#: model:ir.model.fields,field_description:account_sub_accounts.field_res_users__sub_account_customer
|
||||
msgid "Custommer sub-account"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_sub_accounts
|
||||
#: model:ir.model,name:account_sub_accounts.model_account_move_line
|
||||
msgid "Journal Item"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_sub_accounts
|
||||
#: model_terms:ir.ui.view,arch_db:account_sub_accounts.res_partner_form_sub_accounts_view
|
||||
msgid "Sub-accounts"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_sub_accounts
|
||||
#: model:ir.model.fields,field_description:account_sub_accounts.field_account_move_line__sub_account_supplier
|
||||
#: model:ir.model.fields,field_description:account_sub_accounts.field_res_partner__sub_account_supplier
|
||||
#: model:ir.model.fields,field_description:account_sub_accounts.field_res_users__sub_account_supplier
|
||||
msgid "Supplier sub-account"
|
||||
msgstr ""
|
||||
45
account_sub_accounts/i18n/fr.po
Normal file
45
account_sub_accounts/i18n/fr.po
Normal file
@@ -0,0 +1,45 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * account_sub_accounts
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 18.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2025-04-25 08:29+0000\n"
|
||||
"PO-Revision-Date: 2025-04-25 10:30+0200\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: account_sub_accounts
|
||||
#: model:ir.model,name:account_sub_accounts.model_res_partner
|
||||
msgid "Contact"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_sub_accounts
|
||||
#: model:ir.model.fields,field_description:account_sub_accounts.field_account_move_line__sub_account_customer
|
||||
#: model:ir.model.fields,field_description:account_sub_accounts.field_res_partner__sub_account_customer
|
||||
#: model:ir.model.fields,field_description:account_sub_accounts.field_res_users__sub_account_customer
|
||||
msgid "Custommer sub-account"
|
||||
msgstr "Compte auxiliaire client"
|
||||
|
||||
#. module: account_sub_accounts
|
||||
#: model:ir.model,name:account_sub_accounts.model_account_move_line
|
||||
msgid "Journal Item"
|
||||
msgstr "Écriture comptable"
|
||||
|
||||
#. module: account_sub_accounts
|
||||
#: model_terms:ir.ui.view,arch_db:account_sub_accounts.res_partner_form_sub_accounts_view
|
||||
msgid "Sub-accounts"
|
||||
msgstr "Comptes auxiliaires"
|
||||
|
||||
#. module: account_sub_accounts
|
||||
#: model:ir.model.fields,field_description:account_sub_accounts.field_account_move_line__sub_account_supplier
|
||||
#: model:ir.model.fields,field_description:account_sub_accounts.field_res_partner__sub_account_supplier
|
||||
#: model:ir.model.fields,field_description:account_sub_accounts.field_res_users__sub_account_supplier
|
||||
msgid "Supplier sub-account"
|
||||
msgstr "Compte auxiliaire fournisseur"
|
||||
2
account_sub_accounts/models/__init__.py
Normal file
2
account_sub_accounts/models/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from . import res_parter
|
||||
from . import account_move_line
|
||||
13
account_sub_accounts/models/account_move_line.py
Normal file
13
account_sub_accounts/models/account_move_line.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class AccountMoveLine(models.Model):
|
||||
_inherit = "account.move.line"
|
||||
|
||||
sub_account_customer = fields.Char(
|
||||
string="Custommer sub-account", related="partner_id.sub_account_customer"
|
||||
)
|
||||
|
||||
sub_account_supplier = fields.Char(
|
||||
string="Supplier sub-account", related="partner_id.sub_account_supplier"
|
||||
)
|
||||
8
account_sub_accounts/models/res_parter.py
Normal file
8
account_sub_accounts/models/res_parter.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class Partner(models.Model):
|
||||
_inherit = "res.partner"
|
||||
|
||||
sub_account_customer = fields.Char(string="Custommer sub-account")
|
||||
sub_account_supplier = fields.Char(string="Supplier sub-account")
|
||||
14
account_sub_accounts/views/account_move_line_views.xml
Normal file
14
account_sub_accounts/views/account_move_line_views.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="account_move_line_tree_sub_accounts_view" model="ir.ui.view">
|
||||
<field name="name">Account Move Line sub-accounts tree view</field>
|
||||
<field name="model">account.move.line</field>
|
||||
<field name="inherit_id" ref="account.view_move_line_tree" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='analytic_distribution']" position="after">
|
||||
<field name="sub_account_customer" optional="hide" />
|
||||
<field name="sub_account_supplier" optional="hide" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
16
account_sub_accounts/views/res_partner_views.xml
Normal file
16
account_sub_accounts/views/res_partner_views.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="res_partner_form_sub_accounts_view" model="ir.ui.view">
|
||||
<field name="name">Res Partner sub-accounts form view</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref="account.view_partner_property_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page[@name='accounting']/group" position="inside">
|
||||
<group string="Sub-accounts" name="sub_accounts">
|
||||
<field name="sub_account_customer" />
|
||||
<field name="sub_account_supplier" />
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user