[FIX] sale: making an advance payment in percent
When making an advance payment in percent, the function onchange_advance_payment_method set the Down Payment Product to False. Then each time an advanced payment in percent was made, a new down payment product was created and set in sale.config.setting in the field deposit_product_id_setting. Now the function onchange_advance_payment_method let the Down Payment Product even if the payment method is in percent. opw:683167
This commit is contained in:
@@ -23,6 +23,19 @@ class SaleAdvancePaymentInv(models.TransientModel):
|
||||
return 'all'
|
||||
return 'delivered'
|
||||
|
||||
@api.model
|
||||
def _default_product_id(self):
|
||||
product_id = self.env['ir.values'].get_default('sale.config.settings', 'deposit_product_id_setting')
|
||||
return self.env['product.product'].browse(product_id)
|
||||
|
||||
@api.model
|
||||
def _default_deposit_account_id(self):
|
||||
return self._default_product_id().property_account_income_id
|
||||
|
||||
@api.model
|
||||
def _default_deposit_taxes_id(self):
|
||||
return self._default_product_id().taxes_id
|
||||
|
||||
advance_payment_method = fields.Selection([
|
||||
('delivered', 'Invoiceable lines'),
|
||||
('all', 'Invoiceable lines (deduct down payments)'),
|
||||
@@ -30,17 +43,17 @@ class SaleAdvancePaymentInv(models.TransientModel):
|
||||
('fixed', 'Down payment (fixed amount)')
|
||||
], string='What do you want to invoice?', default=_get_advance_payment_method, required=True)
|
||||
product_id = fields.Many2one('product.product', string='Down Payment Product', domain=[('type', '=', 'service')],\
|
||||
default=lambda self: self.env['ir.values'].get_default('sale.config.settings', 'deposit_product_id_setting'))
|
||||
default=_default_product_id)
|
||||
count = fields.Integer(default=_count, string='# of Orders')
|
||||
amount = fields.Float('Down Payment Amount', digits=dp.get_precision('Account'), help="The amount to be invoiced in advance, taxes excluded.")
|
||||
deposit_account_id = fields.Many2one("account.account", string="Income Account", domain=[('deprecated', '=', False)],\
|
||||
help="Account used for deposits")
|
||||
deposit_taxes_id = fields.Many2many("account.tax", string="Customer Taxes", help="Taxes used for deposits")
|
||||
help="Account used for deposits", default=_default_deposit_account_id)
|
||||
deposit_taxes_id = fields.Many2many("account.tax", string="Customer Taxes", help="Taxes used for deposits", default=_default_deposit_taxes_id)
|
||||
|
||||
@api.onchange('advance_payment_method')
|
||||
def onchange_advance_payment_method(self):
|
||||
if self.advance_payment_method == 'percentage':
|
||||
return {'value': {'amount':0, 'product_id':False}}
|
||||
return {'value': {'amount': 0}}
|
||||
return {}
|
||||
|
||||
@api.multi
|
||||
|
||||
Reference in New Issue
Block a user