Minor fix
This commit is contained in:
parent
78948ed262
commit
69a5c48393
|
@ -61,7 +61,10 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="text">Missing account debit or credit for statement journal "%(s)s"</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_missing_code_product">
|
||||
<field name="text">Missing code for product.</field>
|
||||
<field name="text">Missing code for product</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_previous_statement_open">
|
||||
<field name="text">There is previous statement current open. Please close it!</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
29
statement.py
29
statement.py
|
@ -4,6 +4,7 @@
|
|||
from datetime import date, datetime
|
||||
from decimal import Decimal
|
||||
from dateutil import tz
|
||||
|
||||
from trytond.model import fields, ModelView, ModelSQL, Workflow
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.transaction import Transaction
|
||||
|
@ -11,6 +12,7 @@ from trytond.wizard import Button, StateTransition, StateView, Wizard
|
|||
from trytond.pyson import Eval
|
||||
from trytond.i18n import gettext
|
||||
from .exceptions import StatementValidationError
|
||||
from trytond.exceptions import UserError
|
||||
|
||||
_ZERO = Decimal("0.0")
|
||||
|
||||
|
@ -354,6 +356,15 @@ class OpenStatement(Wizard):
|
|||
'result': self.result,
|
||||
}
|
||||
|
||||
def _check_previous(self, sale_device, today):
|
||||
pool = Pool()
|
||||
Statement = pool.get('account.statement')
|
||||
res = Statement.search_read([
|
||||
('sale_device', '=', sale_device.id),
|
||||
('state', '=', 'draft'),
|
||||
], fields_names=['id'])
|
||||
return res
|
||||
|
||||
def transition_create_(self):
|
||||
pool = Pool()
|
||||
User = pool.get('res.user')
|
||||
|
@ -368,6 +379,15 @@ class OpenStatement(Wizard):
|
|||
user = Transaction().user
|
||||
user = User(user)
|
||||
device = user.sale_device
|
||||
time_zone = company.timezone
|
||||
now_ = datetime.now(tz.gettz(time_zone))
|
||||
today = date(now_.year, now_.month, now_.day)
|
||||
previous = self._check_previous(device, today)
|
||||
print("res............", previous)
|
||||
if previous:
|
||||
raise UserError(
|
||||
gettext('sale_pos.msg_previous_statement_open'))
|
||||
return 'end'
|
||||
if device:
|
||||
journals = [j.id for j in device.journals]
|
||||
statements = Statement.search([
|
||||
|
@ -376,14 +396,13 @@ class OpenStatement(Wizard):
|
|||
], order=[
|
||||
('date', 'ASC'),
|
||||
])
|
||||
journals_of_draft_statements = [s.journal for s in statements
|
||||
if s.state == 'draft']
|
||||
journals_of_draft_statements = [
|
||||
s.journal for s in statements if s.state == 'draft'
|
||||
]
|
||||
|
||||
vlist = []
|
||||
result = ''
|
||||
time_zone = company.timezone
|
||||
now_ = datetime.now(tz.gettz(time_zone))
|
||||
today = date(now_.year, now_.month, now_.day)
|
||||
|
||||
for journal in device.journals:
|
||||
statements_today = Statement.search([
|
||||
('journal', '=', journal.id),
|
||||
|
|
Loading…
Reference in New Issue