Merge branch 'master-patch-july-2018' into 'master-patch-july-2018'

[IMP]: Added Upstream Patch for account

See merge request flectra-hq/flectra!102
This commit is contained in:
Parthiv Patel 2018-07-19 08:51:57 +00:00
commit 750aef6e5f
2 changed files with 4 additions and 5 deletions

View File

@ -445,7 +445,7 @@ class AccountMoveLine(models.Model):
tax_line_id = fields.Many2one('account.tax', string='Originator tax', ondelete='restrict')
analytic_account_id = fields.Many2one('account.analytic.account', string='Analytic Account')
analytic_tag_ids = fields.Many2many('account.analytic.tag', string='Analytic tags')
company_id = fields.Many2one('res.company', related='account_id.company_id', string='Company', store=True)
company_id = fields.Many2one('res.company', related='account_id.company_id', string='Company', store=True, readonly=True)
branch_id = fields.Many2one(related='move_id.branch_id', string='Branch',
store=True)
counterpart = fields.Char("Counterpart", compute='_get_counterpart', help="Compute the counter part accounts of this journal item for this journal entry. This can be needed in reports.")
@ -1206,7 +1206,7 @@ class AccountMoveLine(models.Model):
current_invoice = self.env['account.invoice'].browse(self.env.context['invoice_id'])
aml_to_keep = current_invoice.move_id.line_ids | current_invoice.move_id.line_ids.mapped('full_reconcile_id.exchange_move_id.line_ids')
rec_move_ids = rec_move_ids.filtered(
lambda r: (r.debit_move_id + r.credit_move_id) & current_invoice.move_id.line_ids
lambda r: (r.debit_move_id + r.credit_move_id) & aml_to_keep
)
return rec_move_ids.unlink()

View File

@ -790,8 +790,7 @@ class TestReconciliation(AccountingTestCase):
statement = self.make_payment(invoice, journal, 50)
# Case 1: The invoice and payment are reconciled: Nothing should appear
report_lines, total, amls = AgedReport._get_partner_move_lines(account_type, report_date_to, 'posted', 30)
report_lines, total, amls = AgedReport._get_partner_move_lines(account_type, report_date_to, 'posted', 30, self.env.user.company_id.branch_id)
partner_lines = [line for line in report_lines if line['partner_id'] == partner.id]
self.assertEqual(partner_lines, [], 'The aged receivable shouldn\'t have lines at this point')
self.assertFalse(partner.id in amls, 'The aged receivable should not have amls either')
@ -799,7 +798,7 @@ class TestReconciliation(AccountingTestCase):
# Case 2: The invoice and payment are not reconciled: we should have one line on the report
# and 2 amls
invoice.move_id.line_ids.with_context(invoice_id=invoice.id).remove_move_reconcile()
report_lines, total, amls = AgedReport._get_partner_move_lines(account_type, report_date_to, 'posted', 30)
report_lines, total, amls = AgedReport._get_partner_move_lines(account_type, report_date_to, 'posted', 30, self.env.user.company_id.branch_id)
partner_lines = [line for line in report_lines if line['partner_id'] == partner.id]
self.assertEqual(partner_lines, [{'trust': 'normal', '1': 0.0, '0': 0.0, 'direction': 0.0, 'partner_id': partner.id, '3': 0.0, 'total': 0.0, 'name': 'AgedPartner', '4': 0.0, '2': 0.0}],