Skip to content

Commit

Permalink
Merge PR #644 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Sep 17, 2024
2 parents ba321fe + 1c76dde commit d5016fb
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions account_invoice_inter_company/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ def write(self, vals):
if self.env.context.get("skip_check_amount_difference"):
return res
for move in self.filtered("auto_invoice_id"):
if not move.company_id.intercompany_invoice_lock:
continue
if (
float_compare(
move.amount_total,
Expand Down
4 changes: 4 additions & 0 deletions account_invoice_inter_company/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class ResCompany(models.Model):
"for this company, it will automatically validate it",
default=True,
)
intercompany_invoice_lock = fields.Boolean(
help="Don't allow changing an autogenerated invoice.",
default=True,
)
intercompany_invoice_user_id = fields.Many2one(
"res.users",
string="Inter Company Invoice User",
Expand Down
6 changes: 6 additions & 0 deletions account_invoice_inter_company/models/res_config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ class ResConfigSettings(models.TransientModel):
help="When an invoice is created by a multi company rule for "
"this company, it will automatically validate it.",
)
intercompany_invoice_lock = fields.Boolean(
related="company_id.intercompany_invoice_lock",
string="Lock auto-generated invoices",
readonly=False,
help="Don't allow changing an autogenerated invoice.",
)
intercompany_invoice_user_id = fields.Many2one(
related="company_id.intercompany_invoice_user_id",
readonly=False,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,12 @@ def test03_confirm_invoice_and_cancel(self):
with move_form.invoice_line_ids.edit(0) as line_form:
line_form.price_unit = 33.3
move_form.save()
# Check that we can modify it after we disable the setting
dest_invoice.company_id.intercompany_invoice_lock = False
move_form = Form(dest_invoice)
with move_form.invoice_line_ids.edit(0) as line_form:
line_form.price_unit = 33.3
move_form.save()

def test_confirm_invoice_with_child_partner(self):
# ensure the catalog is shared
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@
for="invoice_auto_validation"
/>
</div>
<div id="inter_company_invoice_lock">
<field name="intercompany_invoice_lock" class="oe_inline" />
<label
string="Lock invoice amounts"
class="o_light_label"
for="intercompany_invoice_lock"
/>
</div>
</div>
</div>
</xpath>
Expand Down

0 comments on commit d5016fb

Please sign in to comment.