Skip to content

Commit

Permalink
Merge pull request #134 from coopiteasy/9.0-account-fiscal-position
Browse files Browse the repository at this point in the history
[ADD] account_default_fiscal_position
  • Loading branch information
Houssine BAKKALI authored Nov 25, 2020
2 parents 8e7a07e + 13c812b commit 7acc7f9
Show file tree
Hide file tree
Showing 10 changed files with 585 additions and 0 deletions.
61 changes: 61 additions & 0 deletions account_default_fiscal_position/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
===============================
Default Partner Fiscal Position
===============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-coopiteasy%2Faddons-lightgray.png?logo=github
:target: https://github.com/coopiteasy/addons/tree/9.0/account_default_fiscal_position
:alt: coopiteasy/addons

|badge1| |badge2| |badge3|


Set the default fiscal positions for countries in
- Accounting > Configuration > Accounting > Fiscal Positions.

If a partner is created for those set countries, the fiscal position will be set.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/coopiteasy/addons/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 <https://github.com/coopiteasy/addons/issues/new?body=module:%20account_default_fiscal_position%0Aversion:%209.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Coop IT Easy SCRLfs

Contributors
~~~~~~~~~~~~

* Robin Keunen <[email protected]>

Maintainers
~~~~~~~~~~~

This module is part of the `coopiteasy/addons <https://github.com/coopiteasy/addons/tree/9.0/account_default_fiscal_position>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions account_default_fiscal_position/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions account_default_fiscal_position/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2020 Coop IT Easy SCRL fs
# Robin Keunen <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).


{
"name": "Default Partner Fiscal Position",
"version": "9.0.1.0.0",
"author": "Coop IT Easy SCRLfs",
"category": "Accounting",
"website": "https://www.coopiteasy.be",
"depends": ["account"],
"data": ["views/account_fiscal_position.xml",],
"license": "AGPL-3",
"summary": "Computes default partner fiscal position.",
"installable": True,
}
2 changes: 2 additions & 0 deletions account_default_fiscal_position/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import account_fiscal_position
from . import res_partner
28 changes: 28 additions & 0 deletions account_default_fiscal_position/models/account_fiscal_position.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2020 Coop IT Easy SCRL fs
# Robin Keunen <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from openerp import models, fields, api


class AccountFiscalPosition(models.Model):
_inherit = "account.fiscal.position"

country_line_ids = fields.One2many(
comodel_name="fiscal.position.line",
inverse_name="fiscal_position_id",
string="Countries",
)


class FiscalPositionLine(models.Model):
_name = "fiscal.position.line"

fiscal_position_id = fields.Many2one(
comodel_name="account.fiscal.position",
string="Fiscal Position",
required=True,
)
country_id = fields.Many2one(
comodel_name="res.country", string="Country", required=True
)
22 changes: 22 additions & 0 deletions account_default_fiscal_position/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Coop IT Easy SCRL fs
# Robin Keunen <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from openerp import models, api


class ResPartner(models.Model):
_inherit = "res.partner"

@api.model
def create(self, vals):
partner = super(ResPartner, self).create(vals)

if partner.country_id and partner.vat:
fiscal_position_line = self.env["fiscal.position.line"].search(
[("country_id", "=", partner.country_id.id)]
)
if fiscal_position_line:
fiscal_position = fiscal_position_line.fiscal_position_id
partner.property_account_position_id = fiscal_position
return partner
1 change: 1 addition & 0 deletions account_default_fiscal_position/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Robin Keunen <[email protected]>
5 changes: 5 additions & 0 deletions account_default_fiscal_position/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

Set the default fiscal positions for countries in
- Accounting > Configuration > Accounting > Fiscal Positions.

If a partner is created for those set countries, the fiscal position will be set.
Loading

0 comments on commit 7acc7f9

Please sign in to comment.