diff --git a/account_credit_hold/__manifest__.py b/account_credit_hold/__manifest__.py index 564b9bd..0212a4d 100644 --- a/account_credit_hold/__manifest__.py +++ b/account_credit_hold/__manifest__.py @@ -1,6 +1,6 @@ { 'name': 'Account Credit Hold', - 'version': '15.0.2.0.0.1', + 'version': '16.0.1.0.0', 'summary': 'Allows setting clients on credit hold, blocking the ability confirm a new sales order.', 'description': 'Allows setting clients on hold, blocking the ability confirm a new sales order.', 'category': 'Accounting/Accounting', @@ -15,15 +15,6 @@ 'views/res_partner_views.xml', 'views/stock_picking_views.xml', ], - 'assets': { - 'web.assets_backend': [ - 'account_credit_hold/static/src/js/followup_form_model.js', - 'account_credit_hold/static/src/js/followup_form_controller.js', - ], - 'web.assets_qweb': [ - 'account_credit_hold/static/src/xml/account_followup_template.xml', - ], - }, 'demo': [], 'installable': True, 'auto_install': False diff --git a/account_credit_hold/models/account_followup_report.py b/account_credit_hold/models/account_followup_report.py index 9c9b852..a28efdc 100644 --- a/account_credit_hold/models/account_followup_report.py +++ b/account_credit_hold/models/account_followup_report.py @@ -1,14 +1,12 @@ from odoo import models, fields, api, _ + class FollowUpReport(models.AbstractModel): _inherit = 'account.followup.report' def _get_line_info(self, followup_line): res = super()._get_line_info(followup_line) - res.update({'credit_hold': followup_line.account_hold}) + res.update({ + 'credit_hold': followup_line.account_hold + }) return res - @api.model - def credit_hold(self, options): - partner_id = options['partner_id'] - partner = self.env['res.partner'].browse(partner_id) - partner.action_credit_hold() diff --git a/account_credit_hold/models/res_partner.py b/account_credit_hold/models/res_partner.py index f7fbded..3cc765d 100644 --- a/account_credit_hold/models/res_partner.py +++ b/account_credit_hold/models/res_partner.py @@ -25,6 +25,8 @@ class Partner(models.Model): if rec.hold_bg and not (rec.postpone_hold_until and rec.postpone_hold_until > date.today()): rec.on_hold = True else: + if rec.on_hold: + rec.message_post(_("Credit hold lifted.")) rec.on_hold = False @api.autovacuum @@ -33,10 +35,14 @@ class Partner(models.Model): expired_holds.write({'postpone_hold_until': False}) def action_credit_hold(self): - message = _('Placed on credit hold') for rec in self: rec.hold_bg = True - rec.message_post() + rec.message_post(body=_('Placed on credit hold.')) + + def action_lift_credit_hold(self): + for rec in self: + rec.hold_bg = False + rec.message_post(body=_('Credit hold lifted.')) def _execute_followup_partner(self): res = super()._execute_followup_partner() @@ -45,11 +51,9 @@ class Partner(models.Model): self.action_credit_hold() return res - # BV: FOR MIGRATION - #@api.depends('followup_status', 'followup_level') + @api.depends('followup_status', 'followup_line_id') def _compute_hold_bg(self): - first_followup_level = self.env['account_followup.followup.line'].search( - [('company_id', '=', self.env.company.id)], order="delay asc", limit=1) + first_followup_level = self._get_first_followup_level() for rec in self: prev_hold_bg = rec.hold_bg level = rec.followup_line_id diff --git a/account_credit_hold/static/src/js/followup_form_controller.js b/account_credit_hold/static/src/js/followup_form_controller.js deleted file mode 100644 index 39b26d0..0000000 --- a/account_credit_hold/static/src/js/followup_form_controller.js +++ /dev/null @@ -1,48 +0,0 @@ -/** @odoo-module **/ - -var FollowupFormController = require('account_followup.FollowupFormController'); -import { patch } from '@web/core/utils/patch'; - -var PatchedController = patch(FollowupFormController.prototype, "followup_form_controller", { - events: _.extend({}, FollowupFormController.prototype.events, { - 'click .o_account_followup_credit_hold_button': '_onCreditHold', - }), - updateButtons() { - this._super(...arguments); - let setButtonClass = (button, primary) => { - /* Set class 'btn-primary' if parameter `primary` is true - * 'btn-secondary' otherwise - */ - let addedClass = primary ? 'btn-primary' : 'btn-secondary' - let removedClass = !primary ? 'btn-secondary' : 'btn-primary' - this.$buttons.find(`button.${button}`) - .removeClass(removedClass).addClass(addedClass); - } - if (!this.$buttons) { - return; - } - let followupLevel = this.model.localData[this.handle].data.followup_level; - setButtonClass('o_account_followup_credit_hold_button', followupLevel.credit_hold); - }, - _onCreditHold: function() { - var self = this; - this.model.doCreditHold(this.handle); - this.options = { - partner_id: this._getPartner() - }; - this._rpc({ - model: 'account.followup.report', - method: 'credit_hold', - args: [this.options], - }).then(function (result) { - self._removeHighlightCreditHold(); - self._displayDone(); - }); - }, - _removeHighlightCreditHold: function() { - this.$buttons.find('button.o_account_followup_credit_hold_button') - .removeClass('btn-primary').addClass('btn-secondary'); - }, -}); - -export { PatchedController }; \ No newline at end of file diff --git a/account_credit_hold/static/src/js/followup_form_model.js b/account_credit_hold/static/src/js/followup_form_model.js deleted file mode 100644 index bd84e76..0000000 --- a/account_credit_hold/static/src/js/followup_form_model.js +++ /dev/null @@ -1,14 +0,0 @@ -/** @odoo-module **/ - -var FollowupFormModel = require('account_followup.FollowupFormModel'); -import { patch } from '@web/core/utils/patch'; - -var PatchedModel = patch(FollowupFormModel.prototype, 'followup_form_model', { - doCreditHold: function(handle) { - var level = this.localData[handle].data.followup_level; - if(level && level.credit_hold) { - level.credit_hold = false; - } - }, -}); -export { PatchedModel }; \ No newline at end of file diff --git a/account_credit_hold/static/src/xml/account_followup_template.xml b/account_credit_hold/static/src/xml/account_followup_template.xml deleted file mode 100644 index 50f74ee..0000000 --- a/account_credit_hold/static/src/xml/account_followup_template.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/account_credit_hold/views/account_followup_views.xml b/account_credit_hold/views/account_followup_views.xml index 61caad9..10a7165 100644 --- a/account_credit_hold/views/account_followup_views.xml +++ b/account_credit_hold/views/account_followup_views.xml @@ -8,9 +8,45 @@ - + + + + customer.statements.form.view.inherit + res.partner + + + + +