Browse Source

[IMP] contract_invoice_merge_by_partner: Field contract_invoice_merge in partner

pull/33/head
Carlos Incaser 9 years ago
parent
commit
fca5121964
  1. 3
      contract_invoice_merge_by_partner/__openerp__.py
  2. 33
      contract_invoice_merge_by_partner/i18n/es.po
  3. 1
      contract_invoice_merge_by_partner/models/__init__.py
  4. 4
      contract_invoice_merge_by_partner/models/account_analytic_analysis.py
  5. 11
      contract_invoice_merge_by_partner/models/res_partner.py
  6. 4
      contract_invoice_merge_by_partner/tests/test_contract_invoice_merge_by_partner.py
  7. 19
      contract_invoice_merge_by_partner/views/res_partner_view.xml

3
contract_invoice_merge_by_partner/__openerp__.py

@ -13,5 +13,8 @@
"Odoo Community Association (OCA)",
'website': 'http://www.tecnativa.com',
'depends': ['account_analytic_analysis', 'account_invoice_merge'],
'data': [
'views/res_partner_view.xml',
],
'installable': True,
}

33
contract_invoice_merge_by_partner/i18n/es.po

@ -0,0 +1,33 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * contract_invoice_merge_by_partner
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-06-14 13:16+0000\n"
"PO-Revision-Date: 2016-06-14 15:19+0100\n"
"Last-Translator: Carlos Dauden <carlos.dauden@tecnativa.com>\n"
"Language-Team: Tecnativa <info@tecnativa.com>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.5.4\n"
"Language: es_ES\n"
"X-Poedit-SourceCharset: UTF-8\n"
#. module: contract_invoice_merge_by_partner
#: model:ir.model,name:contract_invoice_merge_by_partner.model_account_analytic_account
msgid "Analytic Account"
msgstr "Cuenta analítica"
#. module: contract_invoice_merge_by_partner
#: field:res.partner,contract_invoice_merge:0
msgid "Contract invoice merge"
msgstr "Fusionar facturas de contratos"
#. module: contract_invoice_merge_by_partner
#: model:ir.model,name:contract_invoice_merge_by_partner.model_res_partner
msgid "Partner"
msgstr "Empresa"

1
contract_invoice_merge_by_partner/models/__init__.py

@ -3,3 +3,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import account_analytic_analysis
from . import res_partner

4
contract_invoice_merge_by_partner/models/account_analytic_analysis.py

@ -18,13 +18,13 @@ class PurchaseOrderLine(models.Model):
unlink_list = []
for partner in invoices.mapped('partner_id'):
inv_to_merge = invoices.filtered(lambda x: x.partner_id == partner)
if len(inv_to_merge) > 1:
if partner.contract_invoice_merge and (len(inv_to_merge) > 1):
invoices_info = inv_to_merge.do_merge()
res.extend(invoices_info.keys())
for inv_ids_list in invoices_info.values():
unlink_list.extend(inv_ids_list)
else:
res.append(inv_to_merge.id)
res.extend(inv_to_merge.ids)
if unlink_list:
invoice_obj.browse(unlink_list).unlink()
return res

11
contract_invoice_merge_by_partner/models/res_partner.py

@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import fields, models
class ResPartner(models.Model):
_inherit = 'res.partner'
contract_invoice_merge = fields.Boolean()

4
contract_invoice_merge_by_partner/tests/test_contract_invoice_merge_by_partner.py

@ -9,10 +9,10 @@ class TestContractInvoiceMergeByPartner(TransactionCase):
""" Use case : Prepare some data for current test case """
def setUp(self):
super(TestContractInvoiceMergeByPartner, self).setUp()
#self.partner = self.env.ref('base.res_partner_2')
self.partner = self.env['res.partner'].create(
{'customer': True,
'name': "Test Customer"
'name': "Test Customer",
'contract_invoice_merge': True,
})
self.product = self.env.ref('product.product_product_consultant')
self.uom = self.env.ref('product.product_uom_hour')

19
contract_invoice_merge_by_partner/views/res_partner_view.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- © 2016 Carlos Dauden <carlos.dauden@tecnativa.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<openerp>
<data>
<record id="view_partner_form" model="ir.ui.view">
<field name="name">Partner Form Contract Invoice Merge</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="contract_invoice_merge"/>
</field>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save