add domain in wizard salepayment
This commit is contained in:
parent
1f61df6bf2
commit
820a75c3b8
|
@ -14,3 +14,6 @@ class ShopUserError(UserError):
|
|||
|
||||
class SaleWriteError(UserError):
|
||||
pass
|
||||
|
||||
class PartyMissingAccount(UserError):
|
||||
pass
|
||||
|
|
35
sale.py
35
sale.py
|
@ -5,6 +5,8 @@ import logging
|
|||
from decimal import Decimal
|
||||
from datetime import date, timedelta
|
||||
import calendar
|
||||
from multiprocessing import context
|
||||
from unittest import result
|
||||
from sql.aggregate import Sum
|
||||
from sql.functions import Extract
|
||||
from sql.conditionals import Case
|
||||
|
@ -13,14 +15,14 @@ from sql.operators import In
|
|||
from trytond.model import fields, Unique, ModelView
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.pyson import Bool, Eval, Or, Not
|
||||
from trytond.pyson import Bool, Eval, Or, Not,If
|
||||
from trytond.report import Report
|
||||
from trytond.wizard import (
|
||||
Wizard, StateView, StateAction, StateReport, Button, StateTransition
|
||||
)
|
||||
from trytond.i18n import gettext
|
||||
from .exceptions import (
|
||||
SaleMissingSequenceError, ShopUserError, SaleWriteError
|
||||
SaleMissingSequenceError, ShopUserError, SaleWriteError, PartyMissingAccount
|
||||
)
|
||||
from trytond.modules.sale.exceptions import SaleValidationError
|
||||
|
||||
|
@ -1082,9 +1084,7 @@ class SalePaymentForm(ModelView):
|
|||
'Sale Payment Form'
|
||||
__name__ = 'sale.payment.form'
|
||||
statement = fields.Many2One('account.statement', 'Statement',
|
||||
domain=[
|
||||
('state', '=', 'draft'),
|
||||
], required=True)
|
||||
required=True)
|
||||
amount_payable = fields.Numeric('Amount Payable', required=True,
|
||||
digits=(16, Eval('currency_digits', 2)),
|
||||
depends=['currency_digits'])
|
||||
|
@ -1099,6 +1099,10 @@ class SalePaymentForm(ModelView):
|
|||
self_pick_up = fields.Boolean('Self Pick Up', readonly=True)
|
||||
do_invoice = fields.Boolean('Do Invoice')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(SalePaymentForm, cls).__setup__()
|
||||
|
||||
@fields.depends('statement', 'voucher')
|
||||
def on_change_with_require_voucher(self):
|
||||
if self.statement:
|
||||
|
@ -1129,8 +1133,27 @@ class WizardSalePayment(Wizard):
|
|||
def __setup__(cls):
|
||||
super(WizardSalePayment, cls).__setup__()
|
||||
|
||||
@classmethod
|
||||
def execute(cls, session_id, data, state_name):
|
||||
pool = Pool()
|
||||
Sale = pool.get('sale.sale')
|
||||
sale = Sale(Transaction().context['active_id'])
|
||||
result = super().execute(session_id, data, state_name)
|
||||
dom_statement = [
|
||||
('state', '=', 'draft')
|
||||
]
|
||||
context = Transaction().context
|
||||
|
||||
if context.get('sale_device', None):
|
||||
dom_statement.append(('sale_device', '=', sale.sale_device.id))
|
||||
|
||||
if result.get('view'):
|
||||
result['view']['fields_view']['fields']['statement']['domain']= dom_statement
|
||||
return result
|
||||
|
||||
def default_start(self, fields):
|
||||
Sale = Pool().get('sale.sale')
|
||||
pool = Pool()
|
||||
Sale = pool.get('sale.sale')
|
||||
sale = Sale(Transaction().context['active_id'])
|
||||
return {
|
||||
'amount_payable': abs(sale.total_amount - sale.paid_amount
|
||||
|
|
Loading…
Reference in New Issue