diff --git a/statement.py b/statement.py index 8c31692..23b2e17 100755 --- a/statement.py +++ b/statement.py @@ -34,11 +34,11 @@ class Statement(metaclass=PoolMeta): total_money = fields.Function( fields.Numeric("Total Money"), 'get_total_money') amount_difference = fields.Function(fields.Numeric("Amount Difference"), - 'get_amount_difference') + 'get_amount_difference') expenses_daily = fields.One2Many('sale_pos.expenses_daily', 'statement', - 'Expenses Daily') + 'Expenses Daily') additional_income = fields.One2Many('sale_pos.additional_income', 'statement', - 'Additional Income') + 'Additional Income') balance_next_shift = fields.Numeric('balance next shift', digits=(10, 2)) salesman = fields.Many2One('company.employee', 'Salesman', states={ 'readonly': Eval('state').in_(['validated', 'cancel', 'posted']), @@ -47,6 +47,15 @@ class Statement(metaclass=PoolMeta): @classmethod def __setup__(cls): super(Statement, cls).__setup__() + cls._transitions |= set(( + ('posted', 'draft'), + )) + cls._buttons.update({ + 'force_draft': { + 'invisible': Eval('state') != 'posted', + 'depends': ['state'], + }, + }) @classmethod def cron_autopost(cls): @@ -73,15 +82,13 @@ class Statement(metaclass=PoolMeta): @classmethod def get_users(cls, statements, names): - return { - 'users': + return {'users': {s.id: [ u.id for j in s.journal for d in j.devices for u in d.users - ] - } for s in statements} + ]} for s in statements} @classmethod def search_users(cls, name, clause): @@ -124,6 +131,12 @@ class Statement(metaclass=PoolMeta): # }) # MoneyCount.create(money_to_create) + @classmethod + @ModelView.button + @Workflow.transition('draft') + def force_draft(cls, statements): + pass + @classmethod def create_move(cls, statements): '''Create move for the statements and try to reconcile the lines. diff --git a/statement.xml b/statement.xml index 0d85fe1..66f68bb 100755 --- a/statement.xml +++ b/statement.xml @@ -263,5 +263,17 @@ copyright notices and license terms. --> tree additional_income_tree + + + force_draft + Force Draft + Are you sure you want to force draft account statement posted? + + + + + + diff --git a/view/statement_form.xml b/view/statement_form.xml index 095f1c8..814a3b4 100755 --- a/view/statement_form.xml +++ b/view/statement_form.xml @@ -22,8 +22,9 @@ copyright notices and license terms. --> -