diff --git a/addons/account/report/account_aged_partner_balance.py b/addons/account/report/account_aged_partner_balance.py index 897b8366b7a..3b000e40592 100644 --- a/addons/account/report/account_aged_partner_balance.py +++ b/addons/account/report/account_aged_partner_balance.py @@ -366,12 +366,13 @@ class aged_trial_report(report_sxw.rml_parse, common_report_header): return period or 0.0 def _get_partners(self,data): + # TODO: deprecated, to remove in trunk if data['form']['result_selection'] == 'customer': - return 'Receivable Accounts' + return self._translate('Receivable Accounts') elif data['form']['result_selection'] == 'supplier': - return 'Payable Accounts' + return self._translate('Payable Accounts') elif data['form']['result_selection'] == 'customer_supplier': - return 'Receivable and Payable Accounts' + return self._translate('Receivable and Payable Accounts') return '' report_sxw.report_sxw('report.account.aged_trial_balance', 'res.partner', diff --git a/addons/account/report/account_aged_partner_balance.rml b/addons/account/report/account_aged_partner_balance.rml index fb79ab0d199..5b5404e9c86 100644 --- a/addons/account/report/account_aged_partner_balance.rml +++ b/addons/account/report/account_aged_partner_balance.rml @@ -147,7 +147,9 @@ [[ data['form']['period_length'] ]] - [[ get_partners(data) ]] + Receivable Accounts[[ data['form']['result_selection'] == 'customer' or removeParentNode('para') ]] + Payable Accounts[[ data['form']['result_selection'] == 'supplier' or removeParentNode('para') ]] + Receivable and Payable Accounts[[ data['form']['result_selection'] == 'customer_supplier' or removeParentNode('para') ]] [[ data['form']['direction_selection'] ]] @@ -166,7 +168,8 @@ Partners - [[ data['form']['direction_selection'] == 'future' and 'Due' or 'Not due' ]] + Due[[ data['form']['direction_selection'] == 'future' and ' ' or removeParentNode('para') ]] + Not due[[ data['form']['direction_selection'] != 'future' and ' ' or removeParentNode('para') ]] [[ data['form']['4']['name'] ]] diff --git a/addons/account/report/account_balance.rml b/addons/account/report/account_balance.rml index 88980a9cd97..6ddfc238bff 100644 --- a/addons/account/report/account_balance.rml +++ b/addons/account/report/account_balance.rml @@ -211,8 +211,10 @@ - [[ data['model']=='account.account' and 'Company'or removeParentNode('para') ]] - [[ data['model']=='ir.ui.menu' and 'Chart of Accounts' or removeParentNode('para') ]] + + Company[[ data['model']=='account.account' and ' ' or removeParentNode('para') ]] + Chart of Accounts[[ data['model']=='ir.ui.menu' and ' ' or removeParentNode('para') ]] + Fiscal Year @@ -233,7 +235,11 @@ [[ get_fiscalyear(data) or '' ]] - [[ (data['form']['display_account']=='all' and 'All') or (data['form']['display_account']=='movement' and 'With movements') or 'With balance is not equal to 0']] + + All[[ data['form']['display_account']=='all' and ' ' or removeParentNode('para') ]] + With movements[[ data['form']['display_account']=='movement' and ' ' or removeParentNode('para') ]] + With balance is not equal to 0[[ data['form']['display_account']=='not_zero' and ' ' or removeParentNode('para') ]] + [[ data['form']['filter']=='filter_no' and get_filter(data) or removeParentNode('para') ]] [[ data['form']['filter']=='filter_date' or removeParentNode('blockTable') ]] diff --git a/addons/account/report/account_general_journal.rml b/addons/account/report/account_general_journal.rml index 4ad086d6bd4..dce30e59918 100644 --- a/addons/account/report/account_general_journal.rml +++ b/addons/account/report/account_general_journal.rml @@ -220,8 +220,8 @@ - [[ data['model']=='account.journal.period' and 'Company' or removeParentNode('para') ]] - [[ data['model']=='ir.ui.menu' and 'Chart of Accounts' or removeParentNode('para') ]] + Company[[ data['model']=='account.journal.period' and ' ' or removeParentNode('para') ]] + Chart of Accounts[[ data['model']=='ir.ui.menu' and ' ' or removeParentNode('para') ]] Fiscal Year Journals Filter By [[ data['form']['filter']!='filter_no' and get_filter(data) ]] diff --git a/addons/account/report/account_general_ledger_landscape.rml b/addons/account/report/account_general_ledger_landscape.rml index 7ae5db98f20..c5d24343148 100644 --- a/addons/account/report/account_general_ledger_landscape.rml +++ b/addons/account/report/account_general_ledger_landscape.rml @@ -360,9 +360,8 @@ - [[ data['model']=='account.account' and 'Company' or removeParentNode('para') ]] - [[ data['model']=='ir.ui.menu' and 'Chart of Accounts' or removeParentNode('para') ]] - + Company[[ data['model']=='account.account' and ' ' or removeParentNode('para') ]] + Chart of Accounts[[ data['model']=='ir.ui.menu' and ' ' or removeParentNode('para') ]] Fiscal Year @@ -395,7 +394,9 @@ [[', '.join([ lt or '' for lt in get_journal(data) ]) ]] - [[ (data['form']['display_account']=='all' and 'All') or (data['form']['display_account']=='movement' and 'With movements') or 'With balance is not equal to 0']] + All[[ data['form']['display_account']=='all' and ' ' or removeParentNode('para') ]] + With movements[[ data['form']['display_account']=='movement' and ' ' or removeParentNode('para') ]] + With balance is not equal to 0[[ data['form']['display_account']=='not_zero' and ' ' or removeParentNode('para') ]] [[ data['form']['filter']=='filter_no' and get_filter(data) or removeParentNode('para') ]] diff --git a/addons/account/report/account_journal.py b/addons/account/report/account_journal.py index 769a8335f55..97e19be4b0c 100644 --- a/addons/account/report/account_journal.py +++ b/addons/account/report/account_journal.py @@ -189,11 +189,12 @@ class journal_print(report_sxw.rml_parse, common_report_header): return data['form']['amount_currency'] def _get_sortby(self, data): + # TODO: deprecated, to remove in trunk if self.sort_selection == 'date': - return 'Date' + return self._translate('Date') elif self.sort_selection == 'ref': - return 'Reference Number' - return 'Date' + return self._translate('Reference Number') + return self._translate('Date') report_sxw.report_sxw('report.account.journal.period.print', 'account.journal.period', 'addons/account/report/account_journal.rml', parser=journal_print, header='external') report_sxw.report_sxw('report.account.journal.period.print.sale.purchase', 'account.journal.period', 'addons/account/report/account_journal_sale_purchase.rml', parser=journal_print, header='external') diff --git a/addons/account/report/account_journal.rml b/addons/account/report/account_journal.rml index fb203d4e664..6d606ed1937 100644 --- a/addons/account/report/account_journal.rml +++ b/addons/account/report/account_journal.rml @@ -186,8 +186,8 @@ - [[ data['model']=='account.journal.period'and 'Company' or removeParentNode('para') ]] - [[ data['model']=='ir.ui.menu' and 'Chart of Accounts' or removeParentNode('para') ]] + Company[[ data['model']=='account.journal.period'and ' ' or removeParentNode('para') ]] + Chart of Accounts[[ data['model']=='ir.ui.menu' and ' ' or removeParentNode('para') ]] Fiscal Year Journal Period @@ -199,8 +199,10 @@ [[ get_fiscalyear(data) or '' ]] [[ o.journal_id.name ]] [[ o.period_id.name ]] - [[ get_sortby(data) ]] - [[ get_target_move(data) ]] + + Date[[ data['form'].get('sort_selection', 'date') == 'date' and ' ' or removeParentNode('para') ]] + Reference Number[[ data['form'].get('sort_selection', 'date') == 'ref' and ' ' or removeParentNode('para') ]] + diff --git a/addons/account/report/account_partner_ledger.py b/addons/account/report/account_partner_ledger.py index 21c1ee3d846..d21323e02fc 100644 --- a/addons/account/report/account_partner_ledger.py +++ b/addons/account/report/account_partner_ledger.py @@ -267,12 +267,13 @@ class third_party_ledger(report_sxw.rml_parse, common_report_header): return result_tmp + result_init def _get_partners(self): + # TODO: deprecated, to remove in trunk if self.result_selection == 'customer': - return 'Receivable Accounts' + return _('Receivable Accounts') elif self.result_selection == 'supplier': - return 'Payable Accounts' + return _('Payable Accounts') elif self.result_selection == 'customer_supplier': - return 'Receivable and Payable Accounts' + return _('Receivable and Payable Accounts') return '' def _sum_currency_amount_account(self, account, form): diff --git a/addons/account/report/account_partner_ledger.rml b/addons/account/report/account_partner_ledger.rml index 0d7122369c6..48ed6d4afe3 100644 --- a/addons/account/report/account_partner_ledger.rml +++ b/addons/account/report/account_partner_ledger.rml @@ -423,7 +423,9 @@ - [[ get_partners() ]] + Receivable Accounts[[ data['form'].get('result_selection', 'customer') == 'customer' or removeParentNode('para') ]] + Payable Accounts[[ data['form'].get('result_selection', 'customer') == 'supplier' or removeParentNode('para') ]] + Receivable and Payable Accounts[[ data['form'].get('result_selection', 'customer') == 'customer_supplier' or removeParentNode('para') ]] [[ get_target_move(data) ]] diff --git a/addons/account/static/src/js/account_move_line_quickadd.js b/addons/account/static/src/js/account_move_line_quickadd.js index 997b2b03bb6..0b904e19da6 100644 --- a/addons/account/static/src/js/account_move_line_quickadd.js +++ b/addons/account/static/src/js/account_move_line_quickadd.js @@ -84,7 +84,7 @@ openerp.account.quickadd = function (instance) { }, search_by_journal_period: function() { var self = this; - var domain = []; + var domain = ['|',['debit', '!=', 0], ['credit', '!=', 0]]; if (self.current_journal !== null) domain.push(["journal_id", "=", self.current_journal]); if (self.current_period !== null) domain.push(["period_id", "=", self.current_period]); self.last_context["journal_id"] = self.current_journal === null ? false : self.current_journal; diff --git a/addons/account/wizard/account_report_common.py b/addons/account/wizard/account_report_common.py index c457140684a..871aea9e4d9 100644 --- a/addons/account/wizard/account_report_common.py +++ b/addons/account/wizard/account_report_common.py @@ -175,7 +175,7 @@ class account_common_report(osv.osv_memory): data['form'][field] = data['form'][field][0] used_context = self._build_contexts(cr, uid, ids, data, context=context) data['form']['periods'] = used_context.get('periods', False) and used_context['periods'] or [] - data['form']['used_context'] = used_context + data['form']['used_context'] = dict(used_context, lang=context.get('lang', 'en_US')) return self._print_report(cr, uid, ids, data, context=context) diff --git a/addons/account_analytic_plans/account_analytic_plans_view.xml b/addons/account_analytic_plans/account_analytic_plans_view.xml index 7fb4091b45f..42b17ae06c3 100644 --- a/addons/account_analytic_plans/account_analytic_plans_view.xml +++ b/addons/account_analytic_plans/account_analytic_plans_view.xml @@ -248,9 +248,12 @@ account.analytic.default - + + 1 + + - + diff --git a/addons/account_anglo_saxon/purchase.py b/addons/account_anglo_saxon/purchase.py index c10a2a97d80..fc36dab41c2 100644 --- a/addons/account_anglo_saxon/purchase.py +++ b/addons/account_anglo_saxon/purchase.py @@ -26,16 +26,15 @@ class purchase_order(osv.osv): _inherit = "purchase.order" _description = "Purchase Order" - def _prepare_inv_line(self, cr, uid, account_id, order_line, context=None): - line = super(purchase_order, self)._prepare_inv_line(cr, uid, account_id, order_line, context=context) + def _choose_account_from_po_line(self, cr, uid, order_line, context=None): + account_id = super(purchase_order, self)._choose_account_from_po_line(cr, uid, order_line, context=context) if order_line.product_id and not order_line.product_id.type == 'service': acc_id = order_line.product_id.property_stock_account_input and order_line.product_id.property_stock_account_input.id if not acc_id: acc_id = order_line.product_id.categ_id.property_stock_account_input_categ and order_line.product_id.categ_id.property_stock_account_input_categ.id if acc_id: fpos = order_line.order_id.fiscal_position or False - new_account_id = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, acc_id) - line.update({'account_id': new_account_id}) - return line + account_id = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, acc_id) + return account_id # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 81eb76ff3a8..35c9163619a 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -932,6 +932,8 @@ class account_voucher(osv.osv): move_pool = self.pool.get('account.move') for voucher in self.browse(cr, uid, ids, context=context): + # refresh to make sure you don't unlink an already removed move + voucher.refresh() recs = [] for line in voucher.move_ids: if line.reconcile_id: diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index 896349ec5e6..a9061c0afce 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -1510,7 +1510,7 @@ rule or repeating pattern of time to exclude from the recurring rule."), continue if r['class']=='private': for f in r.keys(): - if f not in ('id','date','date_deadline','duration','user_id','state'): + if f not in ('id','date','date_deadline','duration','user_id','state','interval','count'): if isinstance(r[f], list): r[f] = [] else: diff --git a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ExportToRML.py b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ExportToRML.py index a12becdc68c..669c8b8fb84 100644 --- a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ExportToRML.py +++ b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ExportToRML.py @@ -1,7 +1,7 @@ ######################################################################### # # Copyright (c) 2003-2004 Danny Brewer d29583@groovegarden.com -# Copyright (C) 2004-2010 OpenERP SA (). +# Copyright (C) 2004-2013 OpenERP SA (). # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -78,7 +78,7 @@ class ExportToRML( unohelper.Base, XJobExecutor ): res = self.sock.execute(database, uid, self.password, 'ir.actions.report.xml', 'sxwtorml',base64.encodestring(data),file_type) if res['report_rml_content']: - write_data_to_file( get_absolute_file_path( filename[7:] ), res['report_rml_content'] ) + write_data_to_file(get_absolute_file_path(filename), res['report_rml_content']) except Exception,e: import traceback,sys info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) @@ -99,8 +99,12 @@ class ExportToRML( unohelper.Base, XJobExecutor ): oFileDialog.setDefaultName(f_path ) - sPath = oFileDialog.execute() == 1 and oFileDialog.Files[0] or None + sPath = oFileDialog.execute() == 1 and oFileDialog.Files[0] or '' oFileDialog.dispose() + sPath = sPath[7:] + if sPath.startswith('localhost/'): + slash = int(os.name == 'nt') + sPath = sPath[9 + slash:] return sPath if __name__<>"package" and __name__=="__main__": diff --git a/addons/base_report_designer/static/base-report-designer-plugin/openerp_report_designer.zip b/addons/base_report_designer/static/base-report-designer-plugin/openerp_report_designer.zip index 238f9d19671..2fc61fbf679 100644 Binary files a/addons/base_report_designer/static/base-report-designer-plugin/openerp_report_designer.zip and b/addons/base_report_designer/static/base-report-designer-plugin/openerp_report_designer.zip differ diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 0256eba517e..57277debc28 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -96,13 +96,11 @@ class crm_lead(base_stage, format_address, osv.osv): def create(self, cr, uid, vals, context=None): if context is None: context = {} - if not vals.get('stage_id'): - ctx = context.copy() - if vals.get('section_id'): - ctx['default_section_id'] = vals['section_id'] - if vals.get('type'): - ctx['default_type'] = vals['type'] - vals['stage_id'] = self._get_default_stage_id(cr, uid, context=ctx) + if vals.get('type') and not context.get('default_type'): + context['default_type'] = vals.get('type') + if vals.get('section_id') and not context.get('default_section_id'): + context['default_section_id'] = vals.get('section_id') + # context: no_log, because subtype already handle this create_context = dict(context, mail_create_nolog=True) return super(crm_lead, self).create(cr, uid, vals, context=create_context) @@ -369,12 +367,11 @@ class crm_lead(base_stage, format_address, osv.osv): def on_change_user(self, cr, uid, ids, user_id, context=None): """ When changing the user, also set a section_id or restrict section id to the ones user_id is member of. """ - section_id = False if user_id: section_ids = self.pool.get('crm.case.section').search(cr, uid, ['|', ('user_id', '=', user_id), ('member_ids', '=', user_id)], context=context) if section_ids: - section_id = section_ids[0] - return {'value': {'section_id': section_id}} + return {'value': {'section_id': section_ids[0]}} + return {'value': {}} def _check(self, cr, uid, ids=False, context=None): """ Override of the base.stage method. diff --git a/addons/crm/crm_phonecall_menu.xml b/addons/crm/crm_phonecall_menu.xml index 2344604a294..f6f94547173 100644 --- a/addons/crm/crm_phonecall_menu.xml +++ b/addons/crm/crm_phonecall_menu.xml @@ -58,7 +58,7 @@ tree,calendar [] - {} + {'default_state': 'done'}

diff --git a/addons/crm/res_partner.py b/addons/crm/res_partner.py index f25b1303c02..fca9222082d 100644 --- a/addons/crm/res_partner.py +++ b/addons/crm/res_partner.py @@ -56,7 +56,7 @@ class res_partner(osv.osv): default.update({'opportunity_ids': [], 'meeting_ids' : [], 'phonecall_ids' : []}) - super(res_partner, self).copy(cr, uid, record_id, default, context) + return super(res_partner, self).copy(cr, uid, record_id, default, context) def redirect_partner_form(self, cr, uid, partner_id, context=None): search_view = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'base', 'view_res_partner_filter') diff --git a/addons/document_page/document_page.py b/addons/document_page/document_page.py index f74cfe02a21..7f885018001 100644 --- a/addons/document_page/document_page.py +++ b/addons/document_page/document_page.py @@ -66,7 +66,7 @@ class document_page(osv.osv): 'create_date': fields.datetime("Created on", select=True, readonly=True), 'create_uid': fields.many2one('res.users', 'Author', select=True, readonly=True), 'write_date': fields.datetime("Modification Date", select=True, readonly=True), - 'write_uid': fields.many2one('res.users', "Last Contributor", select=True), + 'write_uid': fields.many2one('res.users', "Last Contributor", select=True, readonly=True), } _defaults = { 'type':'content', diff --git a/addons/email_template/wizard/mail_compose_message.py b/addons/email_template/wizard/mail_compose_message.py index 746c2cc55f6..92187e97b47 100644 --- a/addons/email_template/wizard/mail_compose_message.py +++ b/addons/email_template/wizard/mail_compose_message.py @@ -155,7 +155,8 @@ class mail_compose_message(osv.TransientModel): values['body'] = values.pop('body_html', '') # transform email_to, email_cc into partner_ids - partner_ids = self._get_or_create_partners_from_values(cr, uid, values, context=context) + ctx = dict((k, v) for k, v in (context or {}).items() if not k.startswith('default_')) + partner_ids = self._get_or_create_partners_from_values(cr, uid, values, context=ctx) # legacy template behavior: void values do not erase existing values and the # related key is removed from the values dict if partner_ids: diff --git a/addons/hr_expense/hr_expense_view.xml b/addons/hr_expense/hr_expense_view.xml index a383f72e2ab..0d9e2a247fd 100644 --- a/addons/hr_expense/hr_expense_view.xml +++ b/addons/hr_expense/hr_expense_view.xml @@ -86,7 +86,7 @@ - +

diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 4fdf9a3b8bf..830693aed22 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -240,7 +240,7 @@ class hr_applicant(base_stage, osv.Model): _defaults = { 'active': lambda *a: 1, - 'user_id': lambda s, cr, uid, c: uid, + 'user_id': lambda s, cr, uid, c: uid, 'email_from': lambda s, cr, uid, c: s._get_default_email(cr, uid, c), 'stage_id': lambda s, cr, uid, c: s._get_default_stage_id(cr, uid, c), 'department_id': lambda s, cr, uid, c: s._get_default_department_id(cr, uid, c), @@ -253,13 +253,11 @@ class hr_applicant(base_stage, osv.Model): } def onchange_job(self, cr, uid, ids, job, context=None): - result = {} - if job: - job_obj = self.pool.get('hr.job') - result['department_id'] = job_obj.browse(cr, uid, job, context=context).department_id.id - return {'value': result} - return {'value': {'department_id': False}} + job_record = self.pool.get('hr.job').browse(cr, uid, job, context=context) + if job_record and job_record.department_id: + return {'value': {'department_id': job_record.department_id.id}} + return {} def onchange_department_id(self, cr, uid, ids, department_id=False, context=None): obj_recru_stage = self.pool.get('hr.recruitment.stage') @@ -401,6 +399,11 @@ class hr_applicant(base_stage, osv.Model): return super(hr_applicant, self).message_update(cr, uid, ids, msg, update_vals=update_vals, context=context) def create(self, cr, uid, vals, context=None): + if context is None: + context = {} + if vals.get('department_id') and not context.get('default_department_id'): + context['default_department_id'] = vals.get('department_id') + obj_id = super(hr_applicant, self).create(cr, uid, vals, context=context) applicant = self.browse(cr, uid, obj_id, context=context) if applicant.job_id: diff --git a/addons/hr_recruitment/hr_recruitment_view.xml b/addons/hr_recruitment/hr_recruitment_view.xml index 716c1cba8d5..c8bfd0a444e 100644 --- a/addons/hr_recruitment/hr_recruitment_view.xml +++ b/addons/hr_recruitment/hr_recruitment_view.xml @@ -187,6 +187,7 @@ + diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py index 6c4f6022c39..b950b85ac48 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py @@ -173,7 +173,10 @@ class account_analytic_line(osv.osv): data = {} journal_types = {} + price = 0.0 for line in self.pool.get('account.analytic.line').browse(cr, uid, ids, context=context): + price += line.amount*-1 + line_name = line.name if line.journal_id.type not in journal_types: journal_types[line.journal_id.type] = set() journal_types[line.journal_id.type].add(line.account_id.id) @@ -204,7 +207,6 @@ class account_analytic_line(osv.osv): 'date_due': date_due, 'fiscal_position': account.partner_id.property_account_position.id } - context2 = context.copy() context2['lang'] = partner.lang # set company_id in context, so the correct default journal will be selected @@ -225,36 +227,42 @@ class account_analytic_line(osv.osv): if data.get('product'): product_id = data['product'][0] product = product_obj.browse(cr, uid, product_id, context=context2) - if not product: - raise osv.except_osv(_('Error!'), _('There is no product defined. Please select one or force the product through the wizard.')) factor = invoice_factor_obj.browse(cr, uid, factor_id, context=context2) - factor_name = product_obj.name_get(cr, uid, [product_id], context=context2)[0][1] - if factor.customer_name: - factor_name += ' - ' + factor.customer_name - - ctx = context.copy() - ctx.update({'uom':uom}) - - price = self._get_invoice_price(cr, uid, account, product_id, user_id, qty, ctx) - - general_account = product.property_account_income or product.categ_id.property_account_income_categ - if not general_account: - raise osv.except_osv(_("Configuration Error!"), _("Please define income account for product '%s'.") % product.name) - taxes = product.taxes_id or general_account.tax_ids - tax = fiscal_pos_obj.map_tax(cr, uid, account.partner_id.property_account_position, taxes) + factor_name = factor.customer_name and line_name + ' - ' + factor.customer_name or line_name curr_line = { 'price_unit': price, 'quantity': qty, - 'discount':factor.factor, - 'invoice_line_tax_id': [(6,0,tax )], + 'discount': factor.factor, 'invoice_id': last_invoice, 'name': factor_name, - 'product_id': product_id, - 'invoice_line_tax_id': [(6,0,tax)], 'uos_id': uom, - 'account_id': general_account.id, 'account_analytic_id': account.id, } + if product: + factor_name = product_obj.name_get(cr, uid, [product_id], context=context2)[0][1] + if factor.customer_name: + factor_name += ' - ' + factor.customer_name + + ctx = context.copy() + ctx.update({'uom': uom}) + + # check force product + if data.get('product'): + price = self._get_invoice_price(cr, uid, account, product_id, user_id, qty, ctx) + + general_account = product.property_account_income or product.categ_id.property_account_income_categ + if not general_account: + raise osv.except_osv(_("Configuration Error!"), _("Please define income account for product '%s'.") % product.name) + taxes = product.taxes_id or general_account.tax_ids + tax = fiscal_pos_obj.map_tax(cr, uid, account.partner_id.property_account_position, taxes) + curr_line.update({ + 'price_unit': price, + 'invoice_line_tax_id': [(6,0,tax )], + 'name': factor_name, + 'product_id': product_id, + 'invoice_line_tax_id': [(6,0,tax)], + 'account_id': general_account.id, + }) # # Compute for lines diff --git a/addons/idea/idea_view.xml b/addons/idea/idea_view.xml index 53734d53919..9c99100c1cd 100644 --- a/addons/idea/idea_view.xml +++ b/addons/idea/idea_view.xml @@ -114,7 +114,6 @@ - diff --git a/addons/l10n_be_coda/wizard/account_coda_import.py b/addons/l10n_be_coda/wizard/account_coda_import.py index 8aabe601bc8..aed99345fba 100644 --- a/addons/l10n_be_coda/wizard/account_coda_import.py +++ b/addons/l10n_be_coda/wizard/account_coda_import.py @@ -117,6 +117,8 @@ class account_coda_import(osv.osv_memory): # and so a 'like' operator would return the first account number in the database which matches. cr.execute("select id from res_partner_bank where replace(replace(acc_number,' ',''),'-','') = %s", (statement['acc_number'],)) bank_ids = [id[0] for id in cr.fetchall()] + # Filter bank accounts which are not allowed + bank_ids = self.pool.get('res.partner.bank').search(cr, uid, [('id', 'in', bank_ids)]) if bank_ids and len(bank_ids) > 0: bank_accs = self.pool.get('res.partner.bank').browse(cr, uid, bank_ids) for bank_acc in bank_accs: @@ -248,7 +250,7 @@ class account_coda_import(osv.osv_memory): elif line[0] == '9': statement['balanceMin'] = float(rmspaces(line[22:37])) / 1000 statement['balancePlus'] = float(rmspaces(line[37:52])) / 1000 - if not statement['balance_end_real']: + if not statement.get('balance_end_real'): statement['balance_end_real'] = statement['balance_start'] + statement['balancePlus'] - statement['balanceMin'] for i, statement in enumerate(statements): statement['coda_note'] = '' @@ -266,6 +268,8 @@ class account_coda_import(osv.osv_memory): raise osv.except_osv(_('Error'), _("Configuration Error in journal %s!\nPlease verify the Default Debit and Credit Account settings.") % statement['journal_id'].name) if balance_start_check != statement['balance_start']: statement['coda_note'] = _("The CODA Statement %s Starting Balance (%.2f) does not correspond with the previous Closing Balance (%.2f) in journal %s!") % (statement['description'] + ' #' + statement['paperSeqNumber'], statement['balance_start'], balance_start_check, statement['journal_id'].name) + if not(statement.get('period_id')): + raise osv.except_osv(_('Error') + ' R3006', _(' No transactions or no period in coda file !')) data = { 'name': statement['paperSeqNumber'], 'date': statement['date'], diff --git a/addons/l10n_be_invoice_bba/invoice.py b/addons/l10n_be_invoice_bba/invoice.py index a23dabd7c51..fca743928bf 100644 --- a/addons/l10n_be_invoice_bba/invoice.py +++ b/addons/l10n_be_invoice_bba/invoice.py @@ -153,25 +153,33 @@ class account_invoice(osv.osv): return {'value': {'reference': reference}} def create(self, cr, uid, vals, context=None): - if vals.has_key('reference_type'): - reference_type = vals['reference_type'] + reference = vals.get('reference', False) + reference_type = vals.get('reference_type', False) + if vals.get('type') == 'out_invoice' and not reference_type: + # fallback on default communication type for partner + reference_type = self.pool.get('res.partner').browse(cr, uid, vals['partner_id']).out_inv_comm_type if reference_type == 'bba': - if vals.has_key('reference'): - bbacomm = vals['reference'] - else: + reference = self.generate_bbacomm(cr, uid, [], vals['type'], reference_type, vals['partner_id'], '', context={})['value']['reference'] + vals.update({ + 'reference_type': reference_type or 'none', + 'reference': reference, + }) + + if reference_type == 'bba': + if not reference: + raise osv.except_osv(_('Warning!'), + _('Empty BBA Structured Communication!' \ + '\nPlease fill in a unique BBA Structured Communication.')) + if self.check_bbacomm(reference): + reference = re.sub('\D', '', reference) + vals['reference'] = '+++' + reference[0:3] + '/' + reference[3:7] + '/' + reference[7:] + '+++' + same_ids = self.search(cr, uid, + [('type', '=', 'out_invoice'), ('reference_type', '=', 'bba'), + ('reference', '=', vals['reference'])]) + if same_ids: raise osv.except_osv(_('Warning!'), - _('Empty BBA Structured Communication!' \ - '\nPlease fill in a unique BBA Structured Communication.')) - if self.check_bbacomm(bbacomm): - reference = re.sub('\D', '', bbacomm) - vals['reference'] = '+++' + reference[0:3] + '/' + reference[3:7] + '/' + reference[7:] + '+++' - same_ids = self.search(cr, uid, - [('type', '=', 'out_invoice'), ('reference_type', '=', 'bba'), - ('reference', '=', vals['reference'])]) - if same_ids: - raise osv.except_osv(_('Warning!'), - _('The BBA Structured Communication has already been used!' \ - '\nPlease create manually a unique BBA Structured Communication.')) + _('The BBA Structured Communication has already been used!' \ + '\nPlease create manually a unique BBA Structured Communication.')) return super(account_invoice, self).create(cr, uid, vals, context=context) def write(self, cr, uid, ids, vals, context=None): diff --git a/addons/l10n_ca/account_tax_en.xml b/addons/l10n_ca/account_tax_en.xml index afe505f27f5..f0d2670d077 100644 --- a/addons/l10n_ca/account_tax_en.xml +++ b/addons/l10n_ca/account_tax_en.xml @@ -101,8 +101,8 @@ - GST + TVQ for sales - GSTTVQ_SALE + GST + QST for sales + GSTQST_SALE sale 1 percent @@ -127,8 +127,8 @@ - TVQ for sales - 9.975% - TVQ + QST for sales - 9.975% + QST sale 0.099750 percent @@ -192,8 +192,8 @@ - TVH for sales - 12% - TVH12_SALE + HST for sales - 12% + HST12_SALE sale 0.120000 percent @@ -207,8 +207,8 @@ - TVH for sales - 13% - TVH13_SALE + HST for sales - 13% + HST13_SALE sale 0.130000 percent @@ -222,8 +222,8 @@ - TVH for sales - 13.5% - TVH135_SALE + HST for sales - 13.5% + HST135_SALE sale 0.135000 percent @@ -237,8 +237,8 @@ - TVH for sales - 15% - TVH15_SALE + HST for sales - 15% + HST15_SALE sale 0.150000 percent @@ -367,8 +367,8 @@ - GST + TVQ for purchases - GSTTVQ_PURC + GST + QST for purchases + GSTQST_PURC purchase 1 percent @@ -393,8 +393,8 @@ - TVQ for purchases - 9.975% - TVQ + QST for purchases - 9.975% + QST purchase 0.099750 percent @@ -458,8 +458,8 @@ - TVH for purchases - 12% - TVH12_PURC + HST for purchases - 12% + HST12_PURC purchase 0.120000 percent @@ -473,8 +473,8 @@ - TVH for purchases - 13% - TVH13_PURC + HST for purchases - 13% + HST13_PURC purchase 0.130000 percent @@ -488,8 +488,8 @@ - TVH for purchases - 13.5% - TVH135_PURC + HST for purchases - 13.5% + HST135_PURC purchase 0.135000 percent @@ -503,8 +503,8 @@ - TVH for purchases - 15% - TVH15_PURC + HST for purchases - 15% + HST15_PURC purchase 0.150000 percent diff --git a/addons/l10n_ch/__openerp__.py b/addons/l10n_ch/__openerp__.py index 8960224891d..a7830784340 100644 --- a/addons/l10n_ch/__openerp__.py +++ b/addons/l10n_ch/__openerp__.py @@ -24,8 +24,8 @@ {'name': 'Switzerland - Accounting', 'description': """ - Swiss localization : - ==================== +Swiss localization +================== **Multilang swiss STERCHI account chart and taxes** **Author:** Camptocamp SA diff --git a/addons/l10n_pl/account_chart.xml b/addons/l10n_pl/account_chart.xml index 19e59714fc7..57ab12beb5d 100644 --- a/addons/l10n_pl/account_chart.xml +++ b/addons/l10n_pl/account_chart.xml @@ -978,7 +978,7 @@ other - Rozliczenie naliczonego VAT-22% + Rozliczenie naliczonego VAT-23% @@ -987,7 +987,16 @@ other - Rozliczenie naliczonego VAT-7% + Rozliczenie naliczonego VAT-8% + + + + 222020400 + + + other + + Rozliczenie naliczonego VAT-5% @@ -1014,7 +1023,7 @@ other - Rozliczenie należnego VAT-22% + Rozliczenie należnego VAT-23% @@ -1023,7 +1032,16 @@ other - Rozliczenie należnego VAT-7% + Rozliczenie należnego VAT-8% + + + + 222030400 + + + other + + Rozliczenie należnego VAT-5% @@ -3176,15 +3194,15 @@ - Polska - Plan kont - - - - + Polska - Plan kont + + + + - + \ No newline at end of file diff --git a/addons/l10n_pl/account_tax.xml b/addons/l10n_pl/account_tax.xml index d3ba9b221bf..de4123708d9 100644 --- a/addons/l10n_pl/account_tax.xml +++ b/addons/l10n_pl/account_tax.xml @@ -1,10 +1,10 @@ - + - VAT-22%(22.0%) - 0.220000 + VAT-23%(23.0%) + 0.230000 percent sale @@ -16,10 +16,10 @@ - + - VAT-7%(7.0%) - 0.070000 + VAT-8%(8.0%) + 0.080000 percent sale @@ -31,7 +31,22 @@ - + + + VAT-5%(5.0%) + 0.050000 + percent + sale + + + + + + + + + + VAT-0%(0.0%) 0.000000 @@ -46,10 +61,11 @@ - + + - VAT naliczony-22%(22.0%) - 0.220000 + VAT naliczony-23%(23.0%) + 0.230000 percent purchase @@ -61,10 +77,10 @@ - + - VAT naliczony-7%(7.0%) - 0.070000 + VAT naliczony-8%(8.0%) + 0.080000 percent purchase @@ -76,7 +92,22 @@ - + + + VAT naliczony-5%(5.0%) + 0.050000 + percent + purchase + + + + + + + + + + VAT naliczony-0%(0.0%) 0.000000 @@ -92,4 +123,4 @@ - + \ No newline at end of file diff --git a/addons/l10n_ro/partner_view.xml b/addons/l10n_ro/partner_view.xml index c03d5c9a1a6..102ba3d92f0 100644 --- a/addons/l10n_ro/partner_view.xml +++ b/addons/l10n_ro/partner_view.xml @@ -7,7 +7,6 @@ res.partner - diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 7726fc0b579..d586ddda768 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -292,7 +292,12 @@ class mail_thread(osv.AbstractModel): # subscribe uid unless asked not to if not context.get('mail_create_nosubscribe'): self.message_subscribe_users(cr, uid, [thread_id], [uid], context=context) - self.message_auto_subscribe(cr, uid, [thread_id], values.keys(), context=context) + # auto_subscribe: take values and defaults into account + create_values = set(values.keys()) + for key, val in context.iteritems(): + if key.startswith('default_'): + create_values.add(key[8:]) + self.message_auto_subscribe(cr, uid, [thread_id], list(create_values), context=context) # track values tracked_fields = self._get_tracked_fields(cr, uid, values.keys(), context=context) @@ -1252,7 +1257,7 @@ class mail_thread(osv.AbstractModel): ], context=context) mail_followers_obj.write(cr, SUPERUSER_ID, fol_ids, {'subtype_ids': [(6, 0, subtype_ids)]}, context=context) # subtype_ids not specified: do not update already subscribed partner, fetch default subtypes for new partners - else: + elif subtype_ids is None: subtype_ids = subtype_obj.search(cr, uid, [ ('default', '=', True), '|', diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 089c577e940..39afdb2a5a3 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -969,11 +969,11 @@ class pos_order(osv.osv): }) if data_type == 'product': - key = ('product', values['partner_id'], values['product_id']) + key = ('product', values['partner_id'], values['product_id'], values['debit'] > 0) elif data_type == 'tax': - key = ('tax', values['partner_id'], values['tax_code_id'],) + key = ('tax', values['partner_id'], values['tax_code_id'], values['debit'] > 0) elif data_type == 'counter_part': - key = ('counter_part', values['partner_id'], values['account_id']) + key = ('counter_part', values['partner_id'], values['account_id'], values['debit'] > 0) else: return diff --git a/addons/point_of_sale/point_of_sale_demo.xml b/addons/point_of_sale/point_of_sale_demo.xml index 1c61218a4cb..c27bb5fc7f3 100644 --- a/addons/point_of_sale/point_of_sale_demo.xml +++ b/addons/point_of_sale/point_of_sale_demo.xml @@ -290,7 +290,7 @@ True 5.10 - Fishing + Peaches True 2300001000008 diff --git a/addons/point_of_sale/static/src/js/devices.js b/addons/point_of_sale/static/src/js/devices.js index e7d0376938c..835b7fe7b5a 100644 --- a/addons/point_of_sale/static/src/js/devices.js +++ b/addons/point_of_sale/static/src/js/devices.js @@ -12,6 +12,8 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal this.weight = 0; this.weighting = false; + this.debug_weight = 0; + this.use_debug_weight = false; this.paying = false; this.default_payment_status = { @@ -92,38 +94,36 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal // and a weighting_end() weighting_read_kg: function(){ var self = this; - if(this.bypass_proxy){ - return this.weight; - }else{ - this.message('weighting_read_kg',{}) - .done(function(weight){ - if(self.weighting && !self.bypass_proxy){ + this.message('weighting_read_kg',{}) + .done(function(weight){ + if(self.weighting){ + if(self.use_debug_weight){ + self.weight = self.debug_weight; + }else{ self.weight = weight; } - }); - return this.weight; - } + } + }); + return this.weight; }, // sets a custom weight, ignoring the proxy returned value. debug_set_weight: function(kg){ - this.bypass_proxy = true; - this.weight = kg; + this.use_debug_weight = true; + this.debug_weight = kg; }, // resets the custom weight and re-enable listening to the proxy for weight values debug_reset_weight: function(){ - this.bypass_proxy = false; - this.weight = 0; + this.use_debug_weight = false; + this.debug_weight = 0; }, // the client has finished weighting products weighting_end: function(){ - if(!this.bypass_proxy){ - this.weight = 0; - this.weighting = false; - this.message('weighting_end'); - } + this.weight = 0; + this.weighting = false; + this.message('weighting_end'); }, // the pos asks the client to pay 'price' units diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 98ba49c8856..2538f36eb13 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -104,7 +104,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal return self.fetch('res.currency',['symbol','position','rounding','accuracy'],[['id','=',self.get('company').currency_id[0]]]); }).then(function(currencies){ - console.log('Currency:',currencies[0]); self.set('currency',currencies[0]); return self.fetch('product.uom', null, null); @@ -234,8 +233,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal on_removed_order: function(removed_order){ if( this.get('orders').isEmpty()){ this.add_new_order(); - } - if( this.get('selectedOrder') === removed_order){ + }else{ this.set({ selectedOrder: this.get('orders').last() }); } }, diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index 7a01732c353..20253ffd27b 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -459,7 +459,6 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa icon: '/point_of_sale/static/src/img/icons/png48/go-previous.png', click: function(){ clearInterval(this.intervalID); - self.pos.proxy.weighting_end(); self.pos_widget.screen_selector.set_current_screen(self.previous_screen); } }); @@ -820,7 +819,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa click: function() { self.finishOrder(); }, }); - window.print(); + this.print(); }, print: function() { window.print(); diff --git a/addons/point_of_sale/static/src/js/widgets.js b/addons/point_of_sale/static/src/js/widgets.js index 96ccd85134d..24660ab6377 100644 --- a/addons/point_of_sale/static/src/js/widgets.js +++ b/addons/point_of_sale/static/src/js/widgets.js @@ -743,6 +743,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa } }); this.$('.button.reset_weight').click(function(){ + self.$('input.weight').val(''); self.pos.proxy.debug_reset_weight(); }); this.$('.button.custom_ean').click(function(){ diff --git a/addons/point_of_sale/wizard/pos_session_opening.py b/addons/point_of_sale/wizard/pos_session_opening.py index 39e7c564831..3d6e314d033 100644 --- a/addons/point_of_sale/wizard/pos_session_opening.py +++ b/addons/point_of_sale/wizard/pos_session_opening.py @@ -85,6 +85,7 @@ class pos_session_opening(osv.osv_memory): session_ids = proxy.search(cr, uid, [ ('state', '!=', 'closed'), ('config_id', '=', config_id), + ('user_id', '=', uid), ], context=context) if session_ids: session = proxy.browse(cr, uid, session_ids[0], context=context) diff --git a/addons/procurement/procurement_data.xml b/addons/procurement/procurement_data.xml index 6a83d525c68..52503e76c44 100644 --- a/addons/procurement/procurement_data.xml +++ b/addons/procurement/procurement_data.xml @@ -12,7 +12,7 @@ - + diff --git a/addons/procurement/schedulers.py b/addons/procurement/schedulers.py index 7c9d5ec3290..6f326ccf1c5 100644 --- a/addons/procurement/schedulers.py +++ b/addons/procurement/schedulers.py @@ -36,6 +36,8 @@ class procurement_order(osv.osv): ''' Runs through scheduler. @param use_new_cursor: False or the dbname ''' + if use_new_cursor: + use_new_cursor = cr.dbname self._procure_confirm(cr, uid, use_new_cursor=use_new_cursor, context=context) self._procure_orderpoint_confirm(cr, uid, automatic=automatic,\ use_new_cursor=use_new_cursor, context=context) diff --git a/addons/project/project.py b/addons/project/project.py index 9ca74c19f9b..09146b9ed5a 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -593,6 +593,15 @@ class task(base_stage, osv.osv): }, } + def _get_default_partner(self, cr, uid, context=None): + """ Override of base_stage to add project specific behavior """ + project_id = self._get_default_project_id(cr, uid, context) + if project_id: + project = self.pool.get('project.project').browse(cr, uid, project_id, context=context) + if project and project.partner_id: + return project.partner_id.id + return super(task, self)._get_default_partner(cr, uid, context=context) + def _get_default_project_id(self, cr, uid, context=None): """ Gives default section by checking if present in the context """ return (self._resolve_project_id_from_context(cr, uid, context=context) or False) @@ -607,7 +616,8 @@ class task(base_stage, osv.osv): context key, or None if it cannot be resolved to a single project. """ - if context is None: context = {} + if context is None: + context = {} if type(context.get('default_project_id')) in (int, long): return context['default_project_id'] if isinstance(context.get('default_project_id'), basestring): @@ -688,13 +698,11 @@ class task(base_stage, osv.osv): def onchange_planned(self, cr, uid, ids, planned=0.0, effective=0.0): return {'value':{'remaining_hours': planned - effective}} - def onchange_project(self, cr, uid, id, project_id): - if not project_id: - return {} - data = self.pool.get('project.project').browse(cr, uid, [project_id]) - partner_id=data and data[0].partner_id - if partner_id: - return {'value':{'partner_id':partner_id.id}} + def onchange_project(self, cr, uid, id, project_id, context=None): + if project_id: + project = self.pool.get('project.project').browse(cr, uid, project_id, context=context) + if project and project.partner_id: + return {'value': {'partner_id': project.partner_id.id}} return {} def duplicate_task(self, cr, uid, map_ids, context=None): @@ -769,7 +777,8 @@ class task(base_stage, osv.osv): " * Blocked indicates something is preventing the progress of this task\n" " * Ready for next stage indicates the task is ready to be pulled to the next stage", readonly=True, required=False), - 'create_date': fields.datetime('Create Date', readonly=True,select=True), + 'create_date': fields.datetime('Create Date', readonly=True, select=True), + 'write_date': fields.datetime('Last Modification Date', readonly=True, select=True), #not displayed in the view but it might be useful with base_action_rule module (and it needs to be defined first for that) 'date_start': fields.datetime('Starting Date',select=True), 'date_end': fields.datetime('Ending Date',select=True), 'date_deadline': fields.date('Deadline',select=True), @@ -817,8 +826,9 @@ class task(base_stage, osv.osv): 'progress': 0, 'sequence': 10, 'active': True, - 'user_id': lambda obj, cr, uid, context: uid, - 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'project.task', context=c), + 'user_id': lambda obj, cr, uid, ctx=None: uid, + 'company_id': lambda self, cr, uid, ctx=None: self.pool.get('res.company')._company_default_get(cr, uid, 'project.task', context=ctx), + 'partner_id': lambda self, cr, uid, ctx=None: self._get_default_partner(cr, uid, context=ctx), } _order = "priority, sequence, date_start, name, id" @@ -1118,11 +1128,9 @@ class task(base_stage, osv.osv): def create(self, cr, uid, vals, context=None): if context is None: context = {} - if not vals.get('stage_id'): - ctx = context.copy() - if vals.get('project_id'): - ctx['default_project_id'] = vals['project_id'] - vals['stage_id'] = self._get_default_stage_id(cr, uid, context=ctx) + if vals.get('project_id') and not context.get('default_project_id'): + context['default_project_id'] = vals.get('project_id') + # context: no_log, because subtype already handle this create_context = dict(context, mail_create_nolog=True) task_id = super(task, self).create(cr, uid, vals, context=create_context) @@ -1134,11 +1142,6 @@ class task(base_stage, osv.osv): def write(self, cr, uid, ids, vals, context=None): if isinstance(ids, (int, long)): ids = [ids] - if vals.get('project_id'): - project_id = self.pool.get('project.project').browse(cr, uid, vals.get('project_id'), context=context) - if project_id: - vals.setdefault('message_follower_ids', []) - vals['message_follower_ids'] += [(6, 0,[follower.id]) for follower in project_id.message_follower_ids] if vals and not 'kanban_state' in vals and 'stage_id' in vals: new_stage = vals.get('stage_id') vals_reset_kstate = dict(vals, kanban_state='normal') diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index c334f5f67ef..37466802d98 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -65,15 +65,22 @@ class project_issue(base_stage, osv.osv): def create(self, cr, uid, vals, context=None): if context is None: context = {} - if not vals.get('stage_id'): - ctx = context.copy() - if vals.get('project_id'): - ctx['default_project_id'] = vals['project_id'] - vals['stage_id'] = self._get_default_stage_id(cr, uid, context=ctx) + if vals.get('project_id') and not context.get('default_project_id'): + context['default_project_id'] = vals.get('project_id') + # context: no_log, because subtype already handle this create_context = dict(context, mail_create_nolog=True) return super(project_issue, self).create(cr, uid, vals, context=create_context) + def _get_default_partner(self, cr, uid, context=None): + """ Override of base_stage to add project specific behavior """ + project_id = self._get_default_project_id(cr, uid, context) + if project_id: + project = self.pool.get('project.project').browse(cr, uid, project_id, context=context) + if project and project.partner_id: + return project.partner_id.id + return super(project_issue, self)._get_default_partner(cr, uid, context=context) + def _get_default_project_id(self, cr, uid, context=None): """ Gives default project by checking if present in the context """ return self._resolve_project_id_from_context(cr, uid, context=context) @@ -215,6 +222,10 @@ class project_issue(base_stage, osv.osv): return res def on_change_project(self, cr, uid, ids, project_id, context=None): + if project_id: + project = self.pool.get('project.project').browse(cr, uid, project_id, context=context) + if project and project.partner_id: + return {'value': {'partner_id': project.partner_id.id}} return {} def _get_issue_task(self, cr, uid, ids, context=None): @@ -309,6 +320,7 @@ class project_issue(base_stage, osv.osv): 'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.helpdesk', context=c), 'priority': crm.AVAILABLE_PRIORITIES[2][0], 'kanban_state': 'normal', + 'user_id': lambda obj, cr, uid, context: uid, } _group_by_full = { diff --git a/addons/project_mrp/project_mrp_view.xml b/addons/project_mrp/project_mrp_view.xml index 881ed9b6b29..499a0259214 100644 --- a/addons/project_mrp/project_mrp_view.xml +++ b/addons/project_mrp/project_mrp_view.xml @@ -26,9 +26,9 @@ project.task - + - + diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 849e558563a..ae5f56b4899 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -467,6 +467,20 @@ class purchase_order(osv.osv): self.write(cr, uid, [id], {'state' : 'confirmed', 'validator' : uid}) return True + def _choose_account_from_po_line(self, cr, uid, po_line, context=None): + fiscal_obj = self.pool.get('account.fiscal.position') + property_obj = self.pool.get('ir.property') + if po_line.product_id: + acc_id = po_line.product_id.property_account_expense.id + if not acc_id: + acc_id = po_line.product_id.categ_id.property_account_expense_categ.id + if not acc_id: + raise osv.except_osv(_('Error!'), _('Define expense account for this company: "%s" (id:%d).') % (po_line.product_id.name, po_line.product_id.id,)) + else: + acc_id = property_obj.get(cr, uid, 'property_account_expense_categ', 'product.category').id + fpos = po_line.order_id.fiscal_position or False + return fiscal_obj.map_account(cr, uid, fpos, acc_id) + def _prepare_inv_line(self, cr, uid, account_id, order_line, context=None): """Collects require data from purchase order line that is used to create invoice line for that purchase order line @@ -507,8 +521,6 @@ class purchase_order(osv.osv): journal_obj = self.pool.get('account.journal') inv_obj = self.pool.get('account.invoice') inv_line_obj = self.pool.get('account.invoice.line') - fiscal_obj = self.pool.get('account.fiscal.position') - property_obj = self.pool.get('ir.property') for order in self.browse(cr, uid, ids, context=context): pay_acc_id = order.partner_id.property_account_payable.id @@ -520,17 +532,7 @@ class purchase_order(osv.osv): # generate invoice line correspond to PO line and link that to created invoice (inv_id) and PO line inv_lines = [] for po_line in order.order_line: - if po_line.product_id: - acc_id = po_line.product_id.property_account_expense.id - if not acc_id: - acc_id = po_line.product_id.categ_id.property_account_expense_categ.id - if not acc_id: - raise osv.except_osv(_('Error!'), _('Define expense account for this company: "%s" (id:%d).') % (po_line.product_id.name, po_line.product_id.id,)) - else: - acc_id = property_obj.get(cr, uid, 'property_account_expense_categ', 'product.category').id - fpos = order.fiscal_position or False - acc_id = fiscal_obj.map_account(cr, uid, fpos, acc_id) - + acc_id = self._choose_account_from_po_line(cr, uid, po_line, context=context) inv_line_data = self._prepare_inv_line(cr, uid, acc_id, po_line, context=context) inv_line_id = inv_line_obj.create(cr, uid, inv_line_data, context=context) inv_lines.append(inv_line_id) diff --git a/addons/purchase/wizard/purchase_line_invoice.py b/addons/purchase/wizard/purchase_line_invoice.py index f97d82a8456..1be1e8e662d 100644 --- a/addons/purchase/wizard/purchase_line_invoice.py +++ b/addons/purchase/wizard/purchase_line_invoice.py @@ -48,12 +48,11 @@ class purchase_line_invoice(osv.osv_memory): if record_ids: res = False invoices = {} - invoice_obj=self.pool.get('account.invoice') - purchase_line_obj=self.pool.get('purchase.order.line') - property_obj=self.pool.get('ir.property') - account_fiscal_obj=self.pool.get('account.fiscal.position') - invoice_line_obj=self.pool.get('account.invoice.line') - account_jrnl_obj=self.pool.get('account.journal') + invoice_obj = self.pool.get('account.invoice') + purchase_obj = self.pool.get('purchase.order') + purchase_line_obj = self.pool.get('purchase.order.line') + invoice_line_obj = self.pool.get('account.invoice.line') + account_jrnl_obj = self.pool.get('account.journal') def multiple_order_invoice_notes(orders): notes = "" @@ -93,35 +92,14 @@ class purchase_line_invoice(osv.osv_memory): order.write({'invoice_ids': [(4, inv_id)]}) return inv_id - for line in purchase_line_obj.browse(cr,uid,record_ids): - if (not line.invoiced) and (line.state not in ('draft','cancel')): + for line in purchase_line_obj.browse(cr, uid, record_ids, context=context): + if (not line.invoiced) and (line.state not in ('draft', 'cancel')): if not line.partner_id.id in invoices: invoices[line.partner_id.id] = [] - if line.product_id: - a = line.product_id.property_account_expense.id - if not a: - a = line.product_id.categ_id.property_account_expense_categ.id - if not a: - raise osv.except_osv(_('Error!'), - _('Define expense account for this product: "%s" (id:%d).') % \ - (line.product_id.name, line.product_id.id,)) - else: - a = property_obj.get(cr, uid, - 'property_account_expense_categ', 'product.category', - context=context).id - fpos = line.order_id.fiscal_position or False - a = account_fiscal_obj.map_account(cr, uid, fpos, a) - inv_id = invoice_line_obj.create(cr, uid, { - 'name': line.name, - 'origin': line.order_id.name, - 'account_id': a, - 'price_unit': line.price_unit, - 'quantity': line.product_qty, - 'uos_id': line.product_uom.id, - 'product_id': line.product_id.id or False, - 'invoice_line_tax_id': [(6, 0, [x.id for x in line.taxes_id])], - 'account_analytic_id': line.account_analytic_id and line.account_analytic_id.id or False, - }) + acc_id = purchase_obj._choose_account_from_po_line(cr, uid, line, context=context) + inv_line_data = purchase_obj._prepare_inv_line(cr, uid, acc_id, line, context=context) + inv_line_data.update({'origin': line.order_id.name}) + inv_id = invoice_line_obj.create(cr, uid, inv_line_data, context=context) purchase_line_obj.write(cr, uid, [line.id], {'invoiced': True, 'invoice_lines': [(4, inv_id)]}) invoices[line.partner_id.id].append((line,inv_id)) diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index b1a1fa048be..14b3ba04eb5 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -918,7 +918,7 @@ - + @@ -1045,7 +1045,7 @@