[tryton-dev] trytond: Add missing converter to get_style_content of ir.action.report (issue203001)
Reviewers: , Please review this at http://codereview.tryton.org/203001/ Affected files: M trytond/ir/action.py Index: trytond/ir/action.py === --- a/trytond/ir/action.py +++ b/trytond/ir/action.py @@ -425,6 +425,12 @@ def get_style_content(self, ids, name): res = {} +converter = buffer +default = False +format_ = Transaction().context.pop('%s.%s' % (self._name, name), '') +if format_ == 'size': +converter = len +default = 0 for report in self.browse(ids): try: with file_open( report.style.replace('/', os.sep), @@ -432,7 +438,7 @@ data = fp.read() except Exception: data = False -res[report.id] = data +res[report.id] = converter(data) if data else default return res def get_pyson(self, ids, name): -- tryton-dev@googlegroups.com mailing list
[tryton-dev] trytond: Fix str convertion of buffer if False for issue2335 (issue198005)
Reviewers: , Please review this at http://codereview.tryton.org/198005/ Affected files: M trytond/report/report.py Index: trytond/report/report.py === --- a/trytond/report/report.py +++ b/trytond/report/report.py @@ -166,8 +166,10 @@ localcontext['setLang'] = lambda language: translate.set_language(language) # Convert to str as buffer from DB is not supported by StringIO -report_content = str(report.report_content) -style_content = str(report.style_content) +report_content = (str(report.report_content) if report.report_content +else False) +style_content = (str(report.style_content) if report.style_content +else False) if not report_content: raise Exception('Error', 'Missing report file!') -- tryton-dev@googlegroups.com mailing list
[tryton-dev] Put focus on search entry (issue198004)
Reviewers: , Please review this at http://codereview.tryton.org/198004/ Affected files: M tryton/gui/window/form.py M tryton/gui/window/view_form/screen/screen.py M tryton/gui/window/view_form/view/form.py M tryton/gui/window/window.py Index: tryton/gui/window/form.py === --- a/tryton/gui/window/form.py +++ b/tryton/gui/window/form.py @@ -592,6 +592,10 @@ return menu +def grab_focus(self): +if self.screen.focusable_widget: +self.screen.focusable_widget.grab_focus() + def _popup_menu_selected(self, menuitem, togglebutton, action, keyword): event = gtk.get_current_event() allow_similar = False Index: tryton/gui/window/view_form/screen/screen.py === --- a/tryton/gui/window/view_form/screen/screen.py +++ b/tryton/gui/window/view_form/screen/screen.py @@ -505,6 +505,18 @@ current_view = property(__get_current_view) +@property +def focusable_widget(self): +current_view = self.current_view +focusable_widget = None +if current_view.view_type == 'tree': +focusable_widget = current_view.widget_tree +if self.screen_container.filter_vbox: +focusable_widget = self.screen_container.search_entry +elif current_view.view_type == 'form': +focusable_widget = current_view.focusable_widget +return focusable_widget + def get(self, get_readonly=True, includeid=False, check_load=True, get_modifiedonly=False): if not self.current_record: Index: tryton/gui/window/view_form/view/form.py === --- a/tryton/gui/window/view_form/view/form.py +++ b/tryton/gui/window/view_form/view/form.py @@ -121,14 +121,9 @@ button.state_set(record) return True -def set_cursor(self, new=False, reset_view=True): -if reset_view: -for notebook in self.notebooks: -notebook.set_current_page(0) -if self.cursor_widget in self.widgets: -self.widgets[self.cursor_widget][0].grab_focus() +@property +def focusable_widget(self): record = self.screen.current_record -position = reduce(lambda x, y: x + len(y), self.widgets, 0) focus_widget = None if record: for name, widgets in self.widgets.iteritems(): @@ -141,10 +136,20 @@ continue position = widget.position focus_widget = widget -if focus_widget: +return focus_widget + +def set_cursor(self, new=False, reset_view=True): +if reset_view: +for notebook in self.notebooks: +notebook.set_current_page(0) +if self.cursor_widget in self.widgets: +self.widgets[self.cursor_widget][0].grab_focus() +record = self.screen.current_record +position = reduce(lambda x, y: x + len(y), self.widgets, 0) +if self.focusable_widget: for notebook in self.notebooks: for i in range(notebook.get_n_pages()): child = notebook.get_nth_page(i) -if focus_widget.widget.is_ancestor(child): +if self.focusable_widget.widget.is_ancestor(child): notebook.set_current_page(i) -focus_widget.grab_focus() +self.focusable_widget.grab_focus() Index: tryton/gui/window/window.py === --- a/tryton/gui/window/window.py +++ b/tryton/gui/window/window.py @@ -41,6 +41,7 @@ win.icon = icon Main.get_main().win_add(win, hide_current=Window.hide_current, allow_similar=Window.allow_similar) +win.grab_focus() @staticmethod def create_wizard(action, data, state='init', direct_print=False, -- tryton-dev@googlegroups.com mailing list
[tryton-dev] sale: Add default database language code (issue198003)
Reviewers: , Please review this at http://codereview.tryton.org/198003/ Affected files: M sale.py Index: sale.py === --- a/sale.py +++ b/sale.py @@ -12,6 +12,7 @@ from trytond.pyson import If, Eval, Bool, PYSONEncoder from trytond.transaction import Transaction from trytond.pool import Pool +from trytond.config import CONFIG class Sale(ModelWorkflow, ModelSQL, ModelView): @@ -316,7 +317,7 @@ party = party_obj.browse(vals['party']) if party.lang: return party.lang.code -return 'en_US' +return CONFIG['language'] def get_party_lang(self, sales): ''' @@ -331,7 +332,7 @@ if sale.party.lang: res[sale.id] = sale.party.lang.code else: -res[sale.id] = 'en_US' +res[sale.id] = CONFIG['language'] return res -- tryton-dev@googlegroups.com mailing list
[tryton-dev] purchase: Add default database language code (issue202001)
Reviewers: , Please review this at http://codereview.tryton.org/202001/ Affected files: M purchase.py Index: purchase.py === --- a/purchase.py +++ b/purchase.py @@ -10,6 +10,7 @@ from trytond.pyson import Eval, Bool, If, PYSONEncoder from trytond.transaction import Transaction from trytond.pool import Pool +from trytond.config import CONFIG _STATES = { 'readonly': Eval('state') != 'draft', @@ -269,7 +270,7 @@ party = party_obj.browse(vals['party']) if party.lang: return party.lang.code -return 'en_US' +return CONFIG['language'] def get_tax_context(self, purchase): party_obj = Pool().get('party.party') @@ -378,7 +379,7 @@ if purchase.party.lang: res[purchase.id] = purchase.party.lang.code else: -res[purchase.id] = 'en_US' +res[purchase.id] = CONFIG['language'] return res def get_untaxed_amount(self, purchases): -- tryton-dev@googlegroups.com mailing list
[tryton-dev] currency: Add default database language code (issue199002)
Reviewers: , Please review this at http://codereview.tryton.org/199002/ Affected files: M currency.py Index: currency.py === --- a/currency.py +++ b/currency.py @@ -204,13 +204,10 @@ else: name = to_currency.name -for code in [Transaction().language, 'en_US']: -lang_ids = lang_obj.search([ -('code', '=', code), +lang_id, = lang_obj.search([ +('code', '=', Transaction().language), ]) -if lang_ids: -break -lang = lang_obj.browse(lang_ids[0]) +lang = lang_obj.browse(lang_id) self.raise_user_error('no_rate', (name, datetime_strftime(date, str(lang.date -- tryton-dev@googlegroups.com mailing list
[tryton-dev] account_statement: Add default database language code (issue201001)
Reviewers: , Please review this at http://codereview.tryton.org/201001/ Affected files: M statement.py Index: statement.py === --- a/statement.py +++ b/statement.py @@ -148,13 +148,10 @@ if not ids: return {} -for code in [Transaction().language, 'en_US']: -lang_ids = lang_obj.search([ -('code', '=', code), +lang_id, = lang_obj.search([ +('code', '=', Transaction().language), ]) -if lang_ids: -break -lang = lang_obj.browse(lang_ids[0]) +lang = lang_obj.browse(lang_id) res = {} for statement in self.browse(ids): @@ -266,13 +263,10 @@ for line in statement.lines: computed_end_balance += line.amount if computed_end_balance != statement.end_balance: -for code in [Transaction().language, 'en_US']: -lang_ids = lang_obj.search([ -('code', '=', code), +lang_id, = lang_obj.search([ +('code', '=', Transaction().language), ]) -if lang_ids: -break -lang = lang_obj.browse(lang_ids[0]) +lang = lang_obj.browse(lang_id) amount = lang_obj.format(lang, '%.' + str(statement.journal.currency.digits) + 'f', @@ -462,13 +456,10 @@ line.invoice.amount_to_pay, line.statement.journal.currency.id) if amount_to_pay < abs(line.amount): -for code in [Transaction().language, 'en_US']: -lang_ids = lang_obj.search([ -('code', '=', code), +lang_id, = lang_obj.search([ +('code', '=', Transaction().language), ]) -if lang_ids: -break -lang = lang_obj.browse(lang_ids[0]) +lang = lang_obj.browse(lang_id) amount = lang_obj.format(lang, '%.' + str(line.statement.journal.currency.digits) + 'f', -- tryton-dev@googlegroups.com mailing list
[tryton-dev] account_invoice: Add default database language code (issue198002)
Reviewers: , Please review this at http://codereview.tryton.org/198002/ Affected files: M invoice.py Index: invoice.py === --- a/invoice.py +++ b/invoice.py @@ -11,6 +11,7 @@ from trytond.tools import reduce_ids from trytond.transaction import Transaction from trytond.pool import Pool +from trytond.config import CONFIG _STATES = { 'readonly': Eval('state') != 'draft', @@ -337,7 +338,7 @@ party = party_obj.browse(vals['party']) if party.lang: return party.lang.code -return 'en_US' +return CONFIG['language'] def get_party_language(self, ids, name): ''' @@ -353,7 +354,7 @@ if invoice.party.lang: res[invoice.id] = invoice.party.lang.code else: -res[invoice.id] = 'en_US' +res[invoice.id] = CONFIG['language'] return res def get_type_name(self, ids, name): @@ -1461,7 +1462,7 @@ party = party_obj.browse(vals['party']) if party.lang: return party.lang.code -return 'en_US' +return CONFIG['language'] def get_party_language(self, ids, name): ''' @@ -1477,7 +1478,7 @@ if line.party and line.party.lang: res[line.id] = line.party.lang.code else: -res[line.id] = 'en_US' +res[line.id] = CONFIG['language'] return res def on_change_with_amount(self, vals): -- tryton-dev@googlegroups.com mailing list
[tryton-dev] account: Add default database language code (issue200001)
Reviewers: , Please review this at http://codereview.tryton.org/21/ Affected files: M account.py M move.py M tax.py Index: account.py === --- a/account.py +++ b/account.py @@ -10,6 +10,7 @@ from trytond.pyson import Eval, PYSONEncoder, Date from trytond.transaction import Transaction from trytond.pool import Pool +from trytond.config import CONFIG class TypeTemplate(ModelSQL, ModelView): @@ -114,7 +115,7 @@ new_id = type_obj.create(vals) -prev_lang = template._context.get('language') or 'en_US' +prev_lang = template._context.get('language') or CONFIG['language'] prev_data = {} for field_name, field in template._columns.iteritems(): if getattr(field, 'translate', False): @@ -279,7 +280,7 @@ if vals: self.write(type.id, vals) -prev_lang = type._context.get('language') or 'en_US' +prev_lang = type._context.get('language') or CONFIG['language'] prev_data = {} for field_name, field in type.template._columns.iteritems(): if getattr(field, 'translate', False): @@ -440,7 +441,7 @@ new_id = account_obj.create(vals) -prev_lang = template._context.get('language') or 'en_US' +prev_lang = template._context.get('language') or CONFIG['language'] prev_data = {} for field_name, field in template._columns.iteritems(): if getattr(field, 'translate', False): @@ -914,7 +915,7 @@ if vals: self.write(account.id, vals) -prev_lang = account._context.get('language') or 'en_US' +prev_lang = account._context.get('language') or CONFIG['language'] prev_data = {} for field_name, field in account.template._columns.iteritems(): if getattr(field, 'translate', False): @@ -1496,13 +1497,10 @@ lang_obj = pool.get('ir.lang') company = company_obj.browse(datas['form']['company']) -for code in [Transaction().language, 'en_US']: -lang_ids = lang_obj.search([ -('code', '=', code), +lang_id, = lang_obj.search([ +('code', '=', Transaction().language), ]) -if lang_ids: -break -lang = lang_obj.browse(lang_ids[0]) +lang = lang_obj.browse(lang_id) date = lang_obj.strftime(datas['form']['date'], lang.code, lang.date) @@ -1735,7 +1733,7 @@ tax_rule_line_template_obj = \ pool.get('account.tax.rule.line.template') -with Transaction().set_context(language='en_US'): +with Transaction().set_context(language=CONFIG['language']): account_template = account_template_obj.browse( datas['form']['account_template']) Index: move.py === --- a/move.py +++ b/move.py @@ -15,6 +15,7 @@ from trytond.pyson import Eval, PYSONEncoder from trytond.transaction import Transaction from trytond.pool import Pool +from trytond.config import CONFIG _MOVE_STATES = { 'readonly': Eval('state') == 'posted', @@ -1249,10 +1250,10 @@ account = line.account amount = currency_obj.round(account.currency, amount) period_id = period_obj.find(account.company.id, date=date) -lang_code = 'en_US' +lang_code = CONFIG['language'] if account.company.lang: lang_code = account.company.lang.code -writeoff = translation_obj._get_source( +writeoff = translation_obj.get_source( 'account.move.reconcile_lines.writeoff', 'view', lang_code, 'Write-Off') or 'Write-Off' move_id = move_obj.create({ Index: tax.py === --- a/tax.py +++ b/tax.py @@ -8,6 +8,7 @@ from trytond.transaction import Transaction from trytond.cache import Cache from trytond.pool import Pool +from trytond.config import CONFIG class Group(ModelSQL, ModelView): @@ -104,7 +105,7 @@ new_id = tax_code_obj.create(vals) -prev_lang = template._context.get('language') or 'en_US' +prev_lang = template._context.get('language') or CONFIG['language'] prev_data = {} for field_name, field in template._columns.iteritems(): if getattr(field, 'translate', False): @@ -274,7 +275,7 @@ if vals: self.write(code.id, vals) -prev_lang = code._context.get('language') or 'en_US' +prev_lang = code._context.get('language') or CONFIG['language'] prev_data = {} for field_name, field in code.template._columns.iteri
[tryton-dev] tryton: Improve translate feature for issue2224 and add support for fuzzy_translation (issue199001)
Reviewers: , Please review this at http://codereview.tryton.org/199001/ Affected files: M tryton/gui/window/view_form/view/form_gtk/char.py M tryton/gui/window/view_form/view/form_gtk/interface.py M tryton/gui/window/view_form/view/form_gtk/parser.py M tryton/gui/window/view_form/view/form_gtk/textbox.py -- tryton-dev@googlegroups.com mailing list
[tryton-dev] trytond: Add default database language code and remove underscore to ir.translation methods (issue198001)
Reviewers: , Please review this at http://codereview.tryton.org/198001/ Affected files: M CHANGELOG M etc/trytond.conf M trytond/config.py M trytond/convert.py M trytond/error.py M trytond/ir/cron.py M trytond/ir/lang.py M trytond/ir/model.py M trytond/ir/translation.py M trytond/model/browse.py M trytond/model/model.py M trytond/model/modelsql.py M trytond/model/modelstorage.py M trytond/model/modelview.py M trytond/modules/__init__.py M trytond/protocols/dispatcher.py M trytond/res/user.py M trytond/tools/misc.py M trytond/transaction.py M trytond/wizard/wizard.py -- tryton-dev@googlegroups.com mailing list