Skip to content

Commit

Permalink
Merge remote-tracking branch 'odoo/11.0' into 11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
OCA-git-bot committed Oct 1, 2019
2 parents 68bcba4 + 1043d16 commit 15e0cbe
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 9 deletions.
21 changes: 13 additions & 8 deletions addons/account/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -1842,25 +1842,30 @@ def _compute_partial_lines(self):
#when running the manual reconciliation wizard, don't check the partials separately for full
#reconciliation or exchange rate because it is handled manually after the whole processing
return self
#check if the reconcilation is full
#first, gather all journal items involved in the reconciliation just created

# check if the reconcilation is full
# Determine the main foreign currency across all past partial reconciliations
currency = None

aml_set = aml_to_balance = self.env['account.move.line']
total_debit = 0
total_credit = 0
total_amount_currency = 0
#make sure that all partial reconciliations share the same secondary currency otherwise it's not
#possible to compute the exchange difference entry and it has to be done manually.
currency = self[0].currency_id
maxdate = '0000-00-00'

seen = set()
todo = set(self)
while todo:
partial_rec = todo.pop()
seen.add(partial_rec)
if partial_rec.currency_id != currency:
#no exchange rate entry will be created
currency = None
# make sure that all partial reconciliations share the same secondary currency otherwise it's not
# possible to compute the exchange difference entry and it has to be done manually.
if currency is None and partial_rec.currency_id:
currency = partial_rec.currency_id
elif currency and partial_rec.currency_id and partial_rec.currency_id != currency:
# no exchange rate entry will be created
currency = False

for aml in [partial_rec.debit_move_id, partial_rec.credit_move_id]:
if aml not in aml_set:
if aml.amount_residual or aml.amount_residual_currency:
Expand Down
59 changes: 59 additions & 0 deletions addons/account/tests/test_reconciliation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,3 +1026,62 @@ def test_inv_refund_foreign_payment_writeoff_domestic(self):

self.assertEquals(inv1.state, 'paid')
self.assertEquals(inv2.state, 'paid')

def test_inv_refund_foreign_payment_writeoff_domestic2(self):
company = self.env.ref('base.main_company')
self.env['res.currency.rate'].search([]).unlink()
self.env['res.currency.rate'].create({
'name': time.strftime('%Y') + '-07-01',
'rate': 1.0,
'currency_id': self.currency_euro_id,
'company_id': company.id
})
self.env['res.currency.rate'].create({
'name': time.strftime('%Y') + '-07-01',
'rate': 1.110600, # Don't change this !
'currency_id': self.currency_usd_id,
'company_id': self.env.ref('base.main_company').id
})
inv1 = self.create_invoice(invoice_amount=800, currency_id=self.currency_usd_id)
inv2 = self.create_invoice(type="out_refund", invoice_amount=400, currency_id=self.currency_usd_id)

payment = self.env['account.payment'].create({
'payment_method_id': self.inbound_payment_method.id,
'payment_type': 'inbound',
'partner_type': 'customer',
'partner_id': inv1.partner_id.id,
'amount': 200.00,
'journal_id': self.bank_journal_euro.id,
'company_id': company.id,
})
payment.post()

inv1_receivable = inv1.move_id.line_ids.filtered(lambda l: l.account_id.internal_type == 'receivable')
inv2_receivable = inv2.move_id.line_ids.filtered(lambda l: l.account_id.internal_type == 'receivable')
pay_receivable = payment.move_line_ids.filtered(lambda l: l.account_id.internal_type == 'receivable')

move_balance = self.env['account.move'].create({
'partner_id': inv1.partner_id.id,
'date': time.strftime('%Y') + '-07-01',
'journal_id': self.bank_journal_euro.id,
'line_ids': [
(0, False, {'credit': 160.16, 'account_id': inv1_receivable.account_id.id, 'name': 'Balance WriteOff'}),
(0, False, {'debit': 160.16, 'account_id': self.diff_expense_account.id, 'name': 'Balance WriteOff'}),
]
})

move_balance.post()
move_balance_receiv = move_balance.line_ids.filtered(lambda l: l.account_id.internal_type == 'receivable')

(inv1_receivable + inv2_receivable + pay_receivable + move_balance_receiv).reconcile()

self.assertTrue(inv1_receivable.full_reconcile_id.exists())
self.assertEquals(inv1_receivable.full_reconcile_id, inv2_receivable.full_reconcile_id)
self.assertEquals(inv1_receivable.full_reconcile_id, pay_receivable.full_reconcile_id)
self.assertEquals(inv1_receivable.full_reconcile_id, move_balance_receiv.full_reconcile_id)

self.assertTrue(inv1.reconciled)
self.assertTrue(inv2.reconciled)

self.assertEquals(inv1.state, 'paid')
self.assertEquals(inv2.state, 'paid')
11 changes: 11 additions & 0 deletions doc/cla/individual/joeycodinja.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Jamaica, 2019-09-02

I hereby agree to the terms of the Odoo Individual Contributor License
Agreement v1.0.

I declare that I am authorized and able to make this agreement and sign this
declaration.

Signed,

Danuel Williams joseph_thesaint@hotmail.com https://github.com/JoeyCodinja
2 changes: 1 addition & 1 deletion doc/howtos/backend/exercise-kanban
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Index: addons/openacademy/views/openacademy.xml
</record>

+ <record model="ir.ui.view" id="view_openacad_session_kanban">
+ <field name="name">openacad.session.kanban</field>
+ <field name="name">openacademy.session.kanban</field>
+ <field name="model">openacademy.session</field>
+ <field name="arch" type="xml">
+ <kanban default_group_by="course_id">
Expand Down

0 comments on commit 15e0cbe

Please sign in to comment.