MIG sale_payment_deposit For Odoo 13.0

This commit is contained in:
Bhoomi
2019-10-03 10:56:32 -04:00
committed by Cedric Collins
parent e2faace9e1
commit c821debd35
5 changed files with 9 additions and 12 deletions

View File

@@ -2,7 +2,7 @@
'name': 'Sale Payment Deposit', 'name': 'Sale Payment Deposit',
'author': 'Hibou Corp. <hello@hibou.io>', 'author': 'Hibou Corp. <hello@hibou.io>',
'category': 'Sales', 'category': 'Sales',
'version': '12.0.1.0.0', 'version': '13.0.1.0.0',
'description': 'description':
""" """
Sale Deposits Sale Deposits

View File

@@ -13,7 +13,6 @@ class AccountPaymentTerm(models.Model):
class PaymentTransaction(models.Model): class PaymentTransaction(models.Model):
_inherit = 'payment.transaction' _inherit = 'payment.transaction'
@api.multi
def _post_process_after_done(self): def _post_process_after_done(self):
now = fields.Datetime.now() now = fields.Datetime.now()
res = super(PaymentTransaction, self)._post_process_after_done() res = super(PaymentTransaction, self)._post_process_after_done()

View File

@@ -14,7 +14,6 @@ class SaleOrder(models.Model):
flat_deposite = float(order.payment_term_id.deposit_flat) flat_deposite = float(order.payment_term_id.deposit_flat)
order.amount_total_deposit = percent_deposit + flat_deposite order.amount_total_deposit = percent_deposit + flat_deposite
def action_confirm(self): def action_confirm(self):
res = super(SaleOrder, self).action_confirm() res = super(SaleOrder, self).action_confirm()
self._auto_deposit_invoice() self._auto_deposit_invoice()
@@ -26,11 +25,11 @@ class SaleOrder(models.Model):
# Create Deposit Invoices # Create Deposit Invoices
wizard = wizard_model.create({ wizard = wizard_model.create({
'advance_payment_method': 'fixed', 'advance_payment_method': 'fixed',
'amount': sale.amount_total_deposit, 'fixed_amount': sale.amount_total_deposit,
}) })
wizard.with_context(active_ids=sale.ids).create_invoices() wizard.with_context(active_ids=sale.ids).create_invoices()
# Validate 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 # Attempt to reconcile
sale._auto_deposit_payment_match() 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 # 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() aml_model = self.env['account.move.line'].sudo()
for sale in self.sudo(): for sale in self.sudo():
for invoice in sale.invoice_ids.filtered(lambda i: i.state == 'open'): for invoice in sale.invoice_ids.filtered(lambda i: i.state == 'posted'):
outstanding = json_loads(invoice.outstanding_credits_debits_widget) outstanding = json_loads(invoice.invoice_outstanding_credits_debits_widget)
if isinstance(outstanding, dict) and outstanding.get('content'): if isinstance(outstanding, dict) and outstanding.get('content'):
for line in 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 = 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(): if aml.reconcile():
break break

View File

@@ -3,7 +3,6 @@ from odoo.exceptions import ValidationError
from odoo.addons.sale.models.sale import SaleOrder from odoo.addons.sale.models.sale import SaleOrder
@api.multi
def _create_payment_transaction(self, vals): 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 # 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. # Ultimately, only the 'vals.update' with the new amount is really used.

View File

@@ -7,13 +7,13 @@
<h5 t-if="sale_order.amount_total_deposit"><b t-field="sale_order.amount_total_deposit"/> Deposit</h5> <h5 t-if="sale_order.amount_total_deposit"><b t-field="sale_order.amount_total_deposit"/> Deposit</h5>
</xpath> </xpath>
<!-- Display the Deposit and Total when Signing --> <!-- 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><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.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> <li t-if="sale_order.payment_term_id.note"><span t-field="sale_order.payment_term_id.note"/></li>
</xpath> </xpath>
<!-- Display the Deposit when Paying --> <!-- 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-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-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> <li t-if="sale_order.payment_term_id.note"><span t-field="sale_order.payment_term_id.note"/></li>