Skip to content

Commit

Permalink
[MIG] sale_merge_draft_invoice: Migration to 11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rgarnau committed Dec 19, 2017
1 parent 78d9ef8 commit 1bbb1ba
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 66 deletions.
14 changes: 9 additions & 5 deletions sale_merge_draft_invoice/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
Sale Merge Draft Invoice
========================

This module merges new invoices with existing draft ones when creating them.

The merge between invoices is done when the partner and the currency are the
same.
Odoo can merge sales orders into a single invoice, grouped by partner and
currency, when the sales orders are selected and invoiced together. This module
extends the grouping to also consider any pre-existing draft invoices and merge
them.

This feature is activated from Sales / Settings and assigned to the company
settings.
Expand All @@ -18,6 +18,10 @@ Users assigned to the group 'Change sale to invoice merge proposal'
have the possibility to activate or deactivate this option at the moment of
invoicing.

If you also need to group on fields other than partner and currency, the OCA
module sale_invoice_group_method allows you to specify alternative grouping
methods and is fully compatible with this module.

Configuration
=============

Expand Down Expand Up @@ -60,7 +64,7 @@ Create Invoices from a group of Sales Orders

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/167/10.0
:target: https://runbot.odoo-community.org/runbot/167/11.0

Bug Tracker
===========
Expand Down
1 change: 0 additions & 1 deletion sale_merge_draft_invoice/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

Expand Down
5 changes: 2 additions & 3 deletions sale_merge_draft_invoice/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

{
"name": "Sale Merge Draft Invoice",
"author": "Eficent, Odoo Community Association (OCA)",
"version": "10.0.1.0.0",
"version": "11.0.1.0.0",
"category": "Sale Workflow",
"website": "https://github.com/OCA/sale-workflow",
"depends": [
Expand All @@ -14,7 +13,7 @@
"data": [
'wizard/sale_make_invoice_advance_views.xml',
'security/sale_merge_draft_invoice_security.xml',
'view/sale_config_settings_views.xml',
'view/res_config_settings_views.xml',
],
"license": 'LGPL-3',
"installable": True
Expand Down
3 changes: 1 addition & 2 deletions sale_merge_draft_invoice/model/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from . import sale_order
from . import sale_config_settings
from . import res_config_settings
from . import res_company
5 changes: 1 addition & 4 deletions sale_merge_draft_invoice/model/res_company.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

Expand All @@ -8,8 +7,6 @@
class Company(models.Model):
_inherit = "res.company"

sale_merge_draft_invoice = fields.Selection([
(0, 'Create a new invoice every time a sale order is invoiced'),
(1, 'Merge new invoices with existing draft ones')],
sale_merge_draft_invoice = fields.Boolean(
string="Invoices",
)
13 changes: 13 additions & 0 deletions sale_merge_draft_invoice/model/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'

sale_merge_draft_invoice = fields.Boolean(
string="Invoices",
related='company_id.sale_merge_draft_invoice',
)
16 changes: 0 additions & 16 deletions sale_merge_draft_invoice/model/sale_config_settings.py

This file was deleted.

1 change: 0 additions & 1 deletion sale_merge_draft_invoice/model/sale_order.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

Expand Down
1 change: 0 additions & 1 deletion sale_merge_draft_invoice/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

Expand Down
17 changes: 8 additions & 9 deletions sale_merge_draft_invoice/tests/test_sale_merge_draft_invoice.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

Expand Down Expand Up @@ -121,8 +120,8 @@ def test_create_invoice_case_1(self):
group_sale_merge_draft_invoice from a company with the option
of merging invoices activated creates two sales orders. """

self.company1.sale_merge_draft_invoice = 1
self.assertEquals(self.company1.sale_merge_draft_invoice, 1,
self.company1.sale_merge_draft_invoice = True
self.assertEquals(self.company1.sale_merge_draft_invoice, True,
"The selection should be to merge invoices")
so1 = self._create_sale_order(self.user1_id)
inv1 = self._create_invoice_from_sale(so1, self.user1_id)
Expand All @@ -140,8 +139,8 @@ def test_create_invoice_case_2(self):
group_sale_merge_draft_invoice from a company without the option
of merging invoices activated creates two sales orders. """

self.company1.sale_merge_draft_invoice = 0
self.assertEquals(self.company1.sale_merge_draft_invoice, 0,
self.company1.sale_merge_draft_invoice = False
self.assertEquals(self.company1.sale_merge_draft_invoice, False,
"The selection should be not to merge invoices")
so1 = self._create_sale_order(self.user1_id)
inv1 = self._create_invoice_from_sale(so1, self.user1_id)
Expand All @@ -160,8 +159,8 @@ def test_create_invoice_case_3(self):
of merging invoices activated creates two sales orders.
In this case, the user does not want to merge them. """

self.company1.sale_merge_draft_invoice = 1
self.assertEquals(self.company1.sale_merge_draft_invoice, 1,
self.company1.sale_merge_draft_invoice = True
self.assertEquals(self.company1.sale_merge_draft_invoice, True,
"The selection should be not to merge invoices")
so1 = self._create_sale_order(self.user2_id)
inv1 = self._create_invoice_from_sale(so1, self.user2_id, False, True)
Expand All @@ -180,8 +179,8 @@ def test_create_invoice_case_4(self):
of merging invoices activated creates two sales orders.
In this case, the user wants to merge them. """

self.company1.sale_merge_draft_invoice = 0
self.assertEquals(self.company1.sale_merge_draft_invoice, 0,
self.company1.sale_merge_draft_invoice = False
self.assertEquals(self.company1.sale_merge_draft_invoice, False,
"The selection should be not to merge invoices")
so1 = self._create_sale_order(self.user2_id)
inv1 = self._create_invoice_from_sale(so1, self.user2_id, True, True)
Expand Down
32 changes: 32 additions & 0 deletions sale_merge_draft_invoice/view/res_config_settings_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
Copyright 2017 Eficent Business and IT Consulting Services, S.L.
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
-->

<odoo>

<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.sale</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="base.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@id='sale_config_online_confirmation']"
position="after">
<div class="col-xs-12 col-md-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="sale_merge_draft_invoice"/>
</div>
<div class="o_setting_right_pane">
<label for="sale_merge_draft_invoice"/>
<div class="text-muted">
Merge new invoices with existing draft ones
</div>
</div>
</div>
</xpath>
</field>
</record>

</odoo>
21 changes: 0 additions & 21 deletions sale_merge_draft_invoice/view/sale_config_settings_views.xml

This file was deleted.

1 change: 0 additions & 1 deletion sale_merge_draft_invoice/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

Expand Down
4 changes: 2 additions & 2 deletions sale_merge_draft_invoice/wizard/sale_make_invoice_advance.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

Expand All @@ -10,7 +9,8 @@ class SaleAdvancePaymentInv(models.TransientModel):

@api.model
def _get_default_merge_draft_invoice(self):
return self.env.user.company_id.sale_merge_draft_invoice == 1
if self.env.user.company_id.sale_merge_draft_invoice:
return True

merge_draft_invoice = fields.Boolean(
string='Merge with draft invoices',
Expand Down

0 comments on commit 1bbb1ba

Please sign in to comment.