diff options
| author | wan <wan@odoo.com> | 2019-10-11 14:07:42 +0000 |
|---|---|---|
| committer | wan <wan@odoo.com> | 2019-11-15 14:05:30 +0000 |
| commit | 2106dd3cd10da44cd0b25897aaa5104f93aea703 (patch) | |
| tree | c4bae24cf8f1aebb4b63741527ce235d5bb0be20 /addons/l10n_latam_invoice_document | |
| parent | 3fe9402de40a57ec7dc90218ea50054ac390b5a6 (diff) | |
[IMP] account: clean entry/move reversal
Task 2085023
* Add a field that replaces the context to get the ids of the
entries/invoices
* Remove move_id, we can use move_ids instead
* Add text to explain invioces/bills will create refunds
closes odoo/odoo#38857
Related: odoo/enterprise#6263
Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
Diffstat (limited to 'addons/l10n_latam_invoice_document')
| -rw-r--r-- | addons/l10n_latam_invoice_document/wizards/account_move_reversal.py | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/addons/l10n_latam_invoice_document/wizards/account_move_reversal.py b/addons/l10n_latam_invoice_document/wizards/account_move_reversal.py index ae1da9561c2..e6356df2e7e 100644 --- a/addons/l10n_latam_invoice_document/wizards/account_move_reversal.py +++ b/addons/l10n_latam_invoice_document/wizards/account_move_reversal.py @@ -8,8 +8,7 @@ class AccountMoveReversal(models.TransientModel): _inherit = "account.move.reversal" - l10n_latam_use_documents = fields.Boolean( - related='move_id.journal_id.l10n_latam_use_documents', readonly=True) + l10n_latam_use_documents = fields.Boolean(readonly=True) l10n_latam_document_type_id = fields.Many2one('l10n_latam.document.type', 'Document Type', ondelete='cascade') l10n_latam_sequence_id = fields.Many2one('ir.sequence', compute='_compute_l10n_latam_sequence') l10n_latam_document_number = fields.Char(string='Document Number') @@ -22,6 +21,8 @@ class AccountMoveReversal(models.TransientModel): move_ids_use_document = move_ids.filtered(lambda move: move.l10n_latam_use_documents) if move_ids_use_document: raise UserError(_('You can only reverse documents with legal invoicing documents from Latin America one at a time.\nProblematic documents: %s') % ", ".join(move_ids_use_document.mapped('name'))) + else: + res['l10n_latam_use_documents'] = move_ids.journal_id.l10n_latam_use_documents return res @@ -36,14 +37,14 @@ class AccountMoveReversal(models.TransientModel): 'in_receipt': 'out_receipt'} return match.get(move_type) - @api.onchange('move_id') + @api.onchange('move_ids') def _onchange_move_id(self): - if self.move_id.l10n_latam_use_documents: - refund = self.move_id.new({ - 'type': self._reverse_type_map(self.move_id.type), - 'journal_id': self.move_id.journal_id.id, - 'partner_id': self.move_id.partner_id.id, - 'company_id': self.move_id.company_id.id, + if self.l10n_latam_use_documents: + refund = self.env['account.move'].new({ + 'type': self._reverse_type_map(self.move_ids.type), + 'journal_id': self.move_ids.journal_id.id, + 'partner_id': self.move_ids.partner_id.id, + 'company_id': self.move_ids.company_id.id, }) self.l10n_latam_document_type_id = refund.l10n_latam_document_type_id return {'domain': { @@ -57,14 +58,16 @@ class AccountMoveReversal(models.TransientModel): @api.depends('l10n_latam_document_type_id') def _compute_l10n_latam_sequence(self): for rec in self: - refund = rec.move_id.new({ - 'type': self._reverse_type_map(rec.move_id.type), - 'journal_id': rec.move_id.journal_id.id, - 'partner_id': rec.move_id.partner_id.id, - 'company_id': rec.move_id.company_id.id, - 'l10n_latam_document_type_id': rec.l10n_latam_document_type_id.id, - }) - rec.l10n_latam_sequence_id = refund._get_document_type_sequence() + rec.l10n_latam_sequence_id = False + if len(rec.move_ids) <= 1: + refund = rec.env['account.move'].new({ + 'type': self._reverse_type_map(rec.move_ids.type), + 'journal_id': rec.move_ids.journal_id.id, + 'partner_id': rec.move_ids.partner_id.id, + 'company_id': rec.move_ids.company_id.id, + 'l10n_latam_document_type_id': rec.l10n_latam_document_type_id.id, + }) + rec.l10n_latam_sequence_id = refund._get_document_type_sequence() @api.onchange('l10n_latam_document_number', 'l10n_latam_document_type_id') def _onchange_l10n_latam_document_number(self): |
