diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-04-05 18:46:10 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-04-05 18:46:10 +0200 |
| commit | 3f95b074e959f0f4ac93fbf4048c0c7276f2c17a (patch) | |
| tree | f4e793da5d83bcd1bd4347f71cb3f45cbc953df3 /addons/account | |
| parent | 1a871d72438c731d08ef10e668b81b4ade900b85 (diff) | |
| parent | f2be461f0906ed47306da58c31240014b6239d80 (diff) | |
[MERGE] forward port branch saas-12.2 up to f2be461f090
Diffstat (limited to 'addons/account')
6 files changed, 36 insertions, 24 deletions
diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py index b63543a6b0f..487477dee6a 100644 --- a/addons/account/models/account_bank_statement.py +++ b/addons/account/models/account_bank_statement.py @@ -235,14 +235,18 @@ class AccountBankStatement(models.Model): statements = self.filtered(lambda r: r.state == 'open') for statement in statements: moves = self.env['account.move'] + # `line.journal_entry_ids` gets invalidated from the cache during the loop + # because new move lines are being created at each iteration. + # The below dict is to prevent the ORM to permanently refetch `line.journal_entry_ids` + line_journal_entries = {line: line.journal_entry_ids for line in statement.line_ids} for st_line in statement.line_ids: #upon bank statement confirmation, look if some lines have the account_id set. It would trigger a journal entry #creation towards that account, with the wanted side-effect to skip that line in the bank reconciliation widget. + journal_entries = line_journal_entries[st_line] st_line.fast_counterpart_creation() - if not st_line.account_id and not st_line.journal_entry_ids.ids and not st_line.statement_id.currency_id.is_zero(st_line.amount): + if not st_line.account_id and not journal_entries.ids and not st_line.statement_id.currency_id.is_zero(st_line.amount): raise UserError(_('All the account entries lines must be processed in order to close the statement.')) - for aml in st_line.journal_entry_ids: - moves |= aml.move_id + moves = statement.mapped('line_ids.journal_entry_ids.move_id') if moves: moves.filtered(lambda m: m.state != 'posted').post() statement.message_post(body=_('Statement %s confirmed, journal items were created.') % (statement.name,)) diff --git a/addons/account/models/reconciliation_widget.py b/addons/account/models/reconciliation_widget.py index 875a346dabd..4683afab86f 100644 --- a/addons/account/models/reconciliation_widget.py +++ b/addons/account/models/reconciliation_widget.py @@ -95,6 +95,17 @@ class AccountReconciliation(models.AbstractModel): WHERE st_line.id IN %s ''' params = [tuple(st_lines.ids)] + + # Add the res.partner's IR rules to the WHERE clause. In case partners are not shared + # between companies, identical partners may exist in a company we don't have access to. + ir_rules_query = self.env['res.partner']._where_calc([]) + self.env['res.partner']._apply_ir_rules(ir_rules_query, 'read') + from_clause, where_clause, where_clause_params = ir_rules_query.get_sql() + where_p3 = (" AND %s" % where_clause).replace('res_partner', 'p3') if where_clause else '' + if where_p3: + query += where_p3 + params += where_clause_params + self._cr.execute(query, params) result = {} diff --git a/addons/account/static/src/js/reconciliation/reconciliation_renderer.js b/addons/account/static/src/js/reconciliation/reconciliation_renderer.js index 7e432a0e0a5..33b4430ab2f 100644 --- a/addons/account/static/src/js/reconciliation/reconciliation_renderer.js +++ b/addons/account/static/src/js/reconciliation/reconciliation_renderer.js @@ -573,7 +573,10 @@ var LineRenderer = Widget.extend(FieldManagerMixin, { type: 'boolean', name: 'to_check', }], { - account_id: {string: _t("Account")}, + account_id: { + string: _t("Account"), + domain: [['deprecated', '=', false]], + }, label: {string: _t("Label")}, amount: {string: _t("Account")}, }).then(function (recordID) { diff --git a/addons/account/static/tests/reconciliation_tests.js b/addons/account/static/tests/reconciliation_tests.js index 87fbddd31eb..5e8d71b466d 100644 --- a/addons/account/static/tests/reconciliation_tests.js +++ b/addons/account/static/tests/reconciliation_tests.js @@ -54,6 +54,7 @@ var db = { code: {string: "code", type: 'integer'}, name: {string: "Displayed name", type: 'char'}, company_id: {string: "Company", type: 'many2one', relation: 'res.company'}, + deprecated: {string: "Deprecated", type: 'boolean'}, }, records: [ {id: 282, code: 100000, name: "100000 Fixed Asset Account", company_id: 1}, diff --git a/addons/account/views/report_invoice.xml b/addons/account/views/report_invoice.xml index 1c57b6892c9..043c5a3cc47 100644 --- a/addons/account/views/report_invoice.xml +++ b/addons/account/views/report_invoice.xml @@ -59,18 +59,19 @@ <span>Disc.(%)</span> </th> <th t-attf-class="text-left {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}"><span>Taxes</span></th> - <th class="text-right" groups="account.group_show_line_subtotals_tax_excluded">Amount</th> - <th class="text-right" groups="account.group_show_line_subtotals_tax_included">Total Price</th> + <th class="text-right"> + <span groups="account.group_show_line_subtotals_tax_excluded">Amount</span> + <span groups="account.group_show_line_subtotals_tax_included">Total Price</span> + </th> </tr> </thead> <tbody class="invoice_tbody"> - <t t-set="current_subtotal_tax_excluded" t-value="0"/> - <t t-set="current_subtotal_tax_included" t-value="0"/> + <t t-set="current_subtotal" t-value="0"/> <t t-foreach="o.invoice_line_ids" t-as="line"> - <t t-set="current_subtotal_tax_excluded" t-value="current_subtotal_tax_excluded + line.price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/> - <t t-set="current_subtotal_tax_included" t-value="current_subtotal_tax_included + line.price_total" groups="account.group_show_line_subtotals_tax_included"/> + <t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/> + <t t-set="current_subtotal" t-value="current_subtotal + line.price_total" groups="account.group_show_line_subtotals_tax_included"/> <tr t-att-class="'bg-200 font-weight-bold o_line_section' if line.display_type == 'line_section' else 'font-italic o_line_note' if line.display_type == 'line_note' else ''"> <t t-if="not line.display_type" name="account_invoice_line_accountable"> @@ -89,11 +90,9 @@ <td t-attf-class="text-left {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}"> <span t-esc="', '.join(map(lambda x: (x.description or x.name), line.invoice_line_tax_ids))"/> </td> - <td class="text-right o_price_total" groups="account.group_show_line_subtotals_tax_excluded"> - <span t-field="line.price_subtotal"/> - </td> - <td class="text-right o_price_total" groups="account.group_show_line_subtotals_tax_included"> - <span t-field="line.price_total"/> + <td class="text-right o_price_total"> + <span t-field="line.price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/> + <span t-field="line.price_total" groups="account.group_show_line_subtotals_tax_included"/> </td> </t> <t t-if="line.display_type == 'line_section'"> @@ -101,8 +100,7 @@ <span t-field="line.name"/> </td> <t t-set="current_section" t-value="line"/> - <t t-set="current_subtotal_tax_excluded" t-value="0"/> - <t t-set="current_subtotal_tax_included" t-value="0"/> + <t t-set="current_subtotal" t-value="0"/> </t> <t t-if="line.display_type == 'line_note'"> <td colspan="99"> @@ -116,14 +114,9 @@ <td colspan="99"> <strong class="mr16">Subtotal</strong> <span - groups="account.group_show_line_subtotals_tax_excluded" - t-esc="current_subtotal_tax_excluded" + t-esc="current_subtotal" t-options='{"widget": "monetary", "display_currency": o.currency_id}' /> - <span groups="account.group_show_line_subtotals_tax_included"> | <span - t-esc="current_subtotal_tax_included" - t-options='{"widget": "monetary", "display_currency": o.currency_id}' - /></span> </td> </tr> </t> diff --git a/addons/account/views/report_payment_receipt_templates.xml b/addons/account/views/report_payment_receipt_templates.xml index 626cff36fe2..871ae39479f 100644 --- a/addons/account/views/report_payment_receipt_templates.xml +++ b/addons/account/views/report_payment_receipt_templates.xml @@ -42,7 +42,7 @@ </tr> </thead> <tbody> - <tr t-foreach="o.invoice_ids" t-as="inv"> + <tr t-foreach="o.reconciled_invoice_ids" t-as="inv"> <td><span t-field="inv.date_invoice"/></td> <td><span t-field="inv.number"/></td> <td class="text-right"><span t-field="inv.amount_total"/></td> |
