diff --git a/account_invoice_update_wizard/models/account_move.py b/account_invoice_update_wizard/models/account_move.py index 47b5d8c..7811599 100644 --- a/account_invoice_update_wizard/models/account_move.py +++ b/account_invoice_update_wizard/models/account_move.py @@ -11,9 +11,8 @@ class AccountMove(models.Model): self.ensure_one() wizard = self.env['account.move.update'] res = wizard._prepare_default_get(self) - action = self.env.ref( - 'account_invoice_update_wizard.account_invoice_update_action' - ).read()[0] + action = self.env["ir.actions.actions"]._for_xml_id( + 'account_invoice_update_wizard.account_invoice_update_action') action['name'] = "Update Wizard" action['res_id'] = wizard.create(res).id return action diff --git a/account_invoice_update_wizard/wizard/account_move_update.py b/account_invoice_update_wizard/wizard/account_move_update.py index cae7176..c454f07 100644 --- a/account_invoice_update_wizard/wizard/account_move_update.py +++ b/account_invoice_update_wizard/wizard/account_move_update.py @@ -14,16 +14,13 @@ class AccountMoveUpdate(models.TransientModel): invoice_id = fields.Many2one( 'account.move', string='Invoice', required=True, readonly=True) - type = fields.Selection(related='invoice_id.move_type', readonly=True) - company_id = fields.Many2one( - related='invoice_id.company_id', readonly=True) - partner_id = fields.Many2one( - related='invoice_id.partner_id', readonly=True) + move_type = fields.Selection(related='invoice_id.move_type') + company_id = fields.Many2one(related='invoice_id.company_id') + partner_id = fields.Many2one(related='invoice_id.partner_id') user_id = fields.Many2one('res.users', string='Salesperson') invoice_payment_term_id = fields.Many2one( 'account.payment.term', string='Payment Term') - ref = fields.Char(string='Invoice Reference') - name = fields.Char(string='Reference/Description') + ref = fields.Char(string='Reference') # field label is customized in the view invoice_origin = fields.Char(string='Source Document') partner_bank_id = fields.Many2one( 'res.partner.bank', string='Bank Account') @@ -33,7 +30,7 @@ class AccountMoveUpdate(models.TransientModel): @api.model def _simple_fields2update(self): '''List boolean, date, datetime, char, text fields''' - return ['ref', 'name', 'invoice_origin'] + return ['ref', 'invoice_origin'] @api.model def _m2o_fields2update(self): @@ -55,15 +52,16 @@ class AccountMoveUpdate(models.TransientModel): 'quantity': line.quantity, 'price_subtotal': line.price_subtotal, 'analytic_account_id': line.analytic_account_id.id, + 'currency_id': line.currency_id.id, 'analytic_tag_ids': aa_tags, 'display_type': line.display_type, }]) return res - @api.onchange('type') - def type_on_change(self): + @api.onchange('move_type') + def move_type_on_change(self): res = {'domain': {}} - if self.type in ('out_invoice', 'out_refund'): + if self.move_type in ('out_invoice', 'out_refund'): res['domain']['partner_bank_id'] =\ "[('partner_id.ref_company_ids', 'in', [company_id])]" else: @@ -243,11 +241,11 @@ class AccountMoveLineUpdate(models.TransientModel): ('line_section', "Section"), ('line_note', "Note")], default=False, help="Technical field for UX purpose.") quantity = fields.Float( - string='Quantity', digits=dp.get_precision('Product Unit of Measure'), - readonly=True) - price_subtotal = fields.Float( - string='Amount', readonly=True, digits=dp.get_precision('Account')) + string='Quantity', digits='Product Unit of Measure', readonly=True) + price_subtotal = fields.Monetary( + string='Amount', readonly=True) analytic_account_id = fields.Many2one( 'account.analytic.account', string='Analytic Account') analytic_tag_ids = fields.Many2many( 'account.analytic.tag', string='Analytic Tags') + currency_id = fields.Many2one('res.currency', readonly=True) diff --git a/account_invoice_update_wizard/wizard/account_move_update_view.xml b/account_invoice_update_wizard/wizard/account_move_update_view.xml index 31ca6e9..c817089 100644 --- a/account_invoice_update_wizard/wizard/account_move_update_view.xml +++ b/account_invoice_update_wizard/wizard/account_move_update_view.xml @@ -12,26 +12,27 @@
- + - + + - - + + - + diff --git a/account_invoice_update_wizard_payment_mode/README.rst b/account_invoice_update_wizard_payment_mode/README.rst new file mode 100644 index 0000000..c835502 --- /dev/null +++ b/account_invoice_update_wizard_payment_mode/README.rst @@ -0,0 +1,39 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +Account Invoice Update Wizard +============================= + +This module adds a button *Update Invoice* on Customer and Supplier invoices in +Open or Paid state. This button starts a wizard which allows the user to update +non-legal fields of the invoice: + +* Source Document +* Reference/Description +* Payment terms (update allowed only to a payment term with same number of terms + of the same amount and on invoices without any payment) +* Bank Account +* Salesman +* Notes +* Description of invoice lines +* Analytic account +* Analytic tags + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smash it by providing detailed and welcomed feedback. + +Contributors +------------ + +* Alexis de Lattre +* Florian da Costa +* Matthieu Dietrich +* Yannick Vaucher +* Mykhailo Panarin +* Artem Kostyuk diff --git a/account_invoice_update_wizard_payment_mode/__init__.py b/account_invoice_update_wizard_payment_mode/__init__.py new file mode 100644 index 0000000..4027237 --- /dev/null +++ b/account_invoice_update_wizard_payment_mode/__init__.py @@ -0,0 +1 @@ +from . import wizard diff --git a/account_invoice_update_wizard_payment_mode/__manifest__.py b/account_invoice_update_wizard_payment_mode/__manifest__.py new file mode 100644 index 0000000..32a7de0 --- /dev/null +++ b/account_invoice_update_wizard_payment_mode/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2022 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + 'name': 'Account Invoice Update Wizard Payment Mode', + 'version': '14.0.1.0.0', + 'category': 'Accounting & Finance', + 'license': 'AGPL-3', + 'summary': 'Add Payment Mode to Invoice Update Wizard', + 'author': 'Akretion', + 'website': 'https://github.com/akretion/odoo-usability', + 'depends': ['account_invoice_update_wizard', 'account_payment_partner'], + 'data': ['wizard/account_move_update_view.xml'], + 'installable': True, + 'auto_install': True, +} diff --git a/account_invoice_update_wizard_payment_mode/views/account_move.xml b/account_invoice_update_wizard_payment_mode/views/account_move.xml new file mode 100644 index 0000000..b142b8b --- /dev/null +++ b/account_invoice_update_wizard_payment_mode/views/account_move.xml @@ -0,0 +1,19 @@ + + + + + + + account.move + + + + + + + diff --git a/account_invoice_update_wizard_payment_mode/wizard/__init__.py b/account_invoice_update_wizard_payment_mode/wizard/__init__.py new file mode 100644 index 0000000..ecfa4a4 --- /dev/null +++ b/account_invoice_update_wizard_payment_mode/wizard/__init__.py @@ -0,0 +1 @@ +from . import account_move_update diff --git a/account_invoice_update_wizard_payment_mode/wizard/account_move_update.py b/account_invoice_update_wizard_payment_mode/wizard/account_move_update.py new file mode 100644 index 0000000..23d8511 --- /dev/null +++ b/account_invoice_update_wizard_payment_mode/wizard/account_move_update.py @@ -0,0 +1,24 @@ +# Copyright 2022 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + + +from odoo import models, fields, api, _ + + +class AccountMoveUpdate(models.TransientModel): + _inherit = 'account.move.update' + + payment_mode_filter_type_domain = fields.Char( + related='invoice_id.payment_mode_filter_type_domain') + partner_bank_filter_type_domain = fields.Many2one( + related='invoice_id.partner_bank_filter_type_domain') + bank_account_required = fields.Boolean( + related='invoice_id.bank_account_required') + payment_mode_id = fields.Many2one("account.payment.mode") + + @api.model + def _m2o_fields2update(self): + m2o_list = super()._m2o_fields2update() + m2o_list.append('payment_mode_id') + return m2o_list diff --git a/account_invoice_update_wizard_payment_mode/wizard/account_move_update_view.xml b/account_invoice_update_wizard_payment_mode/wizard/account_move_update_view.xml new file mode 100644 index 0000000..ca6a55d --- /dev/null +++ b/account_invoice_update_wizard_payment_mode/wizard/account_move_update_view.xml @@ -0,0 +1,32 @@ + + + + + + + + account.move.update + + + + + + + + + + + [('partner_id', '=', partner_bank_filter_type_domain), + '|',('company_id', '=', company_id),('company_id', '=', False)] + + {'required': [('bank_account_required', '=', True),('move_type', 'in', ('in_invoice', 'in_refund'))]} + + + + + +