mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
Merge remote-tracking branch 'origin/8.0' into 9-sorrento-code-sprint
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
##############################################################################
|
||||
{
|
||||
'name': 'account banking payment blocking',
|
||||
'version': '8.0.0.1.0',
|
||||
'version': '8.0.1.0.0',
|
||||
'category': 'Banking addons',
|
||||
'summary': """
|
||||
Prevent invoices under litigation to be proposed in payment orders.
|
||||
|
||||
28
account_payment_blocking/i18n/es.po
Normal file
28
account_payment_blocking/i18n/es.po
Normal file
@@ -0,0 +1,28 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * account_payment_blocking
|
||||
#
|
||||
# Translators:
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: bank-payment (8.0)\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-04-08 00:46+0000\n"
|
||||
"PO-Revision-Date: 2016-04-06 00:15+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: Spanish (http://www.transifex.com/oca/OCA-bank-payment-8-0/language/es/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Language: es\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
#. module: account_payment_blocking
|
||||
#: model:ir.model,name:account_payment_blocking.model_account_invoice
|
||||
msgid "Invoice"
|
||||
msgstr "Factura"
|
||||
|
||||
#. module: account_payment_blocking
|
||||
#: field:account.invoice,blocked:0 field:account.invoice,draft_blocked:0
|
||||
msgid "No Follow Up"
|
||||
msgstr ""
|
||||
28
account_payment_blocking/i18n/nl.po
Normal file
28
account_payment_blocking/i18n/nl.po
Normal file
@@ -0,0 +1,28 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * account_payment_blocking
|
||||
#
|
||||
# Translators:
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: bank-payment (8.0)\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-04-08 00:46+0000\n"
|
||||
"PO-Revision-Date: 2016-04-06 00:15+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: Dutch (http://www.transifex.com/oca/OCA-bank-payment-8-0/language/nl/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Language: nl\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
#. module: account_payment_blocking
|
||||
#: model:ir.model,name:account_payment_blocking.model_account_invoice
|
||||
msgid "Invoice"
|
||||
msgstr "Factuur"
|
||||
|
||||
#. module: account_payment_blocking
|
||||
#: field:account.invoice,blocked:0 field:account.invoice,draft_blocked:0
|
||||
msgid "No Follow Up"
|
||||
msgstr ""
|
||||
29
account_payment_blocking/i18n/pt_BR.po
Normal file
29
account_payment_blocking/i18n/pt_BR.po
Normal file
@@ -0,0 +1,29 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * account_payment_blocking
|
||||
#
|
||||
# Translators:
|
||||
# danimaribeiro <danimaribeiro@gmail.com>, 2016
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: bank-payment (8.0)\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-04-08 00:46+0000\n"
|
||||
"PO-Revision-Date: 2016-04-06 01:01+0000\n"
|
||||
"Last-Translator: danimaribeiro <danimaribeiro@gmail.com>\n"
|
||||
"Language-Team: Portuguese (Brazil) (http://www.transifex.com/oca/OCA-bank-payment-8-0/language/pt_BR/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Language: pt_BR\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#. module: account_payment_blocking
|
||||
#: model:ir.model,name:account_payment_blocking.model_account_invoice
|
||||
msgid "Invoice"
|
||||
msgstr "Fatura"
|
||||
|
||||
#. module: account_payment_blocking
|
||||
#: field:account.invoice,blocked:0 field:account.invoice,draft_blocked:0
|
||||
msgid "No Follow Up"
|
||||
msgstr "Sem acompanhamento"
|
||||
29
account_payment_blocking/i18n/sl.po
Normal file
29
account_payment_blocking/i18n/sl.po
Normal file
@@ -0,0 +1,29 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * account_payment_blocking
|
||||
#
|
||||
# Translators:
|
||||
# Matjaž Mozetič <m.mozetic@matmoz.si>, 2016
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: bank-payment (8.0)\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-04-08 00:46+0000\n"
|
||||
"PO-Revision-Date: 2016-04-08 05:00+0000\n"
|
||||
"Last-Translator: Matjaž Mozetič <m.mozetic@matmoz.si>\n"
|
||||
"Language-Team: Slovenian (http://www.transifex.com/oca/OCA-bank-payment-8-0/language/sl/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Language: sl\n"
|
||||
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n"
|
||||
|
||||
#. module: account_payment_blocking
|
||||
#: model:ir.model,name:account_payment_blocking.model_account_invoice
|
||||
msgid "Invoice"
|
||||
msgstr "Račun"
|
||||
|
||||
#. module: account_payment_blocking
|
||||
#: field:account.invoice,blocked:0 field:account.invoice,draft_blocked:0
|
||||
msgid "No Follow Up"
|
||||
msgstr "Brez opominov"
|
||||
@@ -33,6 +33,20 @@ class account_invoice(orm.Model):
|
||||
('invoice.id', '=', invoice_id)],
|
||||
context=context)
|
||||
|
||||
def _update_blocked(self, cr, uid, invoice, value, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
else:
|
||||
context = context.copy()
|
||||
if invoice.move_id.id:
|
||||
move_line_ids = self._get_move_line(cr, uid, invoice.id,
|
||||
context=context)
|
||||
# work with account_constraints from OCA/AFT:
|
||||
context.update({'from_parent_object': True})
|
||||
self.pool.get('account.move.line')\
|
||||
.write(cr, uid, move_line_ids, {'blocked': value},
|
||||
context=context)
|
||||
|
||||
def _set_move_blocked(self, cr, uid, ids, name, field_value, arg,
|
||||
context=None):
|
||||
if context is None:
|
||||
@@ -40,15 +54,16 @@ class account_invoice(orm.Model):
|
||||
if isinstance(ids, (int, long)):
|
||||
ids = [ids]
|
||||
for invoice in self.browse(cr, uid, ids, context=context):
|
||||
if invoice.move_id.id:
|
||||
move_line_ids = self._get_move_line(cr, uid, invoice.id,
|
||||
context=context)
|
||||
assert len(move_line_ids) == 1
|
||||
# work with account_constraints from OCA/AFT:
|
||||
context.update({'from_parent_object': True})
|
||||
self.pool.get('account.move.line')\
|
||||
.write(cr, uid, move_line_ids, {'blocked': field_value},
|
||||
context=context)
|
||||
self._update_blocked(cr, uid, invoice, field_value,
|
||||
context=context)
|
||||
|
||||
def action_move_create(self, cr, uid, ids, context=None):
|
||||
res = super(account_invoice, self).action_move_create(cr, uid, ids,
|
||||
context=context)
|
||||
for invoice in self.browse(cr, uid, ids, context=context):
|
||||
self._update_blocked(cr, uid, invoice, invoice.draft_blocked,
|
||||
context=context)
|
||||
return res
|
||||
|
||||
def _get_move_blocked(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
@@ -58,10 +73,10 @@ class account_invoice(orm.Model):
|
||||
if invoice.move_id.id:
|
||||
move_line_ids = self._get_move_line(cr, uid, invoice.id,
|
||||
context=context)
|
||||
assert len(move_line_ids) == 1
|
||||
move_line = self.pool.get('account.move.line')\
|
||||
.browse(cr, uid, move_line_ids, context=context)[0]
|
||||
res[invoice.id] = move_line.blocked
|
||||
move_lines = self.pool.get('account.move.line')\
|
||||
.browse(cr, uid, move_line_ids, context=context)
|
||||
res[invoice.id] = move_lines and\
|
||||
all(line.blocked for line in move_lines) or False
|
||||
else:
|
||||
res[invoice.id] = False
|
||||
return res
|
||||
@@ -72,4 +87,5 @@ class account_invoice(orm.Model):
|
||||
type='boolean', string='No Follow Up',
|
||||
states={'draft': [('readonly',
|
||||
True)]}),
|
||||
'draft_blocked': fields.boolean(string='No Follow Up'),
|
||||
}
|
||||
|
||||
@@ -20,15 +20,16 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import orm
|
||||
from openerp import api, models
|
||||
|
||||
|
||||
class payment_order_create(orm.TransientModel):
|
||||
class PaymentOrderCreate(models.TransientModel):
|
||||
_inherit = 'payment.order.create'
|
||||
|
||||
@api.multi
|
||||
def extend_payment_order_domain(
|
||||
self, cr, uid, ids, payment_order, domain, context=None):
|
||||
super(payment_order_create, self).extend_payment_order_domain(
|
||||
cr, uid, ids, payment_order, domain, context=context)
|
||||
self, payment_order, domain):
|
||||
super(PaymentOrderCreate, self).extend_payment_order_domain(
|
||||
payment_order, domain)
|
||||
domain += [('blocked', '!=', True)]
|
||||
return True
|
||||
|
||||
@@ -24,13 +24,14 @@ import openerp.tests.common as common
|
||||
from openerp import workflow
|
||||
|
||||
|
||||
def create_simple_invoice(self, cr, uid, context=None):
|
||||
def create_simple_invoice(self, cr, uid, payment_term=False, context=None):
|
||||
partner_id = self.ref('base.res_partner_2')
|
||||
product_id = self.ref('product.product_product_4')
|
||||
return self.registry('account.invoice')\
|
||||
.create(cr, uid, {'partner_id': partner_id,
|
||||
'account_id':
|
||||
self.ref('account.a_recv'),
|
||||
'payment_term': payment_term,
|
||||
'journal_id':
|
||||
self.ref('account.expenses_journal'),
|
||||
'invoice_line': [(0, 0, {'name': 'test',
|
||||
@@ -57,6 +58,8 @@ class TestAccountBankingPaymentBlocking(common.TransactionCase):
|
||||
move_line_obj = self.registry('account.move.line')
|
||||
invoice_id = create_simple_invoice(self, self.cr, self.uid,
|
||||
context=self.context)
|
||||
invoice_obj.write(self.cr, self.uid, [invoice_id],
|
||||
{'draft_blocked': True})
|
||||
workflow.trg_validate(self.uid, 'account.invoice', invoice_id,
|
||||
'invoice_open', self.cr)
|
||||
invoice = invoice_obj.browse(self.cr, self.uid, [invoice_id],
|
||||
@@ -66,12 +69,40 @@ class TestAccountBankingPaymentBlocking(common.TransactionCase):
|
||||
['payable', 'receivable']),
|
||||
('invoice.id', '=', invoice.id)])
|
||||
move_line = move_line_obj.browse(self.cr, self.uid, move_line_ids)[0]
|
||||
self.assertTrue(move_line.blocked)
|
||||
self.assertEqual(invoice.blocked, move_line.blocked,
|
||||
'Blocked values are not equals')
|
||||
move_line_obj.write(self.cr, self.uid, move_line_ids,
|
||||
{'blocked': True})
|
||||
{'blocked': False})
|
||||
invoice = invoice_obj.browse(self.cr, self.uid, [invoice_id],
|
||||
context=self.context)[0]
|
||||
move_line = move_line_obj.browse(self.cr, self.uid, move_line_ids)[0]
|
||||
self.assertEqual(invoice.blocked, move_line.blocked,
|
||||
'Blocked values are not equals')
|
||||
|
||||
def test_invoice_payment_term(self):
|
||||
invoice_obj = self.registry('account.invoice')
|
||||
move_line_obj = self.registry('account.move.line')
|
||||
payment_term_advance = self.ref('account.account_payment_term_advance')
|
||||
invoice_id = create_simple_invoice(self, self.cr, self.uid,
|
||||
payment_term=payment_term_advance,
|
||||
context=self.context)
|
||||
invoice_obj.write(self.cr, self.uid, [invoice_id],
|
||||
{'draft_blocked': True})
|
||||
workflow.trg_validate(self.uid, 'account.invoice', invoice_id,
|
||||
'invoice_open', self.cr)
|
||||
invoice = invoice_obj.browse(self.cr, self.uid, [invoice_id],
|
||||
context=self.context)[0]
|
||||
move_line_ids = move_line_obj\
|
||||
.search(self.cr, self.uid, [('account_id.type', 'in',
|
||||
['payable', 'receivable']),
|
||||
('invoice.id', '=', invoice.id)])
|
||||
move_lines = move_line_obj.browse(self.cr, self.uid, move_line_ids)
|
||||
self.assertTrue(
|
||||
move_lines and all(line.blocked for line in move_lines) or False)
|
||||
move_line_obj.write(self.cr, self.uid, move_line_ids,
|
||||
{'blocked': False})
|
||||
invoice = invoice_obj.browse(self.cr, self.uid, [invoice_id],
|
||||
context=self.context)[0]
|
||||
self.assertEqual(invoice.blocked, False,
|
||||
'Blocked values are not equals')
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
<field name="inherit_id" ref="account.invoice_supplier_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="move_id" position="after">
|
||||
<field name="blocked"/>
|
||||
<field name="blocked" attrs="{'invisible': [('move_id', '=', False)]}"/>
|
||||
<field name="draft_blocked" attrs="{'invisible': [('move_id', '!=', False)]}"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user