account_credit_hold migrated to 16.0
This commit is contained in:
parent
6ec7dfefa9
commit
be0af4dc17
7 changed files with 52 additions and 95 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
'name': 'Account Credit Hold',
|
'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.',
|
'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.',
|
'description': 'Allows setting clients on hold, blocking the ability confirm a new sales order.',
|
||||||
'category': 'Accounting/Accounting',
|
'category': 'Accounting/Accounting',
|
||||||
|
|
@ -15,15 +15,6 @@
|
||||||
'views/res_partner_views.xml',
|
'views/res_partner_views.xml',
|
||||||
'views/stock_picking_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': [],
|
'demo': [],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
'auto_install': False
|
'auto_install': False
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,12 @@
|
||||||
from odoo import models, fields, api, _
|
from odoo import models, fields, api, _
|
||||||
|
|
||||||
|
|
||||||
class FollowUpReport(models.AbstractModel):
|
class FollowUpReport(models.AbstractModel):
|
||||||
_inherit = 'account.followup.report'
|
_inherit = 'account.followup.report'
|
||||||
|
|
||||||
def _get_line_info(self, followup_line):
|
def _get_line_info(self, followup_line):
|
||||||
res = super()._get_line_info(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
|
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()
|
|
||||||
|
|
|
||||||
|
|
@ -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()):
|
if rec.hold_bg and not (rec.postpone_hold_until and rec.postpone_hold_until > date.today()):
|
||||||
rec.on_hold = True
|
rec.on_hold = True
|
||||||
else:
|
else:
|
||||||
|
if rec.on_hold:
|
||||||
|
rec.message_post(_("Credit hold lifted."))
|
||||||
rec.on_hold = False
|
rec.on_hold = False
|
||||||
|
|
||||||
@api.autovacuum
|
@api.autovacuum
|
||||||
|
|
@ -33,10 +35,14 @@ class Partner(models.Model):
|
||||||
expired_holds.write({'postpone_hold_until': False})
|
expired_holds.write({'postpone_hold_until': False})
|
||||||
|
|
||||||
def action_credit_hold(self):
|
def action_credit_hold(self):
|
||||||
message = _('Placed on credit hold')
|
|
||||||
for rec in self:
|
for rec in self:
|
||||||
rec.hold_bg = True
|
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):
|
def _execute_followup_partner(self):
|
||||||
res = super()._execute_followup_partner()
|
res = super()._execute_followup_partner()
|
||||||
|
|
@ -45,11 +51,9 @@ class Partner(models.Model):
|
||||||
self.action_credit_hold()
|
self.action_credit_hold()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
# BV: FOR MIGRATION
|
@api.depends('followup_status', 'followup_line_id')
|
||||||
#@api.depends('followup_status', 'followup_level')
|
|
||||||
def _compute_hold_bg(self):
|
def _compute_hold_bg(self):
|
||||||
first_followup_level = self.env['account_followup.followup.line'].search(
|
first_followup_level = self._get_first_followup_level()
|
||||||
[('company_id', '=', self.env.company.id)], order="delay asc", limit=1)
|
|
||||||
for rec in self:
|
for rec in self:
|
||||||
prev_hold_bg = rec.hold_bg
|
prev_hold_bg = rec.hold_bg
|
||||||
level = rec.followup_line_id
|
level = rec.followup_line_id
|
||||||
|
|
|
||||||
|
|
@ -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 };
|
|
||||||
|
|
@ -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 };
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<templates>
|
|
||||||
<t t-inherit="account_followup.CustomerStatements.buttons" t-inherit-mode="extension">
|
|
||||||
<xpath expr="//button[hasclass('o_account_followup_print_letter_button')]" position="before">
|
|
||||||
<button type="button" class="btn btn-primary o_account_followup_credit_hold_button">
|
|
||||||
Credit Hold
|
|
||||||
</button>
|
|
||||||
</xpath>
|
|
||||||
</t>
|
|
||||||
</templates>
|
|
||||||
|
|
@ -8,9 +8,45 @@
|
||||||
<field name="inherit_id" ref="account_followup.view_account_followup_followup_line_form"/>
|
<field name="inherit_id" ref="account_followup.view_account_followup_followup_line_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//field[@name='send_email']" position="before">
|
<xpath expr="//field[@name='send_email']" position="before">
|
||||||
<field name="account_hold" />
|
<field name="account_hold"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="customer_statements_form_view_inherit" model="ir.ui.view">
|
||||||
|
<field name="name">customer.statements.form.view.inherit</field>
|
||||||
|
<field name="model">res.partner</field>
|
||||||
|
<field name="inherit_id" ref="account_followup.customer_statements_form_view"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//button[last()]" position="after">
|
||||||
|
<field name="hold_bg" invisible="1"/>
|
||||||
|
<button
|
||||||
|
string="Credit Hold"
|
||||||
|
type="object"
|
||||||
|
name="action_credit_hold"
|
||||||
|
class="button btn-secondary"
|
||||||
|
attrs="{'invisible': [('hold_bg', '=', True)]}"
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
string="Lift Credit Hold"
|
||||||
|
type="object"
|
||||||
|
name="action_lift_credit_hold"
|
||||||
|
class="button btn-secondary"
|
||||||
|
attrs="{'invisible': [('hold_bg', '=', False)]}"
|
||||||
|
/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="action_credit_hold" model="ir.actions.server">
|
||||||
|
<field name="name">action_credit_hold</field>
|
||||||
|
<field name="model_id" ref="base.model_res_partner"/>
|
||||||
|
<field name="binding_model_id" ref="base.model_res_partner"/>
|
||||||
|
<field name="binding_view_types">list,form</field>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">
|
||||||
|
records.action_credit_hold()
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
Loading…
Reference in a new issue