Skip to content

Commit

Permalink
[14.0][ADD] account_payment_line_import
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisOForgeFlow committed Mar 28, 2023
1 parent 9293013 commit 5b4b573
Show file tree
Hide file tree
Showing 14 changed files with 675 additions and 0 deletions.
86 changes: 86 additions & 0 deletions account_payment_line_import/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
=====================================
Payment Counterpart Lines Import XLSX
=====================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--payment-lightgray.png?logo=github
:target: https://github.com/OCA/account-payment/tree/14.0/account_payment_line_import
:alt: OCA/account-payment
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-payment-14-0/account-payment-14-0-account_payment_line_import
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/account-payment&target_branch=14.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module add import xlsx template to import payment distribution

**Table of contents**

.. contents::
:local:

Usage
=====

In draft state on payment you can open wizard on action "Import Excel", or use bottom "Import Payment Distribution", you can download sample on wizard

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-payment/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/OCA/account-payment/issues/new?body=module:%20account_payment_line_import%0Aversion:%2014.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
~~~~~~~

* ForgeFlow S.L.

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

* Christopher Ormaza. <chris.ormaza@forgeflow.com>

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

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-ChrisOForgeFlow| image:: https://github.com/ChrisOForgeFlow.png?size=40px
:target: https://github.com/ChrisOForgeFlow
:alt: ChrisOForgeFlow

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-ChrisOForgeFlow|

This module is part of the `OCA/account-payment <https://github.com/OCA/account-payment/tree/14.0/account_payment_line_import>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions account_payment_line_import/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright 2023 ForgeFlow, S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import models
20 changes: 20 additions & 0 deletions account_payment_line_import/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2023 ForgeFlow, S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

{
"name": "Payment Counterpart Lines Import XLSX",
"summary": """Payment Counterpart Lines Import XLSX""",
"author": "ForgeFlow S.L., Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-payment",
"category": "Account",
"version": "14.0.1.0.0",
"license": "LGPL-3",
"depends": ["account_payment_line", "excel_import_export"],
"data": [
"views/account_payment_view.xml",
"data/import_template.xml",
],
"maintainers": ["ChrisOForgeFlow"],
"installable": True,
"auto_install": False,
}
34 changes: 34 additions & 0 deletions account_payment_line_import/data/import_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>


<record id="payment_counterpart_line_xlsx_template" model="xlsx.template">
<field name="res_model">account.payment</field>
<field name="fname">payment_detail.xlsx</field>
<field name="name">Payment Distribution (import)</field>
<field name="description">Payment Distribution</field>
<field
name="import_action_id"
eval="ref('action_account_payment_import_xlsx')"
/>
<field name="input_instruction">
{
'__IMPORT__': {
'payment_distribution': {
'_NODEL_line_payment_counterpart_ids': {
'A2': 'name',
'B2': 'move_id',
'C2': 'amount',
'D2': 'account_id',
'E2': 'analytic_account_id',
}
}
},
'__POST_IMPORT__': '${object.post_import_process_lines()}',
}
</field>
</record>
<function model="xlsx.template" name="load_xlsx_template">
<value eval="[ref('payment_counterpart_line_xlsx_template')]" />
</function>
</odoo>
Binary file not shown.
3 changes: 3 additions & 0 deletions account_payment_line_import/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright 2023 ForgeFlow, S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import account_payment
53 changes: 53 additions & 0 deletions account_payment_line_import/models/account_payment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright 2023 ForgeFlow, S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from contextlib import suppress

from odoo import api, models


class AccountPayment(models.Model):

_inherit = "account.payment"

@api.model
def load(self, fields, data):
account_move = self.env["account.move"]
if "template_context" in self.env.context and self.env.context.get(
"active_id", False
):
fields.append("line_payment_counterpart_ids/partner_id")
current_payment = self.browse(self.env.context.get("active_id"))
current_payment.action_delete_counterpart_lines()
current_partner = current_payment.partner_id
new_data = []
for line in data:
# Description
if len(line[1]) == 0:
line[1] = "/"
# Invoice / Refund
if len(line[2]) != 0:
# Can be ID
with suppress(ValueError):
invoice_id = int(line[2])
invoice = account_move.browse(invoice_id)
line[2] = invoice.name
line.append(invoice.partner_id.name)
# Account
if len(line[4]) == 0:
if current_payment.destination_account_id:
line[4] = current_payment.destination_account_id.code
# If partner not on invoice search by ID
if len(line) != len(fields):
line.append(current_partner.name)
new_data.append(line)
data = new_data
return super().load(fields, data)

def post_import_process_lines(self):
for line in self.line_payment_counterpart_ids.filtered(lambda x: x.move_id):
current_amount = line.amount
current_description = line.name
line._onchange_move_id()
line.name = current_description
line.amount = current_amount
return True
1 change: 1 addition & 0 deletions account_payment_line_import/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Christopher Ormaza. <chris.ormaza@forgeflow.com>
1 change: 1 addition & 0 deletions account_payment_line_import/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module add import xlsx template to import payment distribution
1 change: 1 addition & 0 deletions account_payment_line_import/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In draft state on payment you can open wizard on action "Import Excel", or use bottom "Import Payment Distribution", you can download sample on wizard
Loading

0 comments on commit 5b4b573

Please sign in to comment.