-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[14.0][ADD] contract_invoice_with_start_end_date_period: Generar fact…
…uras desde contratos con fechas desde, y hasta.
- Loading branch information
1 parent
1254311
commit 4c799a9
Showing
12 changed files
with
247 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
=========================================== | ||
Contract invoice with start end date period | ||
=========================================== | ||
|
||
* In account invoice new fields: "Start date period" and "End date period". | ||
* When creating invoice from the contract. Set as the beginning date of the | ||
period the lowest date of the contract lines to be processed, and as the end | ||
date of the period, the maximum date of the contract lines to be processed. | ||
|
||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/avanzosc/odoo-addons/issues>`_. In case of trouble, | ||
please check there if your issue has already been reported. If you spotted | ||
it first, help us smash it by providing detailed and welcomed feedback. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Ana Juaristi <[email protected]> | ||
* Alfredo de la Fuente <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
15 changes: 15 additions & 0 deletions
15
contract_invoice_with_start_end_date_period/__manifest__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright 2023 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "Contract Invoice With Start End Date Period", | ||
"version": "14.0.1.0.0", | ||
"category": "Invoices & Payments", | ||
"license": "AGPL-3", | ||
"author": "AvanzOSC", | ||
"website": "http://www.avanzosc.es", | ||
"depends": ["contract", "account_invoice_with_start_end_date_period"], | ||
"data": [ | ||
], | ||
"installable": True, | ||
"auto_install": True, | ||
} |
36 changes: 36 additions & 0 deletions
36
...t_invoice_with_start_end_date_period/i18n/contract_invoice_with_start_end_date_period.pot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * contract_invoice_with_start_end_date_period | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0+e\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2023-06-28 09:15+0000\n" | ||
"PO-Revision-Date: 2023-06-28 09:15+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: contract_invoice_with_start_end_date_period | ||
#: model:ir.model,name:contract_invoice_with_start_end_date_period.model_contract_contract | ||
msgid "Contract" | ||
msgstr "" | ||
|
||
#. module: contract_invoice_with_start_end_date_period | ||
#: model:ir.model.fields,field_description:contract_invoice_with_start_end_date_period.field_contract_contract__display_name | ||
msgid "Display Name" | ||
msgstr "" | ||
|
||
#. module: contract_invoice_with_start_end_date_period | ||
#: model:ir.model.fields,field_description:contract_invoice_with_start_end_date_period.field_contract_contract__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: contract_invoice_with_start_end_date_period | ||
#: model:ir.model.fields,field_description:contract_invoice_with_start_end_date_period.field_contract_contract____last_update | ||
msgid "Last Modified on" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * contract_invoice_with_start_end_date_period | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0+e\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2023-06-28 09:15+0000\n" | ||
"PO-Revision-Date: 2023-06-28 09:15+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: contract_invoice_with_start_end_date_period | ||
#: model:ir.model,name:contract_invoice_with_start_end_date_period.model_contract_contract | ||
msgid "Contract" | ||
msgstr "" | ||
|
||
#. module: contract_invoice_with_start_end_date_period | ||
#: model:ir.model.fields,field_description:contract_invoice_with_start_end_date_period.field_contract_contract__display_name | ||
msgid "Display Name" | ||
msgstr "" | ||
|
||
#. module: contract_invoice_with_start_end_date_period | ||
#: model:ir.model.fields,field_description:contract_invoice_with_start_end_date_period.field_contract_contract__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: contract_invoice_with_start_end_date_period | ||
#: model:ir.model.fields,field_description:contract_invoice_with_start_end_date_period.field_contract_contract____last_update | ||
msgid "Last Modified on" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * contract_invoice_with_start_end_date_period | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0+e\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2023-06-28 09:15+0000\n" | ||
"PO-Revision-Date: 2023-06-28 09:15+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: contract_invoice_with_start_end_date_period | ||
#: model:ir.model,name:contract_invoice_with_start_end_date_period.model_contract_contract | ||
msgid "Contract" | ||
msgstr "Contrato" | ||
|
||
#. module: contract_invoice_with_start_end_date_period | ||
#: model:ir.model.fields,field_description:contract_invoice_with_start_end_date_period.field_contract_contract__display_name | ||
msgid "Display Name" | ||
msgstr "Nombre mostrado" | ||
|
||
#. module: contract_invoice_with_start_end_date_period | ||
#: model:ir.model.fields,field_description:contract_invoice_with_start_end_date_period.field_contract_contract__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: contract_invoice_with_start_end_date_period | ||
#: model:ir.model.fields,field_description:contract_invoice_with_start_end_date_period.field_contract_contract____last_update | ||
msgid "Last Modified on" | ||
msgstr "Última Modificación en" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import contract_contract |
35 changes: 35 additions & 0 deletions
35
contract_invoice_with_start_end_date_period/models/contract_contract.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright 2021 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from odoo import models | ||
|
||
|
||
class ContractContract(models.Model): | ||
_inherit = "contract.contract" | ||
|
||
def _prepare_invoice(self, date_invoice, journal=None): | ||
contract_lines = self._get_lines_to_invoice(date_invoice) | ||
line_min_fec = False | ||
line_max_fec = False | ||
for line in contract_lines: | ||
if line.next_period_date_start: | ||
if not line_min_fec: | ||
line_min_fec = line.next_period_date_start | ||
else: | ||
if line.next_period_date_start < line_min_fec: | ||
line_min_fec = line.next_period_date_start | ||
if line.next_period_date_end: | ||
if not line_max_fec: | ||
line_max_fec = line.next_period_date_end | ||
else: | ||
if line.next_period_date_end < line_max_fec: | ||
line_max_fec = line.next_period_date_end | ||
invoice_vals, move_form = super(ContractContract, self)._prepare_invoice( | ||
date_invoice, journal=journal | ||
) | ||
vals = {} | ||
if line_min_fec: | ||
vals["start_date_period"] = line_min_fec | ||
if line_max_fec: | ||
vals["end_date_period"] = line_max_fec | ||
if vals: | ||
return invoice_vals, move_form |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from contract_invoice_with_start_end_date_period.tests import test_contract_invoice_with_start_end_date_period |
47 changes: 47 additions & 0 deletions
47
...oice_with_start_end_date_period/tests/test_contract_invoice_with_start_end_date_period.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Copyright 2021 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from odoo.tests import common, tagged | ||
|
||
|
||
@tagged("post_install", "-at_install") | ||
class TestContractInvoiceWithStartEndDatePeriod(common.SavepointCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super(TestContractInvoiceWithStartEndDatePeriod, cls).setUpClass() | ||
cls.product_obj = cls.env["product.product"] | ||
cls.contract_obj = cls.env["contract.contract"] | ||
cls.uom_unit = cls.env.ref("uom.product_uom_unit") | ||
cls.company = cls.env["res.company"]._company_default_get("sale.order") | ||
cls.product = cls.product_obj.create( | ||
{ | ||
"name": "product account invoice with start end date period", | ||
"default_code": "PAIWSEDP", | ||
"uom_id": cls.uom_unit.id, | ||
"uom_po_id": cls.uom_unit.id, | ||
"type": "service", | ||
"invoice_policy": "order", | ||
} | ||
) | ||
cls.customer = cls.env.ref("base.res_partner_12") | ||
contract_line_vals = { | ||
"product_id": cls.product.id, | ||
"name": cls.product.name, | ||
"uom_id": cls.product.uom_id.id, | ||
"quantity": 1, | ||
"price_unit": 500, | ||
} | ||
contract_vals = { | ||
"name": "Contract account invoice with start end date period", | ||
"partner_id": cls.customer.id, | ||
"line_recurrence": True, | ||
"contract_line_ids": [(0, 0, contract_line_vals)], | ||
} | ||
cls.contract = cls.contract_obj.create(contract_vals) | ||
|
||
def test_contract_invoice_with_start_end_date_period(self): | ||
start_date = self.contract.contract_line_ids[0].next_period_date_start | ||
end_date = self.contract.contract_line_ids[0].next_period_date_end | ||
self.contract.recurring_create_invoice() | ||
invoice = self.contract._get_related_invoices() | ||
self.assertEqual(invoice.start_date_period, start_date) | ||
self.assertEqual(invoice.end_date_period, end_date) |
1 change: 1 addition & 0 deletions
1
...nvoice_with_start_end_date_period/odoo/addons/contract_invoice_with_start_end_date_period
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../contract_invoice_with_start_end_date_period |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |