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>
|
<field name="text">Missing account debit or credit for statement journal "%(s)s"</field>
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.message" id="msg_missing_code_product">
|
<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>
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</tryton>
|
</tryton>
|
||||||
|
|
37
statement.py
37
statement.py
|
@ -4,6 +4,7 @@
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from dateutil import tz
|
from dateutil import tz
|
||||||
|
|
||||||
from trytond.model import fields, ModelView, ModelSQL, Workflow
|
from trytond.model import fields, ModelView, ModelSQL, Workflow
|
||||||
from trytond.pool import Pool, PoolMeta
|
from trytond.pool import Pool, PoolMeta
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
|
@ -11,6 +12,7 @@ from trytond.wizard import Button, StateTransition, StateView, Wizard
|
||||||
from trytond.pyson import Eval
|
from trytond.pyson import Eval
|
||||||
from trytond.i18n import gettext
|
from trytond.i18n import gettext
|
||||||
from .exceptions import StatementValidationError
|
from .exceptions import StatementValidationError
|
||||||
|
from trytond.exceptions import UserError
|
||||||
|
|
||||||
_ZERO = Decimal("0.0")
|
_ZERO = Decimal("0.0")
|
||||||
|
|
||||||
|
@ -335,9 +337,9 @@ class OpenStatement(Wizard):
|
||||||
start = StateView(
|
start = StateView(
|
||||||
'open.statement.start',
|
'open.statement.start',
|
||||||
'sale_pos.open_statement_start', [
|
'sale_pos.open_statement_start', [
|
||||||
Button('Cancel', 'end', 'tryton-cancel'),
|
Button('Cancel', 'end', 'tryton-cancel'),
|
||||||
Button('Ok', 'create_', 'tryton-ok', default=True),
|
Button('Ok', 'create_', 'tryton-ok', default=True),
|
||||||
])
|
])
|
||||||
create_ = StateTransition()
|
create_ = StateTransition()
|
||||||
done = StateView(
|
done = StateView(
|
||||||
'open.statement.done',
|
'open.statement.done',
|
||||||
|
@ -352,7 +354,16 @@ class OpenStatement(Wizard):
|
||||||
def default_done(self, fields):
|
def default_done(self, fields):
|
||||||
return {
|
return {
|
||||||
'result': self.result,
|
'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):
|
def transition_create_(self):
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
|
@ -368,6 +379,15 @@ class OpenStatement(Wizard):
|
||||||
user = Transaction().user
|
user = Transaction().user
|
||||||
user = User(user)
|
user = User(user)
|
||||||
device = user.sale_device
|
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:
|
if device:
|
||||||
journals = [j.id for j in device.journals]
|
journals = [j.id for j in device.journals]
|
||||||
statements = Statement.search([
|
statements = Statement.search([
|
||||||
|
@ -376,14 +396,13 @@ class OpenStatement(Wizard):
|
||||||
], order=[
|
], order=[
|
||||||
('date', 'ASC'),
|
('date', 'ASC'),
|
||||||
])
|
])
|
||||||
journals_of_draft_statements = [s.journal for s in statements
|
journals_of_draft_statements = [
|
||||||
if s.state == 'draft']
|
s.journal for s in statements if s.state == 'draft'
|
||||||
|
]
|
||||||
|
|
||||||
vlist = []
|
vlist = []
|
||||||
result = ''
|
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:
|
for journal in device.journals:
|
||||||
statements_today = Statement.search([
|
statements_today = Statement.search([
|
||||||
('journal', '=', journal.id),
|
('journal', '=', journal.id),
|
||||||
|
|
Loading…
Reference in New Issue