Skip to content

Commit

Permalink
Merge pull request #2269 from OCA/16.0
Browse files Browse the repository at this point in the history
Syncing from upstream OCA/sale-workflow (16.0)
  • Loading branch information
bt-admin authored Feb 14, 2025
2 parents dc15394 + b69ea91 commit 44bb31b
Show file tree
Hide file tree
Showing 9 changed files with 792 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ addon | version | maintainers | summary
[product_form_sale_link](product_form_sale_link/) | 16.0.1.0.1 | | Adds a button on product forms to access Sale Lines
[product_price_category](product_price_category/) | 16.0.1.0.0 | [![sbejaoui](https://github.com/sbejaoui.png?size=30px)](https://github.com/sbejaoui) | Add Price Category field on product and allow to apply a pricelist on this field.
[product_supplierinfo_for_customer_sale](product_supplierinfo_for_customer_sale/) | 16.0.1.0.2 | | Loads in every sale order line the customer code defined in the product
[sale_advance_payment](sale_advance_payment/) | 16.0.1.0.0 | | Allow to add advance payments on sales and then use them on invoices
[sale_advance_payment](sale_advance_payment/) | 16.0.1.0.1 | | Allow to add advance payments on sales and then use them on invoices
[sale_attached_product](sale_attached_product/) | 16.0.1.0.0 | [![chienandalu](https://github.com/chienandalu.png?size=30px)](https://github.com/chienandalu) | Define products that will be added automatically when adding another in a sales order
[sale_auto_remove_zero_quantity_lines](sale_auto_remove_zero_quantity_lines/) | 16.0.1.1.0 | | On sale confirmation remove lines with zero quantities
[sale_automatic_workflow](sale_automatic_workflow/) | 16.0.1.1.1 | | Sale Automatic Workflow
Expand Down
2 changes: 1 addition & 1 deletion sale_advance_payment/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Sale Advance Payment
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:849e3e61f660f7220fd5efe0c014ac9fa61fcabc9dffaaa98e765f4e2b304a0d
!! source digest: sha256:076f5d94f3b60eeaa740d9068f2e53ffb84404734ef5131b521488a28c0cb48b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 1 addition & 1 deletion sale_advance_payment/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Sale Advance Payment",
"version": "16.0.1.0.0",
"version": "16.0.1.0.1",
"author": "Comunitea, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sale-workflow",
"category": "Sales",
Expand Down
17 changes: 11 additions & 6 deletions sale_advance_payment/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@
class AccountMove(models.Model):
_inherit = "account.move"

def action_post(self):
def _post(self, soft=True):
# Automatic reconciliation of payment when invoice confirmed.
res = super(AccountMove, self).action_post()
sale_order = self.mapped("line_ids.sale_line_ids.order_id")
if sale_order and self.invoice_outstanding_credits_debits_widget is not False:
res = super(AccountMove, self)._post(soft=soft)
for move in self:
sale_order = move.mapped("line_ids.sale_line_ids.order_id")
if (
not sale_order
or move.invoice_outstanding_credits_debits_widget is False
):
continue
json_invoice_outstanding_data = (
self.invoice_outstanding_credits_debits_widget.get("content", [])
move.invoice_outstanding_credits_debits_widget.get("content", [])
)
for data in json_invoice_outstanding_data:
if data.get("move_id") in sale_order.account_payment_ids.move_id.ids:
self.js_assign_outstanding_line(line_id=data.get("id"))
move.js_assign_outstanding_line(line_id=data.get("id"))
return res
14 changes: 8 additions & 6 deletions sale_advance_payment/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand All @@ -9,10 +8,11 @@

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Sale Advance Payment</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:849e3e61f660f7220fd5efe0c014ac9fa61fcabc9dffaaa98e765f4e2b304a0d
!! source digest: sha256:076f5d94f3b60eeaa740d9068f2e53ffb84404734ef5131b521488a28c0cb48b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/sale-workflow/tree/16.0/sale_advance_payment"><img alt="OCA/sale-workflow" src="https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_advance_payment"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/sale-workflow&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>The module allows to add advance payments on sales and then use them on invoices.</p>
Expand Down Expand Up @@ -430,7 +430,9 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
Expand Down
107 changes: 107 additions & 0 deletions sale_advance_payment/tests/test_sale_advance_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,3 +375,110 @@ def test_03_residual_amount_big_pre_payment(self):
self.assertEqual(invoice.amount_residual, 0.0)
self.assertEqual(self.sale_order_1.amount_residual, 1600)
self.assertEqual(invoice.amount_residual, 0)

def test_04_sale_advance_payment_multi_inv_validate_wiz(self):
self.assertEqual(
self.sale_order_1.amount_residual,
3600,
)
self.assertEqual(
self.sale_order_1.amount_residual,
self.sale_order_1.amount_total,
"Amounts should match",
)

context_payment = {
"active_ids": [self.sale_order_1.id],
"active_id": self.sale_order_1.id,
}

# Create Advance Payment 1 - EUR - bank
advance_payment_1 = (
self.env["account.voucher.wizard"]
.with_context(**context_payment)
.create(
{
"journal_id": self.journal_eur_bank.id,
"payment_type": "inbound",
"amount_advance": 100,
"order_id": self.sale_order_1.id,
}
)
)
advance_payment_1.make_advance_payment()

self.assertEqual(self.sale_order_1.amount_residual, 3480)

# Create Advance Payment 2 - USD - cash
advance_payment_2 = (
self.env["account.voucher.wizard"]
.with_context(**context_payment)
.create(
{
"journal_id": self.journal_usd_cash.id,
"payment_type": "inbound",
"amount_advance": 200,
"order_id": self.sale_order_1.id,
}
)
)
advance_payment_2.make_advance_payment()

self.assertEqual(self.sale_order_1.amount_residual, 3280)

# Confirm Sale Order
self.sale_order_1.action_confirm()

# Create Advance Payment 3 - EUR - cash
advance_payment_3 = (
self.env["account.voucher.wizard"]
.with_context(**context_payment)
.create(
{
"journal_id": self.journal_eur_cash.id,
"payment_type": "inbound",
"amount_advance": 250,
"order_id": self.sale_order_1.id,
}
)
)
advance_payment_3.make_advance_payment()
self.assertEqual(self.sale_order_1.amount_residual, 2980)

# Create Advance Payment 4 - USD - bank
advance_payment_4 = (
self.env["account.voucher.wizard"]
.with_context(**context_payment)
.create(
{
"journal_id": self.journal_usd_bank.id,
"payment_type": "inbound",
"amount_advance": 400,
"order_id": self.sale_order_1.id,
}
)
)
advance_payment_4.make_advance_payment()
self.assertEqual(self.sale_order_1.amount_residual, 2580)

# Confirm Sale Order
self.sale_order_1.action_confirm()

# Create Invoice
invoice = self.sale_order_1._create_invoices()
self.assertEqual(invoice.state, "draft")
validate_wiz = (
self.env["validate.account.move"]
.with_context(active_model="account.move", active_ids=invoice.ids)
.create({})
)
validate_wiz.validate_move()
self.assertEqual(invoice.state, "posted")
self.assertEqual(invoice.payment_state, "partial")

# Compare payments
rate = self.currency_rate.rate
payment_list = [100 * rate, 200, 250 * rate, 400]
payments = invoice.invoice_outstanding_credits_debits_widget
result = [d["amount"] for d in payments["content"]]
self.assertEqual(set(payment_list), set(result))
Loading

0 comments on commit 44bb31b

Please sign in to comment.