Add force draft by account admin

This commit is contained in:
oscar alvarez 2023-04-28 12:40:09 -05:00
parent bf51a4e9ab
commit 81ae6780a7
3 changed files with 35 additions and 9 deletions

View File

@ -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.

View File

@ -263,5 +263,17 @@ copyright notices and license terms. -->
<field name="type">tree</field>
<field name="name">additional_income_tree</field>
</record>
<record model="ir.model.button" id="account_statement_force_draft_button">
<field name="name">force_draft</field>
<field name="string">Force Draft</field>
<field name="confirm">Are you sure you want to force draft account statement posted?</field>
<field name="model" search="[('model', '=', 'account.statement')]"/>
</record>
<record model="ir.model.button-res.group"
id="account_statement_force_draft_button_group_account">
<field name="button" ref="account_statement_force_draft_button"/>
<field name="group" ref="account.group_account_admin"/>
</record>
</data>
</tryton>

View File

@ -24,6 +24,7 @@ copyright notices and license terms. -->
<xpath expr="/form/notebook/page[@id='info']/field[@name='company']" position="after">
<label name="salesman"/>
<field name="salesman"/>
<button name="force_draft" string="Force Draft" icon="tryton-forward"/>
</xpath>
<xpath expr="/form/notebook/page[@id='info']" position="after">
<page string="Expenses" id="count_money_tree">