Browse Source

[ADD] contract/contract_sale_invoicing: New module

pull/340/head
Carlos Dauden 6 years ago
committed by Maxime Chambreuil
parent
commit
730b6ea15c
  1. 69
      contract_sale_invoicing/README.rst
  2. 3
      contract_sale_invoicing/__init__.py
  3. 20
      contract_sale_invoicing/__manifest__.py
  4. 35
      contract_sale_invoicing/i18n/es.po
  5. 3
      contract_sale_invoicing/models/__init__.py
  6. 32
      contract_sale_invoicing/models/contract.py
  7. BIN
      contract_sale_invoicing/static/description/icon.png
  8. 3
      contract_sale_invoicing/tests/__init__.py
  9. 44
      contract_sale_invoicing/tests/test_contract_sale_invoicing.py
  10. 17
      contract_sale_invoicing/views/contract_view.xml

69
contract_sale_invoicing/README.rst

@ -0,0 +1,69 @@
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3
==========================================
Contract Invoicing of Pending Sales Orders
==========================================
This modules allows to include on the same invoice than the recurring invoice
contract, all the pending to invoice sales orders that you have with the same
analytic account.
Usage
=====
To use this module, you need to:
#. Go to Invoicing > Sales > Contracts and select or create a new contract.
#. Check *Generate recurring invoices automatically*.
#. Mark the check "Invoice Pending Sales Orders".
#. On each invoicing, system will check if there's any pending sales orders
with same analyitic account and will append the lines to the invoice being
generated.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/110/11.0
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/contract/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.
Credits
=======
Images
------
* Odoo Community Association: `Icon <https://odoo-community.org/logo.png>`_.
Contributors
------------
* `Tecnativa <https://www.tecnativa.com>`_:
* Carlos Dauden
Do not contact contributors directly about support or help with technical issues.
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
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.
To contribute to this module, please visit https://odoo-community.org.

3
contract_sale_invoicing/__init__.py

@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import models

20
contract_sale_invoicing/__manifest__.py

@ -0,0 +1,20 @@
# Copyright 2018 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
'name': 'Contract Invoicing of Pending Sales Orders',
'summary': 'Include sales to invoice in contract invoice creation',
'version': '11.0.1.0.0',
'category': 'Contract Management',
'website': 'https://github.com/oca/contract',
'author': 'Tecnativa, '
'Odoo Community Association (OCA)',
'license': 'AGPL-3',
'installable': True,
'depends': [
'contract',
'sale_management',
],
'data': [
'views/contract_view.xml',
],
}

35
contract_sale_invoicing/i18n/es.po

@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * contract_sale_invoicing
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-04-06 17:36+0200\n"
"PO-Revision-Date: 2018-04-06 17:38+0200\n"
"Last-Translator: Carlos Dauden <carlos.dauden@tecnativa.com>\n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.8.7.1\n"
#. module: contract_sale_invoicing
#: model:ir.model,name:contract_sale_invoicing.model_account_analytic_account
msgid "Analytic Account"
msgstr "Cuenta analítica"
#. module: contract_sale_invoicing
#: model:ir.model.fields,help:contract_sale_invoicing.field_account_analytic_account_invoicing_sales
#: model:ir.model.fields,help:contract_sale_invoicing.field_project_project_invoicing_sales
msgid "If checked include sales with same analytic account to invoice in contract invoice creation."
msgstr "Si está marcado se incluyen los pedidos a facturar que tengan la misma cuenta analítica en la creación de la factura del contrato"
#. module: contract_sale_invoicing
#: model:ir.model.fields,field_description:contract_sale_invoicing.field_account_analytic_account_invoicing_sales
#: model:ir.model.fields,field_description:contract_sale_invoicing.field_project_project_invoicing_sales
msgid "Invoice Pending Sales Orders"
msgstr "Facturar pedidos pendientes"

3
contract_sale_invoicing/models/__init__.py

@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import contract

32
contract_sale_invoicing/models/contract.py

@ -0,0 +1,32 @@
# Copyright 2018 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class AccountAnalyticAccount(models.Model):
_inherit = 'account.analytic.account'
invoicing_sales = fields.Boolean(
string='Invoice Pending Sales Orders',
help='If checked include sales with same analytic account to invoice '
'in contract invoice creation.',
)
@api.multi
def _create_invoice(self, invoice=False):
if not self.invoicing_sales:
return super(AccountAnalyticAccount, self)._create_invoice()
sales = self.env['sale.order'].search([
('analytic_account_id', '=', self.id),
('partner_invoice_id', 'child_of',
self.partner_id.commercial_partner_id.ids),
('invoice_status', '=', 'to invoice'),
('date_order', '<=',
'{} 23:59:59'.format(self.recurring_next_date)),
])
if sales:
invoice_ids = sales.action_invoice_create()
invoice = self.env['account.invoice'].browse(invoice_ids)[:1]
return super(AccountAnalyticAccount, self)._create_invoice(
invoice=invoice)

BIN
contract_sale_invoicing/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 9.2 KiB

3
contract_sale_invoicing/tests/__init__.py

@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import test_contract_sale_invoicing

44
contract_sale_invoicing/tests/test_contract_sale_invoicing.py

@ -0,0 +1,44 @@
# Copyright 2018 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo.addons.contract.tests.test_contract import TestContractBase
class TestContractSaleInvoicing(TestContractBase):
@classmethod
def setUpClass(cls):
super(TestContractSaleInvoicing, cls).setUpClass()
cls.product_so = cls.env.ref(
'product.service_order_01_product_template')
cls.sale_order = cls.env['sale.order'].create({
'partner_id': cls.partner.id,
'partner_invoice_id': cls.partner.id,
'partner_shipping_id': cls.partner.id,
'order_line': [(0, 0, {'name': cls.product_so.name,
'product_id': cls.product_so.id,
'product_uom_qty': 2,
'product_uom': cls.product_so.uom_id.id,
'price_unit': cls.product_so.list_price})],
'pricelist_id': cls.partner.property_product_pricelist.id,
'analytic_account_id': cls.contract.id,
'date_order': '2016-02-15',
})
def test_not_sale_invoicing(self):
self.contract.invoicing_sales = False
self.sale_order.action_confirm()
self.contract.recurring_create_invoice()
self.assertEqual(self.sale_order.invoice_status, 'to invoice')
def test_sale_invoicing(self):
self.contract.invoicing_sales = True
self.sale_order.action_confirm()
self.contract.recurring_create_invoice()
self.assertEqual(self.sale_order.invoice_status, 'invoiced')
def test_contract_sale_invoicing_without(self):
self.contract.invoicing_sales = True
self.sale_order.analytic_account_id = False
self.sale_order.action_confirm()
self.contract.recurring_create_invoice()
self.assertEqual(self.sale_order.invoice_status, 'to invoice')

17
contract_sale_invoicing/views/contract_view.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 Tecnativa - Carlos Dauden
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="account_analytic_account_recurring_form_form" model="ir.ui.view">
<field name="model">account.analytic.account</field>
<field name="inherit_id" ref="contract.account_analytic_account_recurring_form_form"/>
<field name="arch" type="xml">
<field name="recurring_next_date" position="after">
<field name="invoicing_sales"/>
</field>
</field>
</record>
</odoo>
Loading…
Cancel
Save