mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
Add a button on the "Run" to open the generated lines
This commit is contained in:
@@ -137,6 +137,9 @@ class CreditControlLine(models.Model):
|
||||
|
||||
manually_overridden = fields.Boolean(string='Manually overridden')
|
||||
|
||||
run_id = fields.Many2one(comodel_name='credit.control.run',
|
||||
string='Source')
|
||||
|
||||
@api.model
|
||||
def _prepare_from_move_line(self, move_line, level, controlling_date,
|
||||
open_amount):
|
||||
|
||||
@@ -56,6 +56,12 @@ class CreditControlRun(models.Model):
|
||||
required=True,
|
||||
readonly=True,
|
||||
default='draft')
|
||||
|
||||
line_ids = fields.One2many(
|
||||
comodel_name='credit.control.line',
|
||||
inverse_name='run_id',
|
||||
string='Generated lines')
|
||||
|
||||
manual_ids = fields.Many2many(
|
||||
'account.move.line',
|
||||
rel="credit_runreject_rel",
|
||||
@@ -134,7 +140,8 @@ class CreditControlRun(models.Model):
|
||||
|
||||
vals = {'state': 'done',
|
||||
'report': report,
|
||||
'manual_ids': [(6, 0, manually_managed_lines)]}
|
||||
'manual_ids': [(6, 0, manually_managed_lines.ids)],
|
||||
'line_ids': [(6, 0, generated.ids)]}
|
||||
self.write(vals)
|
||||
return generated
|
||||
|
||||
@@ -156,3 +163,13 @@ class CreditControlRun(models.Model):
|
||||
|
||||
self._generate_credit_lines()
|
||||
return True
|
||||
|
||||
@api.multi
|
||||
def open_credit_lines(self):
|
||||
""" Open the generated lines """
|
||||
self.ensure_one()
|
||||
action_name = 'account_credit_control.credit_control_line_action'
|
||||
action = self.env.ref(action_name)
|
||||
action = action.read()[0]
|
||||
action['domain'] = [('id', 'in', self.line_ids.ids)]
|
||||
return action
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
class="oe_highlight"
|
||||
type="object" icon="gtk-execute"
|
||||
attrs="{'invisible': [('state', '!=', 'draft')]}"/>
|
||||
<button name="open_credit_lines"
|
||||
string="Open Credit Control Lines"
|
||||
type="object"
|
||||
attrs="{'invisible': [('state', '=', 'draft')]}"/>
|
||||
<field name="state" widget="statusbar"
|
||||
statusbar_visible="draft,done"
|
||||
statusbar_colors='{}'/>
|
||||
|
||||
Reference in New Issue
Block a user