diff options
| author | uco <uco@tinyerp.com> | 2010-07-09 18:39:32 +0530 |
|---|---|---|
| committer | uco <uco@tinyerp.com> | 2010-07-09 18:39:32 +0530 |
| commit | dfe184d4e8a3e05005f9ed7265bf8c26854dfcb3 (patch) | |
| tree | 0226e0798a5e5b2fda8743dde3b00aff2d7cd633 /addons | |
| parent | d767e71aebddc7745fecde50d4c1e8fd9d9e4e07 (diff) | |
| parent | 5b1ba838126dfea0109ff860263259ce563eec6a (diff) | |
[MERGE]
bzr revid: uco@tinyerp.com-20100709130932-741eh719xinpkr6l
Diffstat (limited to 'addons')
34 files changed, 372 insertions, 149 deletions
diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 572cb9d04fd..e0d31b9cf18 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -159,7 +159,7 @@ class account_bank_statement(osv.osv): 'period_id': _get_period, } - def button_confirm(self, cr, uid, ids, context={}): + def button_confirm_bank(self, cr, uid, ids, context={}): done = [] res_currency_obj = self.pool.get('res.currency') res_users_obj = self.pool.get('res.users') diff --git a/addons/account/account_cash_statement.py b/addons/account/account_cash_statement.py index 8380a19b411..896b71e9f25 100644 --- a/addons/account/account_cash_statement.py +++ b/addons/account/account_cash_statement.py @@ -67,19 +67,25 @@ class account_cash_statement(osv.osv): _inherit = 'account.bank.statement' - def _get_starting_balance(self, cr, uid, ids, name, arg, context=None): + def _get_starting_balance(self, cr, uid, ids, context=None): - """ Find starting balance " + """ Find starting balance @param name: Names of fields. @param arg: User defined arguments @return: Dictionary of values. - """ + """ res ={} for statement in self.browse(cr, uid, ids): amount_total=0.0 + + if statement.journal_id.type not in('cash'): + continue + for line in statement.starting_details_ids: amount_total+= line.pieces * line.number - res[statement.id]=amount_total + res[statement.id] = { + 'balance_start':amount_total + } return res def _balance_end_cash(self, cr, uid, ids, name, arg, context=None): @@ -116,7 +122,7 @@ class account_cash_statement(osv.osv): """ To get default journal for the object" @param name: Names of fields. @return: journal - """ + """ company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id journal = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'cash'), ('company_id', '=', company_id)]) if journal: @@ -166,11 +172,10 @@ class account_cash_statement(osv.osv): company_id = company_pool.search(cr, uid, [])[0] return company_id - + _columns = { 'company_id':fields.many2one('res.company', 'Company', required=False), 'journal_id': fields.many2one('account.journal', 'Journal', required=True), - 'balance_start': fields.function(_get_starting_balance, store=True, method=True, string='Opening Balance', type='float',digits=(16,2), help="Opening balance based on cashBox"), 'balance_end_real': fields.float('Closing Balance', digits=(16,2), states={'confirm':[('readonly', True)]}, help="closing balance entered by the cashbox verifier"), 'state': fields.selection( [('draft', 'Draft'), @@ -178,7 +183,7 @@ class account_cash_statement(osv.osv): ('open','Open')], 'State', required=True, states={'confirm': [('readonly', True)]}, readonly="1"), 'total_entry_encoding':fields.function(_get_sum_entry_encoding, method=True, store=True, string="Cash Transaction", help="Total cash transactions"), 'closing_date':fields.datetime("Closed On"), - 'balance_end': fields.function(_end_balance, method=True, store=True, string='Balance', help="Closing balance based on transactions"), + 'balance_end': fields.function(_end_balance, method=True, store=True, string='Balance', help="Closing balance based on Opening Balance and Transactions"), 'balance_end_cash': fields.function(_balance_end_cash, method=True, store=True, string='Balance', help="Closing balance based on cashBox"), 'starting_details_ids': fields.one2many('account.cashbox.line', 'starting_id', string='Opening Cashbox'), 'ending_details_ids': fields.one2many('account.cashbox.line', 'ending_id', string='Closing Cashbox'), @@ -205,8 +210,31 @@ class account_cash_statement(osv.osv): for i in starting_details_ids: if i and i[0] and i[1]: i[0], i[1] = 0, 0 - res = super(account_cash_statement, self).create(cr, uid, vals, context=context) - return res + res_id = super(account_cash_statement, self).create(cr, uid, vals, context=context) + res = self._get_starting_balance(cr, uid, [res_id]) + for rs in res: + super(account_cash_statement, self).write(cr, uid, rs, res.get(rs)) + return res_id + + def write(self, cr, uid, ids, vals, context=None): + """ + Update redord(s) comes in {ids}, with new value comes as {vals} + return True on success, False otherwise + + @param cr: cursor to database + @param user: id of current user + @param ids: list of record ids to be update + @param vals: dict of new values to be set + @param context: context arguments, like lang, time zone + + @return: True on success, False otherwise + """ + + super(account_cash_statement, self).write(cr, uid, ids, vals) + res = self._get_starting_balance(cr, uid, ids) + for rs in res: + super(account_cash_statement, self).write(cr, uid, rs, res.get(rs)) + return True def onchange_journal_id(self, cr, uid, statement_id, journal_id, context={}): """ Changes balance start and starting details if journal_id changes" @@ -285,7 +313,7 @@ class account_cash_statement(osv.osv): self.write(cr, uid, ids, vals) return True - def button_confirm(self, cr, uid, ids, context={}): + def button_confirm_cash(self, cr, uid, ids, context={}): """ Check the starting and ending detail of statement @return: True @@ -296,20 +324,24 @@ class account_cash_statement(osv.osv): account_move_obj = self.pool.get('account.move') account_move_line_obj = self.pool.get('account.move.line') account_bank_statement_line_obj = self.pool.get('account.bank.statement.line') - + company_currency_id = res_users_obj.browse(cr, uid, uid, context=context).company_id.currency_id.id for st in self.browse(cr, uid, ids, context): + + self.write(cr, uid, [st.id], {'balance_end_real':st.balance_end}) + st.balance_end_real = st.balance_end + if not st.state == 'open': continue if not self._equal_balance(cr, uid, ids, st, context): - raise osv.except_osv(_('Error !'), _('Cash balance is not matching with closing balance !')) - - if not (abs((st.balance_end or 0.0) - st.balance_end_real) < 0.0001): - raise osv.except_osv(_('Error !'), - _('The statement balance is incorrect !\n') + - _('The expected balance (%.2f) is different than the computed one. (%.2f)') % (st.balance_end_real, st.balance_end)) + raise osv.except_osv(_('Error !'), _('CashBox Balance is not matching with Calculated Balance !')) + +# if not (abs((st.balance_end or 0.0) - st.balance_end_real) < 0.0001): +# raise osv.except_osv(_('Error !'), +# _('The statement balance is incorrect !\n') + +# _('The expected balance (%.2f) is different than the computed one. (%.2f)') % (st.balance_end_real, st.balance_end)) if (not st.journal_id.default_credit_account_id) \ or (not st.journal_id.default_debit_account_id): raise osv.except_osv(_('Configuration Error !'), @@ -435,7 +467,7 @@ class account_cash_statement(osv.osv): if move.reconcile_id and move.reconcile_id.line_ids: torec += map(lambda x: x.id, move.reconcile_id.line_ids) - #try: + if abs(move.reconcile_amount-move.amount)<0.0001: writeoff_acc_id = False @@ -447,13 +479,16 @@ class account_cash_statement(osv.osv): account_move_line_obj.reconcile(cr, uid, torec, 'statement', writeoff_acc_id=writeoff_acc_id, writeoff_period_id=st.period_id.id, writeoff_journal_id=st.journal_id.id, context=context) else: account_move_line_obj.reconcile_partial(cr, uid, torec, 'statement', context) - #except: - # raise osv.except_osv(_('Error !'), _('Unable to reconcile entry "%s": %.2f') % (move.name, move.amount)) if st.journal_id.entry_posted: account_move_obj.write(cr, uid, [move_id], {'state':'posted'}) done.append(st.id) - self.write(cr, uid, done, {'state':'confirm'}, context=context) + + vals = { + 'state':'confirm', + 'closing_date':time.strftime("%Y-%m-%d %H:%M:%S") + } + self.write(cr, uid, done, vals, context=context) return True def button_cancel(self, cr, uid, ids, context={}): diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 80fb20e1fad..de8bc843faa 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -427,6 +427,9 @@ <field name="balance_end_real"/> <field name="balance_end"/> <field name="state"/> + <button type="object" string="Open" name="button_open" states="draft" icon="terp-camera_test"/> + <button type="object" string="Confirm" name="button_confirm_bank" states="open" icon="terp-gtk-go-back-rtl"/> + <button type="object" string="Cancel" name="button_cancel" states="confirm" icon="terp-gtk-stop"/> </tree> </field> </record> @@ -465,7 +468,7 @@ <field name="journal_id" on_change="onchange_journal_id(journal_id)" select="1"/> <field name="period_id"/> <field name="balance_start"/> - <field name="balance_end_real"/> + <field name="balance_end_real"/> </group> <notebook colspan="4"> <page string="Transaction"> @@ -505,7 +508,7 @@ <field name="state"/> <field name="balance_end"/> <button name="button_dummy" states="draft" string="Compute" icon="terp-stock_format-scientific"/> - <button name="button_confirm" states="draft" string="Confirm" type="object" icon="terp-camera_test"/> + <button name="button_confirm_bank" states="draft" string="Confirm" type="object" icon="terp-camera_test"/> <button name="button_cancel" states="confirm" string="Cancel" type="object" icon="terp-gtk-stop"/> </group> </form> @@ -518,6 +521,18 @@ <field name="view_mode">tree,form</field> <field name="domain">[('journal_id.type', '=', 'bank')]</field> </record> + <record model="ir.actions.act_window.view" id="action_bank_statement_tree_bank"> + <field name="sequence" eval="1"/> + <field name="view_mode">tree</field> + <field name="view_id" ref="view_bank_statement_tree"/> + <field name="act_window_id" ref="action_bank_statement_tree"/> + </record> + <record model="ir.actions.act_window.view" id="action_bank_statement_form_bank"> + <field name="sequence" eval="1"/> + <field name="view_mode">form</field> + <field name="view_id" ref="view_bank_statement_form"/> + <field name="act_window_id" ref="action_bank_statement_tree"/> + </record> <menuitem string="Bank Statements" action="action_bank_statement_tree" id="menu_bank_statement_tree" parent="menu_finance_bank_and_cash" sequence="7"/> <record id="action_bank_statement_draft_tree" model="ir.actions.act_window"> @@ -2267,7 +2282,7 @@ <field name="user_id" select="1"/> <field name="state"/> <button type="object" string="Open" name="button_open" states="draft" icon="terp-camera_test"/> - <button type="object" string="Confirm" name="button_confirm" states="open" icon="terp-gtk-go-back-rtl"/> + <button type="object" string="Confirm" name="button_confirm_cash" states="open" icon="terp-gtk-go-back-rtl"/> <button type="object" string="Cancel" name="button_cancel" states="confirm" icon="terp-gtk-stop"/> </tree> </field> @@ -2285,7 +2300,7 @@ <field name="journal_id" on_change="onchange_journal_id(journal_id)" domain="[('type','=','cash')]" select="1" /> <field name="user_id" select="1" readonly="1"/> <field name="period_id" select="1"/> - <field name="balance_end_real"/> +<!-- <field name="balance_end_real"/>--> </group> <notebook colspan="4"> @@ -2318,7 +2333,7 @@ </form> </field> </page> - <page string="Cash Box"> + <page string="CashBox"> <group col="2" colspan="2" expand="1"> <field name="starting_details_ids" nolabel="1" colspan="2" attrs="{'readonly':[('state','=','draft')]}"> <tree string = "Opening Balance" editable="bottom"> @@ -2349,7 +2364,7 @@ </group> </page> <page string="Accounting Entries" attrs="{'invisible': [('state','!=','confirm')]}"> - <field colspan="4" name="move_line_ids" nolabel="1"/> + <field colspan="4" name="move_line_ids" nolabel="1" string="Accounting Entries"/> </page> </notebook> <group col="6" colspan="4"> @@ -2360,18 +2375,18 @@ </group> <group col="2" colspan="2"> <separator string="Opening Balance" colspan="4"/> - <field name="balance_start"/> + <field name="balance_start" readonly="1" string="Opening Balance"/> <field name="total_entry_encoding"/> </group> <group col="2" colspan="2"> <separator string="Closing Balance" colspan="4"/> - <field name="balance_end" string="Approx"/> - <field name="balance_end_cash" string="Cash Balance"/> + <field name="balance_end" string="Calculated Balance"/> + <field name="balance_end_cash" string="CashBox Balance"/> </group> </group> <group col="8" colspan="4"> <field name="state" colspan="4"/> - <button name="button_confirm" states="open" string="Close CashBox" icon="terp-check" type="object"/> + <button name="button_confirm_cash" states="open" string="Close CashBox" icon="terp-check" type="object"/> <button name="button_open" states="draft" string="Open CashBox" icon="terp-document-new" type="object"/> <button name="button_cancel" states="confirm,open" string="Cancel" icon="terp-gtk-stop" type="object" groups="base.group_extended"/> </group> diff --git a/addons/account_cancel/account_cancel_view.xml b/addons/account_cancel/account_cancel_view.xml index bcb9fb4d34e..5f63b6cf6d7 100644 --- a/addons/account_cancel/account_cancel_view.xml +++ b/addons/account_cancel/account_cancel_view.xml @@ -1,16 +1,17 @@ <?xml version="1.0"?> <openerp> <data> - <record id="view_account_journal_form_inherit" model="ir.ui.view"> + <record id="view_account_journal_form_inherit" model="ir.ui.view"> <field name="name">account.journal.form</field> <field name="model">account.journal</field> <field name="type">form</field> <field name="inherit_id" ref="account.view_account_journal_form"/> <field name="arch" type="xml"> - <xpath expr="/form/notebook/page[@string='General Information']/group/group/field[@name='centralisation']" position="after"> + <field name="entry_posted" position="after"> +<!-- <xpath expr="/form/notebook/page[@string='General Information']/group/group/field[@name='centralisation']" position="after">--> <field name="update_posted"/> - </xpath> + </field> </field> - </record> - </data> -</openerp>
\ No newline at end of file + </record> + </data> +</openerp> diff --git a/addons/account_voucher_payment/wizard/account_voucher_unreconcile.py b/addons/account_voucher_payment/wizard/account_voucher_unreconcile.py index 2bfffb372b7..ef30e1af69f 100644 --- a/addons/account_voucher_payment/wizard/account_voucher_unreconcile.py +++ b/addons/account_voucher_payment/wizard/account_voucher_unreconcile.py @@ -49,7 +49,7 @@ class account_voucher_unreconcile(osv.osv_memory): recs = [line.reconcile_id.id] for rec in recs: - obj_reconcile.unlink(cr, uid, rec) + reconcile_pool.unlink(cr, uid, rec) if res.remove: wf_service = netsvc.LocalService("workflow") diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index be1a53046a7..79b883c0236 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -22,7 +22,8 @@ from datetime import datetime from osv import fields, osv, orm from tools.translate import _ -import mx.DateTime +from datetime import datetime +from datetime import timedelta import pooler import re import time @@ -105,7 +106,9 @@ the rule to mark CC(mail to any other person defined in actions)."), 'act_mail_to_email': fields.char('Mail to these Emails', size=128, \ help="Email-id of the persons whom mail is to be sent"), 'act_mail_body': fields.text('Mail body', help="Content of mail"), - 'regex_name': fields.char('Regular Expression on Model Name', size=128), + 'regex_name': fields.char('Regex on Resource Name', size=128, help="Regular expression for mathching name of the resource\ +\ne.g.: urgent.* will search for records having name starting with urgent\ +\nNote: This is case sensitive search."), 'server_action_id': fields.many2one('ir.actions.server', 'Server Action', help="Describes the action name.\neg:on which object which action to be taken on basis of which condition"), 'filter_id':fields.many2one('ir.filters', 'Filter', required=False), 'domain':fields.char('Domain', size=124, required=False, readonly=False), @@ -352,23 +355,23 @@ the rule to mark CC(mail to any other person defined in actions)."), base = False if hasattr(obj, 'create_date') and action.trg_date_type=='create': - base = mx.DateTime.strptime(obj.create_date[:19], '%Y-%m-%d %H:%M:%S') + base = datetime.strptime(obj.create_date[:19], '%Y-%m-%d %H:%M:%S') elif hasattr(obj, 'create_date') and action.trg_date_type=='action_last': if hasattr(obj, 'date_action_last') and obj.date_action_last: - base = mx.DateTime.strptime(obj.date_action_last, '%Y-%m-%d %H:%M:%S') + base = datetime.strptime(obj.date_action_last, '%Y-%m-%d %H:%M:%S') else: - base = mx.DateTime.strptime(obj.create_date[:19], '%Y-%m-%d %H:%M:%S') + base = datetime.strptime(obj.create_date[:19], '%Y-%m-%d %H:%M:%S') elif hasattr(obj, 'date_deadline') and action.trg_date_type=='deadline' \ and obj.date_deadline: - base = mx.DateTime.strptime(obj.date_deadline, '%Y-%m-%d %H:%M:%S') + base = datetime.strptime(obj.date_deadline, '%Y-%m-%d %H:%M:%S') elif hasattr(obj, 'date') and action.trg_date_type=='date' and obj.date: - base = mx.DateTime.strptime(obj.date, '%Y-%m-%d %H:%M:%S') + base = datetime.strptime(obj.date, '%Y-%m-%d %H:%M:%S') if base: fnct = { - 'minutes': lambda interval: mx.DateTime.RelativeDateTime(minutes=interval), - 'day': lambda interval: mx.DateTime.RelativeDateTime(days=interval), - 'hour': lambda interval: mx.DateTime.RelativeDateTime(hours=interval), - 'month': lambda interval: mx.DateTime.RelativeDateTime(months=interval), + 'minutes': lambda interval: timedelta(minutes=interval), + 'day': lambda interval: timedelta(days=interval), + 'hour': lambda interval: timedelta(hours=interval), + 'month': lambda interval: timedelta(months=interval), } d = base + fnct[action.trg_date_range_type](action.trg_date_range) dt = d.strftime('%Y-%m-%d %H:%M:%S') diff --git a/addons/base_action_rule/base_action_rule_view.xml b/addons/base_action_rule/base_action_rule_view.xml index c9164962439..36140e62649 100644 --- a/addons/base_action_rule/base_action_rule_view.xml +++ b/addons/base_action_rule/base_action_rule_view.xml @@ -24,7 +24,7 @@ <page string="Conditions"> <group col="2" colspan="2" name="model"> <separator colspan="4" string="Conditions on Model Fields"/> - <field name="regex_name" string="Regex on Model Name" colspan="2"/> + <field name="regex_name" colspan="2"/> <field name="trg_user_id"/> </group> <group col="2" colspan="2" name="partner"> diff --git a/addons/base_calendar/base_calendar_view.xml b/addons/base_calendar/base_calendar_view.xml index 7e2368658df..bb0412a2247 100644 --- a/addons/base_calendar/base_calendar_view.xml +++ b/addons/base_calendar/base_calendar_view.xml @@ -103,7 +103,7 @@ separator="1" help="Declined Invitations" /> <separator orientation="vertical"/> <field name="email" select='1'/> - <field name="sent_by_uid" select="1"/> + <field name="user_id" select="1"/> <separator orientation="vertical"/> <field name="cutype" string="Invitation type" select="1"/> <field name="event_date" select="1"/> diff --git a/addons/crm/board_crm_statistical_view.xml b/addons/crm/board_crm_statistical_view.xml index 1baf673990d..b23fdeac1cd 100644 --- a/addons/crm/board_crm_statistical_view.xml +++ b/addons/crm/board_crm_statistical_view.xml @@ -4,53 +4,69 @@ <!-- Board for statistical view of the sections --> - <record model="ir.ui.view" id="view_crm_lead_stage_graph1"> - <field name="name">Leads By Stage - Graph</field> + + <record model="ir.ui.view" id="view_crm_opportunity_categ_graph"> + <field name="name">Opportunities By Categories - Graph</field> <field name="model">crm.lead.report</field> <field name="type">graph</field> <field name="arch" type="xml"> - <graph string="Leads By Stage" type="pie"> - <field name="stage_id"/> + <graph string="Opportunity by Categories" type="bar" orientation="horizontal"> + <field name="categ_id"/> <field name="nbr" operator="+"/> </graph> </field> </record> - <record model="ir.ui.view" id="view_crm_opportunity_categ_graph"> - <field name="name">report.crm.opportunity.categ.graph</field> + <record model="ir.ui.view" id="view_crm_opportunity_stage_graph"> + <field name="name">Opportunities By Stage - Graph</field> <field name="model">crm.lead.report</field> <field name="type">graph</field> <field name="arch" type="xml"> - <graph string="Opportunity by Sales Team and Categories" type="bar" orientation="horizontal"> - <field name="categ_id"/> + <graph string="Opportunities By Stage" type="pie"> + <field name="stage_id"/> + <field name="nbr" operator="+"/> + </graph> + </field> + </record> + + <record model="ir.ui.view" id="view_crm_opportunity_user_stage_graph"> + <field name="name">Opportunities By Stage Per User - Graph</field> + <field name="model">crm.lead.report</field> + <field name="type">graph</field> + <field name="arch" type="xml"> + <graph string="Opportunities By Stage" type="bar"> + <field name="stage_id"/> <field name="nbr" operator="+"/> + <field name="user_id" group="True"/> </graph> </field> </record> - <act_window name="Opportunities By Categories" - domain="[('state','!=','done'),('state','!=','cancel')]" - res_model="crm.lead.report" - view_type="form" - view_mode="graph,tree,form" - view_id="view_crm_opportunity_categ_graph" - id="act_oppor_categ"/> + <record model="ir.actions.act_window" id="act_oppor_categ"> + <field name="res_model">Opportunities By Categories</field> + <field name="res_model">crm.lead.report</field> + <field name="view_type">form</field> + <field name="view_mode">graph,tree,form</field> + <field name="view_id" ref="view_crm_opportunity_categ_graph"/> + <field name="domain">[('state','!=','done'),('state','!=','cancel')]</field> + </record> - <record model="ir.actions.act_window" id="act_leads_state"> + <record model="ir.actions.act_window" id="act_opportunity_stage"> <field name="res_model">crm.lead.report</field> <field name="view_type">form</field> <field name="view_mode">graph,tree,form</field> - <field name="view_id" ref="view_crm_lead_stage_graph1"/> + <field name="view_id" ref="view_crm_opportunity_stage_graph"/> <field name="domain">[('state','!=','done'),('state','!=','cancel')]</field> </record> - <act_window name="Leads Of The Month By User" - domain="[('month','=',time.strftime('%%m')),('state','!=','cancel')]" - res_model="crm.lead.report" - view_type="form" - view_mode="graph,tree,form" - view_id="view_crm_lead_stage_graph1" - id="act_leads_month_user"/> + <record model="ir.actions.act_window" id="act_oppor_stage_user"> + <field name="res_model">Number of Opportunities by stage</field> + <field name="res_model">crm.lead.report</field> + <field name="view_type">form</field> + <field name="view_mode">graph,tree,form</field> + <field name="view_id" ref="view_crm_opportunity_user_stage_graph"/> + <field name="domain">[('state','!=','cancel')]</field> + </record> <record model="ir.ui.view" id="board_crm_statistical_form"> <field name="name">CRM - Statistical Dashboard Form</field> @@ -68,8 +84,8 @@ width="250"/> <action - string="Leads By Stage" - name="%(act_leads_state)d" + string="Opportunities By Stage" + name="%(act_opportunity_stage)d" height="200" colspan="4"/> @@ -77,8 +93,8 @@ <child2> <action - string="Leads Of The Month By User" - name="%(act_leads_month_user)d" + string="Number of Opportunities by Stage and User" + name="%(act_oppor_stage_user)d" colspan="4"/> </child2> diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 5cee0052297..575c2a8a3e3 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -268,12 +268,13 @@ class crm_case(object): """ cases = self.browse(cr, uid, ids) for case in cases: - data = {'active': True, 'user_id': False} + data = {'active': True} if case.section_id.parent_id: data['section_id'] = case.section_id.parent_id.id - if case.section_id.parent_id.user_id: - data['user_id'] = case.section_id.parent_id.user_id.id + if case.section_id.parent_id.change_responsible: + if case.section_id.parent_id.user_id: + data['user_id'] = case.section_id.parent_id.user_id.id else: raise osv.except_osv(_('Error !'), _('You can not escalate, You are already at the top level regarding your sales-team category.')) self.write(cr, uid, [case.id], data) @@ -439,6 +440,7 @@ class crm_case_section(osv.osv): 'active': fields.boolean('Active', help="If the active field is set to \ true, it will allow you to hide the sales team without removing it."), 'allow_unlink': fields.boolean('Allow Delete', help="Allows to delete non draft cases"), + 'change_responsible': fields.boolean('Change Responsible', help="Set responsible of this Sales team on escalation to this team"), 'user_id': fields.many2one('res.users', 'Responsible User'), 'member_ids':fields.many2many('res.users', 'sale_member_rel', 'section_id', 'member_id', 'Team Members'), 'reply_to': fields.char('Reply-To', size=64, help="The email address put \ diff --git a/addons/crm/crm_action_rule.py b/addons/crm/crm_action_rule.py index 1f11f2c4c0c..1ca37a426a2 100644 --- a/addons/crm/crm_action_rule.py +++ b/addons/crm/crm_action_rule.py @@ -24,7 +24,6 @@ import re import os import base64 import tools -import mx.DateTime from tools.translate import _ from osv import fields @@ -80,6 +79,26 @@ this if you want the rule to send an email to the partner."), if hasattr(obj, 'categ_id'): ok = ok and (not action.trg_categ_id or action.trg_categ_id.id==obj.categ_id.id) + #Cheking for history + regex = action.regex_history + result_history = True + if regex: + res = False + ptrn = re.compile(str(regex)) + for history in obj.message_ids: + _result = ptrn.search(str(history.name)) + if _result: + res = True + break + result_history = res + ok = ok and (not regex or result_history) + + res_count = True + if action.trg_max_history: + res_count = False + if len(obj.message_ids) >= action.trg_max_history: + res_count = True + ok = ok and res_count return ok def do_action(self, cr, uid, action, model_obj, obj, context={}): diff --git a/addons/crm/crm_meeting_menu.xml b/addons/crm/crm_meeting_menu.xml index bf1a8459655..027ebed0a7a 100644 --- a/addons/crm/crm_meeting_menu.xml +++ b/addons/crm/crm_meeting_menu.xml @@ -105,7 +105,7 @@ <field name="view_mode">tree,form</field> <field name="view_id" ref="base_calendar.base_calendar_attendee_tree_view" /> <field name="domain">[('ref','like','crm.meeting,')]</field> - <field name="context">{'default_sent_by_uid': uid}</field> + <field name="context">{"search_default_user_id":uid}</field> </record> <menuitem id="menu_attendee_invitations" diff --git a/addons/crm/crm_view.xml b/addons/crm/crm_view.xml index a3d9f14273e..74786ad91f6 100644 --- a/addons/crm/crm_view.xml +++ b/addons/crm/crm_view.xml @@ -43,6 +43,7 @@ <group col="2" colspan="1"> <separator string="Configuration" colspan="2"/> <field name="allow_unlink" select="2"/> + <field name="change_responsible"/> </group> <separator string="Team Members" colspan="4"/> <field name="member_ids" nolabel="1" colspan="4"/> diff --git a/addons/document/security/ir.model.access.csv b/addons/document/security/ir.model.access.csv index 245bcbffeab..9684932b2a6 100644 --- a/addons/document/security/ir.model.access.csv +++ b/addons/document/security/ir.model.access.csv @@ -9,6 +9,7 @@ "access_document_directory_content_type_group_system","document.directory.content.type group system","model_document_directory_content_type","base.group_user",1,0,0,0 "access_document_storage_group_document_manager","document.storage document manager","model_document_storage","group_document_manager",1,1,1,1 "access_document_storage_group_system","document.storage group system","model_document_storage","base.group_user",1,0,0,0 +"access_document_directory_dctx_all","document.directory.dctx all","model_document_directory_dctx",,1,0,0,0 "access_document_directory_dctx_group_document_manager","document.directory.dctx document manager","model_document_directory_dctx","group_document_manager",1,1,1,1 "access_document_directory_dctx_group_system","document.directory.dctx group system","model_document_directory_dctx","base.group_system",1,1,1,1 "access_report_document_user_group_document_manager","report.document.user document manager","model_report_document_user","document.group_document_manager",1,0,0,0 diff --git a/addons/event/__init__.py b/addons/event/__init__.py index 275c10657ff..ce8b64ed9a9 100644 --- a/addons/event/__init__.py +++ b/addons/event/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # @@ -15,12 +15,13 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import event import wizard import report +import res_partner # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/event/__openerp__.py b/addons/event/__openerp__.py index 7cd7d4ae2c6..634484deecb 100644 --- a/addons/event/__openerp__.py +++ b/addons/event/__openerp__.py @@ -53,6 +53,7 @@ 'wizard/event_make_invoice_view.xml', 'wizard/partner_event_registration_view.xml', 'board_association_view.xml', + 'res_partner_view.xml', ], 'demo_xml': ['event_demo.xml', 'board_association_demo.xml'], 'test': ['test/test_event.yml'], diff --git a/addons/event/event.py b/addons/event/event.py index b74f874e6b5..73ff7f6755a 100644 --- a/addons/event/event.py +++ b/addons/event/event.py @@ -176,11 +176,13 @@ class event_event(osv.osv): 'note': fields.text('Notes', help="Description or Summary of Event"), 'currency_id': fields.many2one('res.currency', 'Currency', required=True, readonly=True, states={'draft':[('readonly',False)]}), "unit_price": fields.float('Cost'), - 'partner_id': fields.many2one('res.partner','Teacher'), + 'main_speaker_id': fields.many2one('res.partner','Main Speaker'), + 'speaker_ids':fields.many2many('res.partner', 'event_speaker_rel', 'speaker_id', 'partner_id', 'Other Speakers'), 'address_id': fields.many2one('res.partner.address','Location Room'), - 'teacher_confirmed': fields.boolean('Teacher Confirmed'), + 'speaker_confirmed': fields.boolean('Speaker Confirmed'), 'country_id': fields.related('address_id', 'country_id', type='many2one', relation='res.country', string='Country'), + 'language': fields.char('Language',size=64), } diff --git a/addons/event/event_view.xml b/addons/event/event_view.xml index 20047d00f73..97b122d5c6a 100644 --- a/addons/event/event_view.xml +++ b/addons/event/event_view.xml @@ -57,18 +57,20 @@ <page string="General"> <field name="unit_price"/> <field name="currency_id"/> - <separator string="Teacher Information" colspan="4"/> - <field name="partner_id"/> + <separator string="Speaker Information" colspan="4"/> + <field name="main_speaker_id" domain="[('speaker','=',True)]"/> <field name="address_id"/> - <field name="teacher_confirmed"/> + <field name="speaker_ids" domain="[('speaker','=',True)]" colspan="4"/> <field name="country_id" /> + <field name="speaker_confirmed"/> + <field name="language"/> <separator string="Event description" colspan="4"/> <field name="parent_id" domain="[('parent_id','child_of','Event')]"/> <field name="active"/> <field name="register_min"/> <field name="register_max"/> <separator string="Notes" colspan="4"/> - <field name="note" colspan="4" nolabel="1"/> + <!--field name="note" colspan="4" nolabel="1"/--> <field name="state" select="1"/> <group col="4" colspan="2"> <button string="Confirm Event" name="button_confirm" states="draft" type="object" icon="gtk-apply"/> @@ -120,9 +122,11 @@ <field name="arch" type="xml"> <tree string="Events" colors="red:register_min>register_current;black:register_min<=register_current"> <field name="name" string="Name"/> - <field name="user_id"/> + <field name="main_speaker_id"/> + <field name="language"/> <field name="type"/> <field name="date_begin"/> + <field name="date_end"/> <field name="register_min"/> <field name="register_current"/> <field name="state"/> diff --git a/addons/event/report/report_event_registration.py b/addons/event/report/report_event_registration.py index d9232136c3a..9af9347a76d 100644 --- a/addons/event/report/report_event_registration.py +++ b/addons/event/report/report_event_registration.py @@ -43,6 +43,7 @@ class report_event_registration(osv.osv): 'type': fields.many2one('event.type', 'Event Type'), 'state': fields.selection([('draft', 'Draft'), ('confirm', 'Confirmed'), ('done', 'Done'), ('cancel', 'Cancelled')], 'State', readonly=True, required=True), 'user_id':fields.many2one('res.users', 'Responsible', readonly=True), + 'speaker_id':fields.many2one('res.partner', 'Speaker', readonly=True), } _order = 'date desc' def init(self, cr): @@ -57,6 +58,7 @@ class report_event_registration(osv.osv): c.event_id as event_id, e.date_begin as date, e.user_id as user_id, + e.main_speaker_id as speaker_id, to_char(e.date_begin, 'YYYY') as year, to_char(e.date_begin, 'MM') as month, to_char(e.date_begin, 'YYYY-MM-DD') as day, @@ -75,7 +77,7 @@ class report_event_registration(osv.osv): group by to_char(e.date_begin, 'YYYY'), to_char(e.date_begin, 'MM'), - t.id, e.id, e.date_begin, + t.id, e.id, e.date_begin,e.main_speaker_id, e.register_max, e.type, e.state, c.event_id, e.user_id, to_char(e.date_begin, 'YYYY-MM-DD') )""") diff --git a/addons/event/report/report_event_registration_view.xml b/addons/event/report/report_event_registration_view.xml index 2931bc28aa8..9e00040fa97 100644 --- a/addons/event/report/report_event_registration_view.xml +++ b/addons/event/report/report_event_registration_view.xml @@ -10,6 +10,7 @@ <tree string="Event on Registration"> <field name="date" invisible="1"/> <field name="user_id" invisible="1"/> + <field name="speaker_id" invisible="1"/> <field name="year" invisible="1"/> <field name="day" invisible="1"/> <field name="month" invisible="1"/> @@ -85,7 +86,8 @@ <separator orientation="vertical"/> <filter string="state" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/> <separator orientation="vertical"/> - <filter string="Responsible" name="user" icon="terp-personal" context="{'group_by': 'user_id'}"/> + <filter string="Speaker" name="user" icon="terp-personal+" context="{'group_by': 'speaker_id'}"/> + <!--filter string="Responsible" name="user" icon="terp-personal" context="{'group_by': 'user_id'}"/--> <separator orientation="vertical" /> <filter string="Day" icon="terp-go-month" domain="[]" context="{'group_by':'day'}"/> diff --git a/addons/event/res_partner.py b/addons/event/res_partner.py new file mode 100644 index 00000000000..23075ba1927 --- /dev/null +++ b/addons/event/res_partner.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +from osv import fields,osv + +class res_partner(osv.osv): + _inherit = 'res.partner' + + _columns = { + 'speaker': fields.boolean('Speaker'), + 'event_ids': fields.one2many('event.event','main_speaker_id',readonly=True), + 'event_registration_ids': fields.one2many('event.registration','partner_id',readonly=True), + } + +res_partner() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/event/res_partner_view.xml b/addons/event/res_partner_view.xml new file mode 100644 index 00000000000..0b6ace47b19 --- /dev/null +++ b/addons/event/res_partner_view.xml @@ -0,0 +1,44 @@ +<?xml version="1.0"?> +<openerp> + <data> + + <!-- Partners inherited form --> + + <record id="view_speaker_partner_info_form" model="ir.ui.view"> + <field name="name">res.partner.speaker.info.inherit</field> + <field name="model">res.partner</field> + <field name="type">form</field> + <field name="inherit_id" ref="base.view_partner_form"/> + <field name="arch" type="xml"> + <field name="supplier" position="after"> + <field name="speaker"/> + </field> + </field> + </record> + <record id="view_event_partner_info_form" model="ir.ui.view"> + <field name="name">res.partner.event.info.inherit</field> + <field name="model">res.partner</field> + <field name="type">form</field> + <field name="inherit_id" ref="base.view_partner_form"/> + <field name="arch" type="xml"> + <page string="History" position="inside"> + <field name="event_ids" colspan="4" nolabel="1"> + <tree string="Events"> + <field name="name" string="Event"/> + <field name="main_speaker_id"/> + </tree> + </field> + <field name="event_registration_ids" colspan="4" nolabel="1"> + <tree string="Events Registration"> + <field name="event_id" /> + <field name="partner_id"/> + <field name="unit_price"/> + </tree> + </field> + </page> + </field> + </record> + + </data> +</openerp> + diff --git a/addons/mail_gateway/mail_gateway.py b/addons/mail_gateway/mail_gateway.py index 2c778241daf..7187de5d1a5 100644 --- a/addons/mail_gateway/mail_gateway.py +++ b/addons/mail_gateway/mail_gateway.py @@ -158,9 +158,9 @@ class mailgate_message(osv.osv): 'user_id': fields.many2one('res.users', 'User Responsible', readonly=True), 'message': fields.text('Description'), 'email_from': fields.char('From', size=128, help="Email From"), - 'email_to': fields.text('To', help="Email Recipients"), - 'email_cc': fields.text('Cc', help="Carbon Copy Email Recipients"), - 'email_bcc': fields.text('Bcc', help='Blind Carbon Copy Email Recipients'), + 'email_to': fields.char('To', help="Email Recipients", size=256), + 'email_cc': fields.char('Cc', help="Carbon Copy Email Recipients", size=256), + 'email_bcc': fields.char('Bcc', help='Blind Carbon Copy Email Recipients', size=256), 'message_id': fields.char('Message Id', size=1024, readonly=True, help="Message Id on Email.", select=True), 'references': fields.text('References', readonly=True, help="References emails."), 'description': fields.text('Description'), diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index a67ca004f09..802ef47124d 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -160,7 +160,7 @@ class project_issue(osv.osv, crm.crm_case): \nWhen the case is over, the state is set to \'Done\'.\ \nIf the case needs to be reviewed then the state is set to \'Pending\'.'), 'email_from': fields.char('Email', size=128, help="These people will receive email."), - 'email_cc': fields.text('Watchers Emails', size=252, help="These people\ + 'email_cc': fields.char('Watchers Emails', size=256, help="These people\ will receive a copy of the future" \ " communication between partner and users by email"), 'date_open': fields.datetime('Opened', readonly=True), diff --git a/addons/project_issue/project_issue_view.xml b/addons/project_issue/project_issue_view.xml index 0bdee911cee..cbf24b18f76 100644 --- a/addons/project_issue/project_issue_view.xml +++ b/addons/project_issue/project_issue_view.xml @@ -154,9 +154,9 @@ <tree string="Issue Tracker Tree" colors="red:state=='open';blue:state=='pending';grey:state in ('cancel', 'done')"> <field name="id"/> <field name="create_date"/> - <field name="project_id" invisible="1"/> <field name="name"/> <field name="partner_id"/> + <field name="project_id" /> <field name="priority" string="Severity"/> <field name="stage_id" string="Resolution"/> <button icon="gtk-go-back" string="" name="stage_previous" type="object" diff --git a/addons/project_issue/report/project_issue_report.py b/addons/project_issue/report/project_issue_report.py index 833a792c34d..c79ac3eae64 100644 --- a/addons/project_issue/report/project_issue_report.py +++ b/addons/project_issue/report/project_issue_report.py @@ -52,7 +52,7 @@ class project_issue_report(osv.osv): _columns = { 'name': fields.char('Year', size=64, required=False, readonly=True), 'user_id':fields.many2one('res.users', 'Responsible', readonly=True), - 'user_id2':fields.many2one('res.users', 'Assigned To', readonly=True), + 'user_id2':fields.many2one('res.users', 'Assignee', readonly=True), 'section_id':fields.many2one('crm.case.section', 'Section', readonly=True), 'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True), 'avg_answers': fields.function(_get_data, string='Avg. Answers', method=True, type="integer"), @@ -66,17 +66,17 @@ class project_issue_report(osv.osv): ('11', 'November'), ('12', 'December')], 'Month', readonly=True), 'company_id': fields.many2one('res.company', 'Company', readonly=True), 'day': fields.char('Day', size=128, readonly=True), - 'opening_date': fields.date('Opening Date', readonly=True), + 'opening_date': fields.date('Date of Opening', readonly=True), 'creation_date': fields.date('Creation Date', readonly=True), - 'date_closed': fields.date('Closed Date', readonly=True), + 'date_closed': fields.date('Date of Closing', readonly=True), 'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'project.issue')]"), 'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('object_id.model', '=', 'project.issue')]"), 'nbr': fields.integer('# of Issues', readonly=True), - 'working_hours_open': fields.float('# Working Open Hours', readonly=True), - 'working_hours_close': fields.float('# Working Closing Hours', readonly=True), - 'delay_open': fields.float('Avg opening Delay', digits=(16,2), readonly=True, group_operator="avg", + 'working_hours_open': fields.float('Avg. Working Hours to Open', readonly=True), + 'working_hours_close': fields.float('Avg. Working Hours to Close', readonly=True), + 'delay_open': fields.float('Avg. Delay to Open', digits=(16,2), readonly=True, group_operator="avg", help="Number of Days to close the project issue"), - 'delay_close': fields.float('Avg Closing Delay', digits=(16,2), readonly=True, group_operator="avg", + 'delay_close': fields.float('Avg. Delay to Close', digits=(16,2), readonly=True, group_operator="avg", help="Number of Days to close the project issue"), 'company_id' : fields.many2one('res.company', 'Company'), 'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'), diff --git a/addons/purchase/__openerp__.py b/addons/purchase/__openerp__.py index f557997497b..471f5213b12 100644 --- a/addons/purchase/__openerp__.py +++ b/addons/purchase/__openerp__.py @@ -36,9 +36,7 @@ 'author': 'Tiny', 'website': 'http://www.openerp.com', 'depends': ['base', 'account', 'stock', 'process', 'procurement'], - 'init_xml': [], - 'update_xml': [ - + 'data': [ 'security/purchase_security.xml', 'security/ir.model.access.csv', 'purchase_workflow.xml', @@ -60,8 +58,9 @@ 'test/purchase_from_order.yml', 'test/purchase_from_manual.yml', # 'test/purchase_from_picking.yml', + 'purchase_unit_test.xml' ], - 'demo_xml': ['purchase_demo.xml','purchase_unit_test.xml'], + 'demo': ['purchase_demo.xml'], 'installable': True, 'active': False, 'certificate': '0057234283549', diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 82e01735b00..d70ea13d39b 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -720,7 +720,7 @@ purchase_order_line() class procurement_order(osv.osv): _inherit = 'procurement.order' _columns = { - 'purchase_id': fields.many2one('purchase.order', 'Latest Requisition'), + 'purchase_id': fields.many2one('purchase.order', 'Purchase Order'), } def action_po_assign(self, cr, uid, ids, context={}): diff --git a/addons/purchase/report/purchase_report.py b/addons/purchase/report/purchase_report.py index 4f5abfe698d..40a61efbc19 100644 --- a/addons/purchase/report/purchase_report.py +++ b/addons/purchase/report/purchase_report.py @@ -54,14 +54,14 @@ class purchase_report(osv.osv): 'validator' : fields.many2one('res.users', 'Validated By', readonly=True), 'company_id':fields.many2one('res.company', 'Company', readonly=True), 'user_id':fields.many2one('res.users', 'Responsible', readonly=True), - 'delay':fields.float('Days to Validate', digits=(16,2), readonly=True, group_operator="avg"), - 'delay_pass':fields.float('Days to Deliver', digits=(16,2), readonly=True, group_operator="avg"), + 'delay':fields.float('Days to Validate', digits=(16,2), readonly=True), + 'delay_pass':fields.float('Days to Deliver', digits=(16,2), readonly=True), 'quantity': fields.float('# of Products', readonly=True), 'price_total': fields.float('Total Price', readonly=True), - 'price_average': fields.float('Unit Price', readonly=True, group_operator="avg"), + 'price_average': fields.float('Average Price', readonly=True, group_operator="avg"), 'negociation': fields.float('Purchase-Standard Price', readonly=True, group_operator="avg"), 'price_standard': fields.float('Products Value', readonly=True, group_operator="sum"), - 'nbr': fields.integer('# of PO Lines', readonly=True), + 'nbr': fields.integer('# of Lines', readonly=True), 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')],'Month',readonly=True), diff --git a/addons/purchase/report/purchase_report_view.xml b/addons/purchase/report/purchase_report_view.xml index 757fc065a60..bd69e4dfce0 100644 --- a/addons/purchase/report/purchase_report_view.xml +++ b/addons/purchase/report/purchase_report_view.xml @@ -33,14 +33,14 @@ <field name="company_id" invisible="1"/> <field name="state" invisible="1"/> <field name="location_id" invisible="1"/> - <field name="nbr"/> + <field name="nbr" sum="# of Lines"/> <field name="quantity" sum="# of Products"/> - <field name="price_average" avg="Average Price"/> + <field name="price_average" sum="Average Price"/> <field name="price_total" sum="Total Price"/> - <field name="price_standard" sum="Products Costs"/> + <field name="price_standard" sum="Products Value"/> <field name="negociation" widget="progressbar"/> - <field name="delay"/> - <field name="delay_pass"/> + <field name="delay" sum="Days to Validate"/> + <field name="delay_pass" sum="Days to Deliver"/> </tree> </field> </record> @@ -142,10 +142,11 @@ <record id="action_purchase_order_report_all" model="ir.actions.act_window"> - <field name="name">Purchase Orders</field> + <field name="name">Purchase Analysis</field> <field name="res_model">purchase.report</field> <field name="view_type">form</field> <field name="view_mode">tree,graph</field> + <field name="view_id" ref="view_purchase_order_tree"></field> <field name="context">{'search_default_month':1,'search_default_group_partner_id':1,'search_default_group_product_id': 1, 'search_default_orders': 1, 'group_by_no_leaf':1,'group_by':[]}</field> </record> diff --git a/addons/purchase_requisition/purchase_requisition.py b/addons/purchase_requisition/purchase_requisition.py index db05650354b..532c9918b60 100644 --- a/addons/purchase_requisition/purchase_requisition.py +++ b/addons/purchase_requisition/purchase_requisition.py @@ -129,10 +129,14 @@ class purchase_order(osv.osv): } def wkf_confirm_order(self, cr, uid, ids, context={}): res = super(purchase_order, self).wkf_confirm_order(cr, uid, ids, context) + proc_obj=self.pool.get('procurement.order') for po in self.browse(cr, uid, ids, context): if po.requisition_id and (po.requisition_id.exclusive=='exclusive'): for order in po.requisition_id.purchase_ids: if order.id<>po.id: + proc_ids = proc_obj.search(cr, uid, [('purchase_id', '=', order.id)]) + if proc_ids and po.state=='confirmed': + proc_obj.wirte(cr,uid,proc_ids,{'purchase_id':po.id}) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'purchase.order', order.id, 'purchase_cancel', cr) self.pool.get('purchase.requisition').write(cr, uid, [po.requisition_id.id], {'state':'done','date_end':time.strftime('%Y-%m-%d %H:%M:%S')}) @@ -155,14 +159,17 @@ product_product() class procurement_order(osv.osv): _inherit = 'procurement.order' - + _columns = { + 'requisition_id' : fields.many2one('purchase.requisition','Latest Requisition') + } def make_po(self, cr, uid, ids, context=None): sequence_obj = self.pool.get('ir.sequence') res = super(procurement_order, self).make_po(cr, uid, ids, context=context) for proc_id, po_id in res.items(): procurement = self.browse(cr, uid, proc_id) + requisition_id=False if procurement.product_id.purchase_requisition: - self.pool.get('purchase.requisition').create(cr, uid, { + requisition_id=self.pool.get('purchase.requisition').create(cr, uid, { 'name': sequence_obj.get(cr, uid, 'purchase.order.requisition'), 'origin': procurement.name, 'date_end': procurement.date_planned, @@ -174,6 +181,7 @@ class procurement_order(osv.osv): })], 'purchase_ids': [(6,0,[po_id])] }) + self.write(cr,uid,proc_id,{'requisition_id':requisition_id}) return res procurement_order() diff --git a/addons/purchase_requisition/purchase_requisition_view.xml b/addons/purchase_requisition/purchase_requisition_view.xml index 76aa70aaf42..b8e488ac0cf 100644 --- a/addons/purchase_requisition/purchase_requisition_view.xml +++ b/addons/purchase_requisition/purchase_requisition_view.xml @@ -168,6 +168,17 @@ </field> </field> </record> - + + <record model="ir.ui.view" id="procurement_normal_form_view_inherit"> + <field name="name">procurement.form.inherit</field> + <field name="type">form</field> + <field name="model">procurement.order</field> + <field name="inherit_id" ref="procurement.procurement_form_view"/> + <field name="arch" type="xml"> + <xpath expr="/form/notebook/page/field[@name='close_move']" position="after"> + <field name="requisition_id"/> + </xpath> + </field> + </record> </data> </openerp> diff --git a/addons/sale/report/sale_report.py b/addons/sale/report/sale_report.py index 8c24b5000ee..0880cdb76d1 100644 --- a/addons/sale/report/sale_report.py +++ b/addons/sale/report/sale_report.py @@ -74,7 +74,7 @@ class sale_report(osv.osv): tools.drop_view_if_exists(cr, 'sale_report') cr.execute(""" create or replace view sale_report as ( - select el.*, + select el.*, -- (select count(1) from sale_order_line where order_id = s.id) as nbr, (select 1) as nbr, s.date_order as date, @@ -86,28 +86,46 @@ class sale_report(osv.osv): s.user_id as user_id, s.shop_id as shop_id, s.company_id as company_id, - extract(epoch from (s.date_confirm-s.create_date))/(24*60*60)::decimal(16,2) as delay, + extract(epoch from avg(date_trunc('day',s.date_confirm)-date_trunc('day',s.create_date)))/(24*60*60)::decimal(16,2) as delay, s.state, s.shipped, s.shipped::integer as shipped_qty_1, s.pricelist_id as pricelist_id, s.project_id as analytic_account_id - from - sale_order s, - ( - select l.id as id, - l.product_id as product_id, - u.name as uom_name, - sum(l.product_uom_qty * u.factor) as product_uom_qty, - sum(l.product_uom_qty*l.price_unit) as price_total, - (sum(l.product_uom_qty*l.price_unit)/sum(l.product_uom_qty * u.factor)*count(l.product_id))::decimal(16,2) as price_average, - pt.categ_id, l.order_id - from - sale_order_line l - left join product_uom u on (u.id=l.product_uom) - left join product_template pt on (pt.id=l.product_id) - group by l.id, l.order_id, l.product_id, u.name, pt.categ_id) el - where s.id = el.order_id + from + sale_order s, + ( + select l.id as id, + l.product_id as product_id, + u.name as uom_name, + sum(l.product_uom_qty * u.factor) as product_uom_qty, + sum(l.product_uom_qty*l.price_unit) as price_total, + (sum(l.product_uom_qty*l.price_unit)/sum(l.product_uom_qty * u.factor)*count(l.product_id))::decimal(16,2) as price_average, + pt.categ_id, l.order_id + from + sale_order_line l + left join product_uom u on (u.id=l.product_uom) + left join product_template pt on (pt.id=l.product_id) + group by l.id, l.order_id, l.product_id, u.name, pt.categ_id) el + where s.id = el.order_id + group by el.id, + el.product_id, + el.uom_name, + el.product_uom_qty, + el.price_total, + el.price_average, + el.categ_id, + el.order_id, + s.date_order, + s.date_confirm, + s.partner_id, + s.user_id, + s.shop_id, + s.company_id, + s.state, + s.shipped, + s.pricelist_id, + s.project_id ) """) sale_report() diff --git a/addons/sale/report/sale_report_view.xml b/addons/sale/report/sale_report_view.xml index 6ab414aad8b..a4658bc3a1c 100644 --- a/addons/sale/report/sale_report_view.xml +++ b/addons/sale/report/sale_report_view.xml @@ -20,11 +20,11 @@ <field name="categ_id" invisible="1"/> <field name="nbr" sum="# of Lines"/> <field name="product_uom_qty" sum="# of Qty"/> - <field name="shipped_qty_1"/> - <field name="uom_name" invisible="context.get('set_visible',False)"/> - <field name="price_average" avg="Average Price"/> + <field name="shipped_qty_1" sum="Shipped Qty"/> + <field name="uom_name" invisible="not context.get('set_visible',False)"/> + <field name="price_average" sum="Average Price"/> <field name="price_total" sum="Total Price"/> - <field name="delay" avg="Commitment Delay"/> + <field name="delay" sum="Commitment Delay"/> <field name="state" invisible="1"/> <field name="analytic_account_id" invisible="1"/> </tree> @@ -122,6 +122,7 @@ <field name="view_type">form</field> <field name="view_mode">tree,graph</field> <field name="search_view_id" ref="view_order_product_search"/> + <field name="view_id" ref="view_order_product_tree"/> <field name="context">{'search_default_month':1,'search_default_User':1,'group_by_no_leaf':1,'group_by':[]}</field> </record> |
