Skip to content

Commit

Permalink
[16.0][MIG] account_credit_control (code review)
Browse files Browse the repository at this point in the history
  • Loading branch information
astirpe committed Mar 30, 2023
1 parent a73bd19 commit 0d1e8c4
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 113 deletions.
2 changes: 0 additions & 2 deletions account_credit_control/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
# Security
"security/account_security.xml",
"security/ir.model.access.csv",
"security/acl_account_credit_control_analysis.xml",
"security/acl_res_partner_payment_action_type.xml",
# Views
"views/account_move.xml",
"views/credit_control_line.xml",
Expand Down
35 changes: 17 additions & 18 deletions account_credit_control/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,24 @@ def button_cancel(self):
"""Prevent to cancel invoice related to credit line"""
# We will search if this invoice is linked with credit
cc_line_obj = self.env["credit.control.line"]
for invoice in self:
nondraft_domain = [
("invoice_id", "=", invoice.id),
("state", "!=", "draft"),
]
nondraft_domain = [
("invoice_id", "in", self.ids),
("state", "!=", "draft"),
]

cc_nondraft_lines = cc_line_obj.search(nondraft_domain)
cc_nondraft_lines = cc_line_obj.search(nondraft_domain, limit=1)

if cc_nondraft_lines:
raise UserError(
_(
"You cannot cancel this invoice.\n"
"A payment reminder has already been "
"sent to the customer.\n"
"You must create a credit note and "
"issue a new invoice."
)
if cc_nondraft_lines:
raise UserError(
_(
"You cannot cancel this invoice.\n"
"A payment reminder has already been "
"sent to the customer.\n"
"You must create a credit note and "
"issue a new invoice."
)
draft_domain = [("invoice_id", "=", invoice.id), ("state", "=", "draft")]
cc_draft_line = cc_line_obj.search(draft_domain)
cc_draft_line.unlink()
)
draft_domain = [("invoice_id", "in", self.ids), ("state", "=", "draft")]
cc_draft_line = cc_line_obj.search(draft_domain)
cc_draft_line.unlink()
return super().button_cancel()
2 changes: 1 addition & 1 deletion account_credit_control/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ You can define as many policy levels as you need. You must set on which
accounts are applied every Credit Control Policy under Accounts tab.

Configure a tolerance for the Credit control and a default policy
applied on all partners in each company, under the Accounting tab in your
applied on all partners in each company, under the General Information tab in your
company form.

You are able to specify a particular policy for one partner or one invoice.
16 changes: 8 additions & 8 deletions account_credit_control/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
Menu entries are located in *Invoicing > Adviser > Credit Control*.
Menu entries are located in *Invoicing > Credit Control*.

Create a new "run" in the *Credit Control Run* menu with the controlling date.
Then, use the *Compute Credit Lines* button. All the credit control lines will
be generated. You can find them in the *Credit Control Lines* menu.

On each generated line, you have many choices:

* Send a email
* Print a letter
* Change the state (so you can ignore or reopen lines)
* Mark a line as Manually Overridden. The line will get the ignored state when
a second credit control run is done.
* Mark one line as Manual followup will also mark all the lines of the
partner. The partner will be visible in "Do Manual Follow-ups".
* Send a email
* Print a letter
* Change the state (so you can ignore or reopen lines)
* Mark a line as Manually Overridden. The line will get the ignored state when
a second credit control run is done.
* Mark one line as Manual followup will also mark all the lines of the
partner. The partner will be visible in "Do Manual Follow-ups".

Once your lines are properly set up, go back to the "run" and click on
*Run channel action* to massively generate and queue communication emails or
Expand Down

This file was deleted.

This file was deleted.

3 changes: 3 additions & 0 deletions account_credit_control/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ access_credit_control_printer_credit_control_user,credit_control_printer_credit_
access_credit_control_printer_credit_control_manager,credit_control_printer_credit_control_manager,model_credit_control_printer,group_account_credit_control_manager,1,1,1,0
access_credit_control_policy_changer_credit_control_user,credit_control_policy_changer_credit_control_user,model_credit_control_policy_changer,group_account_credit_control_user,1,1,1,0
access_credit_control_policy_changer_credit_control_manager,credit_control_policy_changer_credit_control_manager,model_credit_control_policy_changer,group_account_credit_control_manager,1,1,1,0
res_partner_payment_action_type_info_access,res.partner.payment.action.type info access,account_credit_control.model_res_partner_payment_action_type,account_credit_control.group_account_credit_control_info,1,0,0,0
res_partner_payment_action_type_manager_access,res.partner.payment.action.type manager access,account_credit_control.model_res_partner_payment_action_type,account_credit_control.group_account_credit_control_manager,1,1,1,1
credit_control_analysis_info_access,credit.control.analysis access,account_credit_control.model_credit_control_analysis,account_credit_control.group_account_credit_control_info,1,0,0,0
33 changes: 24 additions & 9 deletions account_credit_control/views/credit_control_communication.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
<group>
<field name="partner_id" />
<field name="contact_address_id" />
<field name="company_id" />
<field
name="company_id"
groups="base.group_multi_company"
/>
<field name="user_id" />
</group>
<group>
Expand All @@ -23,14 +26,25 @@
</group>
<group>
<group>
<field name="total_invoiced" />
<field name="total_due" />
<field name="currency_id" />
<field name="total_invoiced" widget="monetary" />
<field name="total_due" widget="monetary" />
<field
name="currency_id"
groups="base.group_multi_currency"
/>
</group>
</group>
<group string="Lines">
<field name="credit_control_line_ids" colspan="4" nolabel="1" />
</group>
<field name="credit_control_line_ids" nolabel="1">
<tree>
<field name="date" />
<field name="level" />
<field name="state" />
<field name="channel" />
<field name="balance_due" />
<field name="policy_level_id" />
<field name="policy_id" />
</tree>
</field>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" />
Expand All @@ -48,7 +62,7 @@
<group>
<field name="partner_id" />
<field name="user_id" />
<field name="company_id" />
<field name="company_id" groups="base.group_multi_company" />
<separator />
<field name="policy_level_id" />
<field name="policy_id" />
Expand All @@ -75,6 +89,7 @@
context="{'group_by': 'company_id'}"
icon="terp-company"
string="Company"
groups="base.group_multi_company"
/>
<filter
name="group_by_policy"
Expand Down Expand Up @@ -106,7 +121,7 @@
<tree>
<field name="partner_id" />
<field name="user_id" />
<field name="company_id" />
<field name="company_id" groups="base.group_multi_company" />
<field name="policy_level_id" />
<field name="policy_id" />
<field name="report_date" />
Expand Down
23 changes: 15 additions & 8 deletions account_credit_control/views/credit_control_line.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@
<field name="account_id" />
</group>
<group>
<field name="amount_due" />
<field name="balance_due" />
<field name="currency_id" />
<field name="amount_due" widget="monetary" />
<field name="balance_due" widget="monetary" />
<field
name="currency_id"
groups="base.group_multi_currency"
/>
</group>
</group>
</sheet>
Expand Down Expand Up @@ -225,11 +228,15 @@
<field name="invoice_id" />
<field name="partner_id" />
<field name="manual_followup" />
<field name="amount_due" />
<field name="balance_due" />
<field name="currency_id" />
<field name="move_line_id" />
<field name="account_id" />
<field name="amount_due" widget="monetary" optional="hide" />
<field name="balance_due" widget="monetary" />
<field
name="currency_id"
groups="base.group_multi_currency"
optional="hide"
/>
<field name="move_line_id" optional="hide" />
<field name="account_id" optional="hide" />
<field name="policy_level_id" />
<field name="policy_id" />
<field name="activity_date_deadline" />
Expand Down
3 changes: 1 addition & 2 deletions account_credit_control/views/credit_control_policy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
/>
</div>
<group>
<field name="active" invisible="1" />
<field name="name" />
<field name="do_nothing" />
<field name="company_id" />
<field name="company_id" groups="base.group_multi_company" />
<field name="active" />
</group>
<notebook colspan="4">
Expand Down
31 changes: 15 additions & 16 deletions account_credit_control/views/res_partner.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,21 @@
groups="account.group_account_invoice,account.group_account_readonly,account_credit_control.group_account_credit_control_manager,account_credit_control.group_account_credit_control_user"
>
<group name="followup">

<field
name="credit_policy_id"
options="{'no_create_edit': True, 'no_create': True, 'no_open': True}"
context="{'account_receivable_partner_id': id}"
/>
<field name="payment_responsible_id" />
<field name="payment_note" />
<field name="payment_next_action_type" />
<field name="payment_next_action" />
<field name="payment_next_action_date" />
<field
name="credit_control_analysis_ids"
nolabel="1"
colspan="2"
>
<group>
<field
name="credit_policy_id"
options="{'no_create_edit': True, 'no_create': True, 'no_open': True}"
context="{'account_receivable_partner_id': id}"
/>
<field name="payment_responsible_id" />
<field name="payment_note" widget="text" />
</group>
<group>
<field name="payment_next_action_type" />
<field name="payment_next_action" widget="text" />
<field name="payment_next_action_date" />
</group>
<field name="credit_control_analysis_ids" nolabel="1">
<tree editable="bottom">
<field name="policy_id" />
<field name="policy_level_id" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@
<field name="help">Allows to manually change credit level</field>
</record>
<!-- for menu -->

<record
<record
id="action_wizard_credit_policy_changer_menu_action"
model="ir.actions.act_window"
>
<field name="name">Change current credit policy</field>
<field name="res_model">credit.control.policy.changer</field>
<field name="binding_model_id" ref="account.model_account_move" />
<field name="binding_view_types">form</field>
<field name="target">new</field>
<field name="target">new</field>
<field name="view_mode">form</field>
</record>

</odoo>

0 comments on commit 0d1e8c4

Please sign in to comment.