mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
MIG sale_payment_deposit For Odoo 13.0
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
'name': 'Sale Payment Deposit',
|
||||
'author': 'Hibou Corp. <hello@hibou.io>',
|
||||
'category': 'Sales',
|
||||
'version': '12.0.1.0.0',
|
||||
'version': '13.0.1.0.0',
|
||||
'description':
|
||||
"""
|
||||
Sale Deposits
|
||||
|
||||
@@ -13,7 +13,6 @@ class AccountPaymentTerm(models.Model):
|
||||
class PaymentTransaction(models.Model):
|
||||
_inherit = 'payment.transaction'
|
||||
|
||||
@api.multi
|
||||
def _post_process_after_done(self):
|
||||
now = fields.Datetime.now()
|
||||
res = super(PaymentTransaction, self)._post_process_after_done()
|
||||
|
||||
@@ -14,7 +14,6 @@ class SaleOrder(models.Model):
|
||||
flat_deposite = float(order.payment_term_id.deposit_flat)
|
||||
order.amount_total_deposit = percent_deposit + flat_deposite
|
||||
|
||||
|
||||
def action_confirm(self):
|
||||
res = super(SaleOrder, self).action_confirm()
|
||||
self._auto_deposit_invoice()
|
||||
@@ -26,11 +25,11 @@ class SaleOrder(models.Model):
|
||||
# Create Deposit Invoices
|
||||
wizard = wizard_model.create({
|
||||
'advance_payment_method': 'fixed',
|
||||
'amount': sale.amount_total_deposit,
|
||||
'fixed_amount': sale.amount_total_deposit,
|
||||
})
|
||||
wizard.with_context(active_ids=sale.ids).create_invoices()
|
||||
# Validate Invoices
|
||||
sale.invoice_ids.filtered(lambda i: i.state == 'draft').action_invoice_open()
|
||||
sale.invoice_ids.filtered(lambda i: i.state == 'draft').post()
|
||||
# Attempt to reconcile
|
||||
sale._auto_deposit_payment_match()
|
||||
|
||||
@@ -39,12 +38,12 @@ class SaleOrder(models.Model):
|
||||
# Note that this probably doesn't work for a payment made on the front, see .account.PaymentTransaction
|
||||
aml_model = self.env['account.move.line'].sudo()
|
||||
for sale in self.sudo():
|
||||
for invoice in sale.invoice_ids.filtered(lambda i: i.state == 'open'):
|
||||
outstanding = json_loads(invoice.outstanding_credits_debits_widget)
|
||||
for invoice in sale.invoice_ids.filtered(lambda i: i.state == 'posted'):
|
||||
outstanding = json_loads(invoice.invoice_outstanding_credits_debits_widget)
|
||||
if isinstance(outstanding, dict) and outstanding.get('content'):
|
||||
for line in outstanding.get('content'):
|
||||
if abs(line.get('amount', 0.0) - invoice.residual) < 0.01 and line.get('id'):
|
||||
if abs(line.get('amount', 0.0) - invoice.amount_residual) < 0.01 and line.get('id'):
|
||||
aml = aml_model.browse(line.get('id'))
|
||||
aml += invoice.move_id.line_ids.filtered(lambda l: l.account_id == aml.account_id)
|
||||
aml += invoice.line_ids.filtered(lambda l: l.account_id == aml.account_id)
|
||||
if aml.reconcile():
|
||||
break
|
||||
|
||||
@@ -3,7 +3,6 @@ from odoo.exceptions import ValidationError
|
||||
from odoo.addons.sale.models.sale import SaleOrder
|
||||
|
||||
|
||||
@api.multi
|
||||
def _create_payment_transaction(self, vals):
|
||||
# This is a copy job from odoo.addons.sale.models.sale due to the closed nature of the vals.update(dict) call
|
||||
# Ultimately, only the 'vals.update' with the new amount is really used.
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
<h5 t-if="sale_order.amount_total_deposit"><b t-field="sale_order.amount_total_deposit"/> Deposit</h5>
|
||||
</xpath>
|
||||
<!-- Display the Deposit and Total when Signing -->
|
||||
<xpath expr="//div[@id='modalaccept']/div/form//li[2]" position="replace">
|
||||
<xpath expr="//div[@id='modalaccept']/div/form/main/p/ul/li[2]" position="replace">
|
||||
<li><span>For an amount of:</span> <b data-id="total_amount" t-field="sale_order.amount_total"/></li>
|
||||
<li t-if="sale_order.amount_total_deposit"><span>Deposit today of:</span> <b data-id="total_amount_deposit" t-field="sale_order.amount_total_deposit"/></li>
|
||||
<li t-if="sale_order.payment_term_id.note"><span t-field="sale_order.payment_term_id.note"/></li>
|
||||
</xpath>
|
||||
<!-- Display the Deposit when Paying -->
|
||||
<xpath expr="//div[@id='modalaccept']/div/main//li[2]" position="replace">
|
||||
<xpath expr="//div[@id='modalaccept']/div/div/main/p/ul/li[2]" position="replace">
|
||||
<li t-if="sale_order.amount_total_deposit"><span>For the deposit amount of:</span> <b data-id="total_amount_deposit" t-field="sale_order.amount_total_deposit"/></li>
|
||||
<li t-else=""><span>For an amount of:</span> <b data-id="total_amount" t-field="sale_order.amount_total"/></li>
|
||||
<li t-if="sale_order.payment_term_id.note"><span t-field="sale_order.payment_term_id.note"/></li>
|
||||
|
||||
Reference in New Issue
Block a user