Add force draft by account admin
This commit is contained in:
parent
bf51a4e9ab
commit
81ae6780a7
27
statement.py
27
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.
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -22,8 +22,9 @@ copyright notices and license terms. -->
|
|||
</page>
|
||||
</xpath>
|
||||
<xpath expr="/form/notebook/page[@id='info']/field[@name='company']" position="after">
|
||||
<label name="salesman"/>
|
||||
<field name="salesman"/>
|
||||
<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">
|
||||
|
|
Loading…
Reference in New Issue