diff --git a/l10n_ch_account_payment_partner/__init__.py b/l10n_ch_account_payment_partner/__init__.py new file mode 100644 index 0000000..83e553a --- /dev/null +++ b/l10n_ch_account_payment_partner/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/l10n_ch_account_payment_partner/__manifest__.py b/l10n_ch_account_payment_partner/__manifest__.py new file mode 100644 index 0000000..0cfd77a --- /dev/null +++ b/l10n_ch_account_payment_partner/__manifest__.py @@ -0,0 +1,14 @@ +{ + "name": "Account Payment Partner for Switzerland", + "version": "2.0.1.0.0", + "category": "Banking addons", + "license": "AGPL-3", + "summary": "Set partner bank on outgoing invoices", + "author": "Jamotion GmbH", + "website": "https://jamotion.ch", + "depends": ["account_payment_partner", "l10n_ch"], + "data": [], + "demo": [], + "installable": True, + "auto_install": True, +} diff --git a/l10n_ch_account_payment_partner/models/__init__.py b/l10n_ch_account_payment_partner/models/__init__.py new file mode 100644 index 0000000..9c0a421 --- /dev/null +++ b/l10n_ch_account_payment_partner/models/__init__.py @@ -0,0 +1 @@ +from . import account_move diff --git a/l10n_ch_account_payment_partner/models/account_move.py b/l10n_ch_account_payment_partner/models/account_move.py new file mode 100644 index 0000000..2d03fad --- /dev/null +++ b/l10n_ch_account_payment_partner/models/account_move.py @@ -0,0 +1,39 @@ +# Copyright 2014-16 Akretion - Alexis de Lattre +# Copyright 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza +# Copyright 2021 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from flectra import api, fields, models + + +class AccountMove(models.Model): + _inherit = "account.move" + + @api.depends("partner_id", "payment_mode_id") + def _compute_partner_bank(self): + for move in self: + # No bank account assignation is done for out_invoice as this is only + # needed for printing purposes and it can conflict with + # SEPA direct debit payments. Current report prints it. + def get_bank_id(): + return move.commercial_partner_id.bank_ids.filtered( + lambda b: b.company_id == move.company_id or not b.company_id + )[:1] + + bank_id = False + if move.partner_id: + pay_mode = move.payment_mode_id + if move.move_type == "in_invoice": + if ( + pay_mode + and pay_mode.payment_type == "outbound" + and pay_mode.payment_method_id.bank_account_required + and move.commercial_partner_id.bank_ids + ): + bank_id = get_bank_id() + elif move.move_type == 'out_invoice': + if pay_mode.bank_account_link == 'fixed': + bank_id = pay_mode.fixed_journal_id.bank_account_id + + if bank_id: + move.partner_bank_id = bank_id diff --git a/l10n_ch_account_payment_partner/static/description/icon.png b/l10n_ch_account_payment_partner/static/description/icon.png new file mode 100644 index 0000000..98cf47e Binary files /dev/null and b/l10n_ch_account_payment_partner/static/description/icon.png differ diff --git a/l10n_ch_account_payment_partner/static/description/index.html b/l10n_ch_account_payment_partner/static/description/index.html new file mode 100644 index 0000000..612042b --- /dev/null +++ b/l10n_ch_account_payment_partner/static/description/index.html @@ -0,0 +1,94 @@ +
+
+
+
+ +

Set bank on customer invoices

+

Set bank of payment mode or default bank

+
+
+
+ +
+
+

Quick Start

+
+

Installation

+
+

+ There are no dependencies so you can simply install the module. +

+
+
+
+

Configuration

+
+

+ Nothing to configure. Just use it... +

+
+
+
+

Usage

+
+

+ Create a customer invoice, select partner and the bank will be set automatically. +

+
+
+ +
+
+ +
+
+

Need more?

+

Other available modules

+
+
+
+

Module 1

+

+ Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt + ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo + dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor + sit amet. Lorem ipsum dolor sit amet.

+
+
+

Module 2

+

+ Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt + ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo + dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor + sit amet. Lorem ipsum dolor sit amet.

+
+
+

Module 3

+

Some words about the module

+
+
+
+
\ No newline at end of file diff --git a/l10n_ch_account_payment_partner/static/description/module-banner-example.png b/l10n_ch_account_payment_partner/static/description/module-banner-example.png new file mode 100644 index 0000000..977ff09 Binary files /dev/null and b/l10n_ch_account_payment_partner/static/description/module-banner-example.png differ diff --git a/l10n_ch_account_payment_partner/static/description/pricelist_partner.png b/l10n_ch_account_payment_partner/static/description/pricelist_partner.png new file mode 100644 index 0000000..d03eb93 Binary files /dev/null and b/l10n_ch_account_payment_partner/static/description/pricelist_partner.png differ