[IMP] account_analytric_analysis: add a stat button on the contract
form that redirect to all related invoices. This button is linked to an action disallowing the invoice creation; users should use the contract form view instead.
This commit is contained in:
committed by
Thibault Delavallée
parent
92a31785d3
commit
f1cb34c7de
@@ -294,6 +294,23 @@
|
||||
<menuitem id="base.menu_invoiced" name="Invoicing" parent="base.menu_base_partner" sequence="5"/>
|
||||
<menuitem action="action_hr_tree_invoiced_all" id="menu_action_hr_tree_invoiced_all" parent="base.menu_invoiced" sequence="5"/>
|
||||
|
||||
<!-- Action Show all invoices related to a contract -->
|
||||
<record id="action_contract_invoices_all" model="ir.actions.act_window">
|
||||
<field name="name">Invoices</field>
|
||||
<field name="res_model">account.invoice</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('invoice_line.account_analytic_id', '=', active_id)]</field>
|
||||
<field name="context">{'create':False}</field>
|
||||
<field name="help" type="html">
|
||||
<p>
|
||||
You will find here all the invoices related to this contract.
|
||||
If you want to create a new invoice for this contract, you should use
|
||||
the invoicing menu on the contract form view instead.
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Action Sales/Invoicing/Contract to renew -->
|
||||
<record id="action_account_analytic_overdue" model="ir.actions.act_window">
|
||||
<field name="name">Contracts to Renew</field>
|
||||
@@ -359,6 +376,10 @@
|
||||
name="%(action_hr_tree_invoiced_all)d"
|
||||
type="action"
|
||||
context="{'search_default_account_id': [active_id], 'default_account_id': active_id}"/>
|
||||
<button class="oe_inline oe_stat_button" string="Invoices"
|
||||
icon="fa-book"
|
||||
name="%(action_contract_invoices_all)d"
|
||||
type="action"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -219,11 +219,7 @@ class ir_attachment(osv.osv):
|
||||
# datas is false, but file_size and checksum are not (computed as datas is an empty string)
|
||||
if not value:
|
||||
# reset computed fields
|
||||
<<<<<<< HEAD
|
||||
super(ir_attachment, self).write(cr, SUPERUSER_ID, [id], vals, context=context)
|
||||
=======
|
||||
super(ir_attachment, self).write(cr, SUPERUSER_ID, [id], {'file_size' : 0, 'checksum' : None, 'mimetype' : None, 'index_content' : None}, context=context)
|
||||
>>>>>>> [IMP] ir_ui_view: add context check in postprocess_and_fields
|
||||
return True
|
||||
if context is None:
|
||||
context = {}
|
||||
@@ -231,21 +227,8 @@ class ir_attachment(osv.osv):
|
||||
attach = self.browse(cr, uid, id, context=context)
|
||||
fname_to_delete = attach.store_fname
|
||||
location = self._storage(cr, uid, context)
|
||||
<<<<<<< HEAD
|
||||
# compute the index_content field
|
||||
vals['index_content'] = self._index(cr, SUPERUSER_ID, bin_data, attach.datas_fname, attach.mimetype),
|
||||
=======
|
||||
# compute the field depending of datas
|
||||
bin_data = value.decode('base64')
|
||||
mimetype = self._compute_mimetype(bin_data)
|
||||
checksum = self._compute_checksum(bin_data)
|
||||
vals = {
|
||||
'file_size': len(bin_data),
|
||||
'checksum' : checksum,
|
||||
'mimetype' : mimetype,
|
||||
'index_content' : self._index(cr, SUPERUSER_ID, bin_data, attach.datas_fname, mimetype),
|
||||
}
|
||||
>>>>>>> [IMP] ir_ui_view: add context check in postprocess_and_fields
|
||||
if location != 'db':
|
||||
# create the file
|
||||
fname = self._file_write(cr, uid, value, checksum)
|
||||
@@ -275,7 +258,6 @@ class ir_attachment(osv.osv):
|
||||
return hashlib.sha1(bin_data).hexdigest()
|
||||
return False
|
||||
|
||||
<<<<<<< HEAD
|
||||
def _compute_mimetype(self, values):
|
||||
""" compute the mimetype of the given values
|
||||
:param values : dict of values to create or write an ir_attachment
|
||||
@@ -287,14 +269,6 @@ class ir_attachment(osv.osv):
|
||||
if 'datas' in values:
|
||||
mimetype = guess_mimetype(values.get('datas').decode('base64'))
|
||||
return mimetype
|
||||
=======
|
||||
def _compute_mimetype(self, bin_data):
|
||||
""" compute the mimetype of the given datas
|
||||
:param bin_data : binary data
|
||||
:return mime : string indicating the mimetype, or application/octet-stream by default
|
||||
"""
|
||||
return guess_mimetype(bin_data)
|
||||
>>>>>>> [IMP] ir_ui_view: add context check in postprocess_and_fields
|
||||
|
||||
def _index(self, cr, uid, bin_data, datas_fname, file_type):
|
||||
""" compute the index content of the given filename, or binary data.
|
||||
@@ -455,11 +429,7 @@ class ir_attachment(osv.osv):
|
||||
ids = [ids]
|
||||
self.check(cr, uid, ids, 'write', context=context, values=vals)
|
||||
# remove computed field depending of datas
|
||||
<<<<<<< HEAD
|
||||
for field in ['file_size', 'checksum']:
|
||||
=======
|
||||
for field in ['file_size', 'checksum', 'mimetype']:
|
||||
>>>>>>> [IMP] ir_ui_view: add context check in postprocess_and_fields
|
||||
vals.pop(field, False)
|
||||
return super(ir_attachment, self).write(cr, uid, ids, vals, context)
|
||||
|
||||
@@ -487,16 +457,11 @@ class ir_attachment(osv.osv):
|
||||
|
||||
def create(self, cr, uid, values, context=None):
|
||||
# remove computed field depending of datas
|
||||
<<<<<<< HEAD
|
||||
for field in ['file_size', 'checksum']:
|
||||
values.pop(field, False)
|
||||
# if mimetype not given, compute it !
|
||||
if 'mimetype' not in values:
|
||||
values['mimetype'] = self._compute_mimetype(values)
|
||||
=======
|
||||
for field in ['file_size', 'checksum', 'mimetype']:
|
||||
values.pop(field, False)
|
||||
>>>>>>> [IMP] ir_ui_view: add context check in postprocess_and_fields
|
||||
self.check(cr, uid, [], mode='write', context=context, values=values)
|
||||
return super(ir_attachment, self).create(cr, uid, values, context)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user