Rename module sale_advance_payment_management to sale_down_payment

Add field amount_down_payment on sale.order
This commit is contained in:
Alexis de Lattre
2019-11-14 23:02:42 +01:00
parent 83fec9264f
commit 035a3dfd1e
12 changed files with 50 additions and 17 deletions

View File

@@ -1,14 +0,0 @@
# Copyright 2019 Akretion France (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class SaleOrder(models.Model):
_inherit = 'sale.order'
payment_line_ids = fields.One2many(
'account.move.line', 'sale_id', string='Advance Payments',
readonly=True)
# residual

View File

@@ -3,17 +3,19 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Sale Advance Payment Management',
'name': 'Sale Down Payment',
'version': '12.0.1.0.0',
'category': 'Sales',
'license': 'AGPL-3',
'summary': 'Link payment to sale orders',
'description': """
Sale Advance Payment Management
===============================
Sale Down Payment
=================
This module adds a link between payment and sale orders. It allows to see advanced payment directly on the sale order form view.
After processing a bank statement, you can start a wizard to link unreconciled incoming payments to a sale order.
This module targets B2B companies that don't want to generate a down payment invoice for an advanced payment.
This module has been written by Alexis de Lattre from Akretion

View File

@@ -0,0 +1,39 @@
# Copyright 2019 Akretion France (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class SaleOrder(models.Model):
_inherit = 'sale.order'
payment_line_ids = fields.One2many(
'account.move.line', 'sale_id', string='Advance Payments',
readonly=True)
amount_down_payment = fields.Monetary(
compute='_compute_amount_down_payment', string='Down Payment Amount')
@api.depends(
'payment_line_ids.credit', 'payment_line_ids.debit',
'payment_line_ids.amount_currency', 'payment_line_ids.currency_id',
'payment_line_ids.date', 'currency_id')
def _compute_amount_down_payment(self):
for sale in self:
down_payment = 0.0
sale_currency = sale.pricelist_id.currency_id
if sale_currency == sale.company_id.currency_id:
for pl in sale.payment_line_ids:
down_payment -= pl.balance
else:
for pl in sale.payment_line_ids:
if (
pl.currency_id and
pl.currency_id == sale_currency and
pl.amount_currency):
down_payment -= pl.amount_currency
else:
down_payment -= sale.company_id.currency_id._convert(
pl.balance, sale_currency, sale.company_id,
pl.date)
sale.amount_down_payment = down_payment

View File

@@ -18,6 +18,12 @@
<field name="payment_line_ids" nolabel="1"/>
</page>
</notebook>
<field name="amount_total" position="after">
<div class="oe_subtotal_footer_separator oe_inline o_td_label">
<label for="amount_down_payment" />
</div>
<field name="amount_down_payment" nolabel="1" class="oe_subtotal_footer_separator"/>
</field>
</field>
</record>