[MERGE] merge with lp:openobject-addons
bzr revid: cha@tinyerp.com-20121023120326-1x61o0a5dtbg313q
This commit is contained in:
@@ -185,6 +185,7 @@ class account_invoice(osv.osv):
|
||||
_columns = {
|
||||
'name': fields.char('Description', size=64, select=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'origin': fields.char('Source Document', size=64, help="Reference of the document that produced this invoice.", readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'supplier_invoice_number': fields.char('Supplier Invoice Number', size=64, help="The reference of this invoice as provided by the supplier.", readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'type': fields.selection([
|
||||
('out_invoice','Customer Invoice'),
|
||||
('in_invoice','Supplier Invoice'),
|
||||
|
||||
@@ -168,12 +168,15 @@
|
||||
context="{'default_customer': 0, 'search_default_supplier': 1, 'default_supplier': 1}"
|
||||
domain="[('supplier', '=', True)]"/>
|
||||
<field name="fiscal_position" widget="selection"/>
|
||||
<field name="origin"/>
|
||||
<label for="reference_type"/>
|
||||
<div>
|
||||
<group>
|
||||
<field name="origin"/>
|
||||
<field name="supplier_invoice_number"/>
|
||||
</group>
|
||||
<label for="reference_type"/>
|
||||
<div>
|
||||
<field name="reference_type" class="oe_inline oe_edit_only"/>
|
||||
<field name="reference" class="oe_inline"/>
|
||||
</div>
|
||||
</div>
|
||||
</group>
|
||||
<group>
|
||||
<field name="date_invoice"/>
|
||||
@@ -445,7 +448,7 @@
|
||||
<field name="model">account.invoice</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Invoice">
|
||||
<field name="number" string="Invoice" filter_domain="['|', ('number','ilike',self),('origin','ilike',self)]"/>
|
||||
<field name="number" string="Invoice" filter_domain="['|','|', ('number','ilike',self), ('origin','ilike',self), ('supplier_invoice_number', 'ilike', self)]"/>
|
||||
<filter name="draft" icon="terp-document-new" string="Draft" domain="[('state','=','draft')]" help="Draft Invoices"/>
|
||||
<filter name="proforma" icon="terp-gtk-media-pause" string="Proforma" domain="[('state','=','proforma2')]" help="Proforma Invoices" groups="account.group_proforma_invoices"/>
|
||||
<filter name="invoices" icon="terp-dolar" string="Invoices" domain="[('state','not in',['draft','cancel'])]" help="Proforma/Open/Paid Invoices"/>
|
||||
|
||||
@@ -32,13 +32,23 @@ import datetime
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
|
||||
from itertools import groupby
|
||||
from operator import itemgetter
|
||||
|
||||
|
||||
FIELD_STATES = [('clear', 'Clear'), ('anonymized', 'Anonymized'), ('not_existing', 'Not Existing')]
|
||||
ANONYMIZATION_STATES = FIELD_STATES + [('unstable', 'Unstable')]
|
||||
WIZARD_ANONYMIZATION_STATES = [('clear', 'Clear'), ('anonymized', 'Anonymized'), ('unstable', 'Unstable')]
|
||||
ANONYMIZATION_HISTORY_STATE = [('started', 'Started'), ('done', 'Done'), ('in_exception', 'Exception occured')]
|
||||
ANONYMIZATION_DIRECTION = [('clear -> anonymized', 'clear -> anonymized'), ('anonymized -> clear', 'anonymized -> clear')]
|
||||
|
||||
|
||||
def group(lst, cols):
|
||||
if isinstance(cols, basestring):
|
||||
cols = [cols]
|
||||
return dict((k, [v for v in itr]) for k, itr in groupby(sorted(lst, key=itemgetter(*cols)), itemgetter(*cols)))
|
||||
|
||||
|
||||
class ir_model_fields_anonymization(osv.osv):
|
||||
_name = 'ir.model.fields.anonymization'
|
||||
_rec_name = 'field_id'
|
||||
@@ -207,8 +217,6 @@ class ir_model_fields_anonymization(osv.osv):
|
||||
'state': lambda *a: 'clear',
|
||||
}
|
||||
|
||||
ir_model_fields_anonymization()
|
||||
|
||||
|
||||
class ir_model_fields_anonymization_history(osv.osv):
|
||||
_name = 'ir.model.fields.anonymization.history'
|
||||
@@ -223,8 +231,6 @@ class ir_model_fields_anonymization_history(osv.osv):
|
||||
'filepath': fields.char(string='File path', size=256, readonly=True),
|
||||
}
|
||||
|
||||
ir_model_fields_anonymization_history()
|
||||
|
||||
|
||||
class ir_model_fields_anonymize_wizard(osv.osv_memory):
|
||||
_name = 'ir.model.fields.anonymize.wizard'
|
||||
@@ -250,8 +256,8 @@ class ir_model_fields_anonymize_wizard(osv.osv_memory):
|
||||
'name': fields.char(size=64, string='File Name'),
|
||||
'summary': fields.function(_get_summary, type='text', string='Summary'),
|
||||
'file_export': fields.binary(string='Export'),
|
||||
'file_import': fields.binary(string='Import'),
|
||||
'state': fields.function(_get_state, string='Status', type='selection', selection=ANONYMIZATION_STATES, readonly=False),
|
||||
'file_import': fields.binary(string='Import', help="This is the file created by the anonymization process. It should have the '.pickle' extention."),
|
||||
'state': fields.function(_get_state, string='Status', type='selection', selection=WIZARD_ANONYMIZATION_STATES, readonly=False),
|
||||
'msg': fields.text(string='Message'),
|
||||
}
|
||||
|
||||
@@ -319,6 +325,7 @@ class ir_model_fields_anonymize_wizard(osv.osv_memory):
|
||||
# clicked in the menu and the fields are already anonymized
|
||||
placeholder.addnext(etree.Element('newline'))
|
||||
placeholder.addnext(etree.Element('field', {'name': 'file_import', 'required': "1"}))
|
||||
placeholder.addnext(etree.Element('label', {'string': 'Anonymization file'}))
|
||||
eview.remove(placeholder)
|
||||
elif step == 'just_anonymized':
|
||||
# we just ran the anonymization process, we need the file export field
|
||||
@@ -500,7 +507,6 @@ class ir_model_fields_anonymize_wizard(osv.osv_memory):
|
||||
|
||||
def reverse_anonymize_database(self, cr, uid, ids, context=None):
|
||||
"""Set the 'clear' state to defined fields"""
|
||||
|
||||
ir_model_fields_anonymization_model = self.pool.get('ir.model.fields.anonymization')
|
||||
anonymization_history_model = self.pool.get('ir.model.fields.anonymization.history')
|
||||
|
||||
@@ -524,23 +530,46 @@ class ir_model_fields_anonymize_wizard(osv.osv_memory):
|
||||
wizards = self.browse(cr, uid, ids, context=context)
|
||||
for wizard in wizards:
|
||||
if not wizard.file_import:
|
||||
msg = "It is not possible to reverse the anonymization process without supplying anonymization export file."
|
||||
msg = "It is not possible to reverse the anonymization process without supplying the anonymization export file."
|
||||
self._raise_after_history_update(cr, uid, history_id, 'Error !', msg)
|
||||
|
||||
# reverse the anonymization:
|
||||
# load the pickle file content into a data structure:
|
||||
data = pickle.loads(base64.decodestring(wizard.file_import))
|
||||
|
||||
migration_fix_obj = self.pool.get('ir.model.fields.anonymization.migration.fix')
|
||||
fix_ids = migration_fix_obj.search(cr, uid, [('target_version', '=', '7.0')])
|
||||
fixes = migration_fix_obj.read(cr, uid, fix_ids, ['model_name', 'field_name', 'query', 'query_type', 'sequence'])
|
||||
fixes = group(fixes, ('model_name', 'field_name'))
|
||||
|
||||
for line in data:
|
||||
table_name = self.pool.get(line['model_id'])._table
|
||||
sql = "update %(table)s set %(field)s = %%(value)s where id = %%(id)s" % {
|
||||
'table': table_name,
|
||||
'field': line['field_id'],
|
||||
}
|
||||
cr.execute(sql, {
|
||||
'value': line['value'],
|
||||
'id': line['id']
|
||||
})
|
||||
|
||||
# check if custom sql exists:
|
||||
key = (line['model_id'], line['field_id'])
|
||||
custom_updates = fixes.get(key)
|
||||
if custom_updates:
|
||||
custom_updates.sort(itemgetter('sequence'))
|
||||
queries = [(record['query'], record['query_type']) for record in custom_updates if record['query_type']]
|
||||
else:
|
||||
queries = [("update %(table)s set %(field)s = %%(value)s where id = %%(id)s" % {
|
||||
'table': table_name,
|
||||
'field': line['field_id'],
|
||||
}, 'sql')]
|
||||
|
||||
for query in queries:
|
||||
if query[1] == 'sql':
|
||||
sql = query[0]
|
||||
cr.execute(sql, {
|
||||
'value': line['value'],
|
||||
'id': line['id']
|
||||
})
|
||||
elif query[1] == 'python':
|
||||
raw_code = query[0]
|
||||
code = raw_code % line
|
||||
eval(code)
|
||||
else:
|
||||
raise Exception("Unknown query type '%s'. Valid types are: sql, python." % (query['query_type'], ))
|
||||
|
||||
# update the anonymization fields:
|
||||
ir_model_fields_anonymization_model = self.pool.get('ir.model.fields.anonymization')
|
||||
@@ -589,7 +618,19 @@ class ir_model_fields_anonymize_wizard(osv.osv_memory):
|
||||
res = None
|
||||
return res
|
||||
|
||||
ir_model_fields_anonymize_wizard()
|
||||
|
||||
class ir_model_fields_anonymization_migration_fix(osv.osv):
|
||||
_name = 'ir.model.fields.anonymization.migration.fix'
|
||||
_order = "sequence"
|
||||
|
||||
_columns = {
|
||||
'target_version': fields.char('Target Version'),
|
||||
'model_name': fields.char('Model'),
|
||||
'field_name': fields.char('Field'),
|
||||
'query': fields.text('Query'),
|
||||
'query_type': fields.selection(string='Query', selection=[('sql', 'sql'), ('python', 'python')]),
|
||||
'sequence': fields.integer('Sequence'),
|
||||
}
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
<field name="model_id" on_change="onchange_model_id(model_id)" />
|
||||
<field name="model_name" on_change="onchange_model_name(model_name)" />
|
||||
<field name="field_id"
|
||||
|
||||
on_change="onchange_field_id(field_id, model_name)"
|
||||
domain="[('model_id','=',model_id), ('ttype', 'not in', ['function', 'binary', 'many2many', 'many2one', 'one2many', 'reference'])]" />
|
||||
<field name="field_name" on_change="onchange_field_name(field_name, model_name)" />
|
||||
|
||||
@@ -938,10 +938,11 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
||||
this.renderElement();
|
||||
},
|
||||
addPaymentLine: function(newPaymentLine) {
|
||||
var self = this;
|
||||
var x = new module.PaymentlineWidget(null, {
|
||||
payment_line: newPaymentLine
|
||||
});
|
||||
x.on_delete.add(_.bind(this.deleteLine, this, x));
|
||||
x.on('delete_payment_line', self, self.deleteLine);
|
||||
x.appendTo(this.$('#paymentlines'));
|
||||
},
|
||||
renderElement: function() {
|
||||
|
||||
@@ -142,7 +142,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
||||
},
|
||||
click_handler: function() {
|
||||
this.order.selectLine(this.model);
|
||||
this.on_selected();
|
||||
this.trigger('order_line_selected');
|
||||
},
|
||||
renderElement: function() {
|
||||
this._super();
|
||||
@@ -153,10 +153,8 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
||||
},
|
||||
refresh: function(){
|
||||
this.renderElement();
|
||||
this.on_refresh();
|
||||
this.trigger('order_line_refreshed');
|
||||
},
|
||||
on_selected: function() {},
|
||||
on_refresh: function(){},
|
||||
});
|
||||
|
||||
module.OrderWidget = module.PosBaseWidget.extend({
|
||||
@@ -230,8 +228,8 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
||||
model: orderLine,
|
||||
order: this.pos.get('selectedOrder'),
|
||||
});
|
||||
line.on_selected.add(_.bind(this.update_numpad, this));
|
||||
line.on_refresh.add(_.bind(this.update_summary, this));
|
||||
line.on('order_line_selected', self, self.update_numpad);
|
||||
line.on('order_line_refreshed', self, self.update_summary);
|
||||
line.appendTo($content);
|
||||
}, this));
|
||||
this.update_numpad();
|
||||
@@ -303,7 +301,6 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
||||
this.payment_line = options.payment_line;
|
||||
this.payment_line.bind('change', this.changedAmount, this);
|
||||
},
|
||||
on_delete: function() {},
|
||||
changeAmount: function(event) {
|
||||
var newAmount;
|
||||
newAmount = event.currentTarget.value;
|
||||
@@ -317,10 +314,13 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
||||
this.renderElement();
|
||||
},
|
||||
renderElement: function() {
|
||||
var self = this;
|
||||
this.name = this.payment_line.get_cashregister().get('journal_id')[1];
|
||||
this._super();
|
||||
this.$('input').keyup(_.bind(this.changeAmount, this));
|
||||
this.$('.delete-payment-line').click(this.on_delete);
|
||||
this.$('.delete-payment-line').click(function() {
|
||||
self.trigger('delete_payment_line');
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user