IMP sale_payment_deposit Implement flat deposit on Payment Terms and implement functionality on sale order and account invoice.

This commit is contained in:
Bhoomi
2019-09-05 10:38:02 -04:00
committed by Cedric Collins
parent 350cd80135
commit e2faace9e1
3 changed files with 10 additions and 4 deletions

View File

@@ -5,7 +5,9 @@ class AccountPaymentTerm(models.Model):
_inherit = 'account.payment.term'
deposit_percentage = fields.Float(string='Deposit Percentage',
help='Require deposit when paying on the front end.')
help='Require Percentage deposit when paying on the front end.')
deposit_flat = fields.Float(string='Deposit Flat',
help='Require Flat deposit when paying on the front end.')
class PaymentTransaction(models.Model):

View File

@@ -10,7 +10,10 @@ class SaleOrder(models.Model):
@api.depends('amount_total', 'payment_term_id.deposit_percentage')
def _amount_total_deposit(self):
for order in self:
order.amount_total_deposit = order.amount_total * float(order.payment_term_id.deposit_percentage) / 100.0
percent_deposit = order.amount_total * float(order.payment_term_id.deposit_percentage) / 100.0
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()
@@ -22,8 +25,8 @@ class SaleOrder(models.Model):
for sale in self.sudo().filtered(lambda o: not o.invoice_ids and o.amount_total_deposit):
# Create Deposit Invoices
wizard = wizard_model.create({
'advance_payment_method': 'percentage',
'amount': sale.payment_term_id.deposit_percentage,
'advance_payment_method': 'fixed',
'amount': sale.amount_total_deposit,
})
wizard.with_context(active_ids=sale.ids).create_invoices()
# Validate Invoices

View File

@@ -7,6 +7,7 @@
<field name="arch" type="xml">
<xpath expr="//group/group" position="inside">
<field name="deposit_percentage"/>
<field name="deposit_flat"/>
</xpath>
</field>
</record>