[MERGE]: Merge with lp:openobject-trunk-dev-addons2

bzr revid: ksa@tinyerp.co.in-20100924044402-xjq8jjvbunyeo3c9
This commit is contained in:
ksa (Open ERP)
2010-09-24 10:14:02 +05:30
24 changed files with 190 additions and 271 deletions
-15
View File
@@ -31,21 +31,6 @@
<menuitem action="crm_lead_categ_action"
id="menu_crm_lead_categ" name="Categories"
parent="base.menu_crm_config_lead" sequence="1"/>
<!-- Resource Type Form View -->
<record id="crm_lead_resource_act" model="ir.actions.act_window">
<field name="name">Lead Sources</field>
<field name="res_model">crm.case.resource.type</field>
<field name="view_type">form</field>
<field name="view_id" ref="crm.crm_case_resource_type_tree"/>
<field name="domain">[('object_id.model', '=', 'crm.lead')]</field>
<field name="context">{'object_id':'crm.lead'}</field>
</record>
<menuitem action="crm_lead_resource_act"
id="menu_crm_lead_resource_act" name="Lead Sources"
groups="base.group_extended" sequence="2"
parent="base.menu_crm_config_lead" />
<!-- CRM Lead Form View -->
<record model="ir.ui.view" id="crm_case_form_view_leads">
+3 -3
View File
@@ -50,11 +50,11 @@ class crm_phonecall(crm_case, osv.osv):
'company_id': fields.many2one('res.company', 'Company'),
'description': fields.text('Description'),
'state': fields.selection([
('draft', 'Todo'),
('draft', 'Draft'),
('open', 'Todo'),
('cancel', 'Cancelled'),
('done', 'Held'),
('pending', 'Not Held'),
('done', 'Done'),
('pending', 'Pending'),
], 'State', size=16, readonly=True,
help='The state is set to \'Draft\', when a case is created.\
\nIf the case is in progress the state is set to \'Open\'.\
-13
View File
@@ -16,19 +16,6 @@
<menuitem action="crm_phonecall_categ_action" name="Categories"
id="menu_crm_case_phonecall-act" parent="menu_crm_config_phonecall" />
<!-- ResourceType Form View -->
<record id="crm_phonecall_resource_act" model="ir.actions.act_window">
<field name="name">Phonecall Campaigns</field>
<field name="res_model">crm.case.resource.type</field>
<field name="view_type">form</field>
<field name="view_id" ref="crm.crm_case_resource_type_tree"/>
</record>
<menuitem action="crm_phonecall_resource_act"
id="menu_crm_phonecall_resource_act" name="Campaigns"
parent="menu_crm_config_phonecall" />
<!-- PhoneCalls Tree View -->
<record model="ir.ui.view" id="crm_case_phone_tree_view">
+4 -1
View File
@@ -186,7 +186,6 @@
<form string="Campaign">
<field name="name" select="1"/>
<field name="section_id" select="1" widget="selection"/>
<field name="object_id"/>
</form>
</field>
</record>
@@ -200,6 +199,10 @@
<field name="view_id" ref="crm_case_resource_type_tree"/>
</record>
<menuitem action="crm_case_resource_type_act"
id="menu_crm_case_resource_type_act" sequence="4"
parent="base.menu_sale_config_sales" />
<record id="crm_case_section_act_tree" model="ir.actions.act_window">
<field name="name">Cases by Sales Team</field>
<field name="res_model">crm.case.section</field>
+1 -1
View File
@@ -160,7 +160,7 @@ class crm_lead_report(osv.osv):
>>>>>>> MERGE-SOURCE
date_trunc('day',c.create_date) as create_date,
extract('epoch' from (c.date_closed-c.create_date))/(3600*24) as delay_close,
extract('epoch' from (c.date_deadline - c.date_closed))/(3600*24) as delay_expected,
abs(extract('epoch' from (c.date_deadline - c.date_closed))/(3600*24)) as delay_expected,
extract('epoch' from (c.date_open-c.create_date))/(3600*24) as delay_open
FROM
crm_lead c
+12 -9
View File
@@ -73,24 +73,27 @@
<group col="20" colspan="8">
<filter string=" Year " icon="terp-go-year"
domain="[('create_date','&lt;=', time.strftime('%%Y-%%m-%%d')),('create_date','&gt;=',time.strftime('%%Y-01-01'))]"
help="Leads/Opportunities created in last 365 days"/>
help="Leads/Opportunities created in current year"/>
<filter string=" Month " icon="terp-go-month" name="this_month"
domain="[('create_date','&lt;=', time.strftime('%%Y-%%m-%%d')),('create_date','&gt;=',time.strftime('%%Y-%%m-01'))]"
help="Leads/Opportunities created in last 30 days"/>
<filter icon="terp-go-week" string=" Month-1 " separator="1"
help="Leads/Opportunities created in current month"/>
<filter icon="terp-go-month" string=" Month-1 " separator="1"
domain="[('create_date','&lt;=', (datetime.date (int(time.strftime('%%Y')), datetime.date.today().month, 1) - datetime.timedelta (days = 1)).strftime('%%Y-%%m-%%d')),('create_date','&gt;',(datetime.date (int(time.strftime('%%Y')), datetime.date.today().month-1, 1)).strftime('%%Y-%%m-%%d'))]"
help="Leads/Opportunities created in the previous month"/>
help="Leads/Opportunities created in last month"/>
<separator orientation="vertical" />
<filter icon="terp-check"
string="Current"
domain="[('state','in',('draft','open'))]"/>
string="Active"
domain="[('state','in',('draft','open'))]"
help="Leads/Opportunities which are in draft and open state"/>
<filter icon="gtk-media-pause"
string="Pending"
domain="[('state','=','pending')]"/>
domain="[('state','=','pending')]"
help="Leads/Opportunities which are in pending state"/>
<filter icon="terp-dialog-close"
string="Closed"
domain="[('state','=','done')]"/>
domain="[('state','=','done')]"
help="Leads/Opportunities which are in done state"/>
<separator orientation="vertical" />
<field name="section_id"
@@ -101,7 +104,7 @@
domain="[('section_id.user_id','=',uid)]"
help="My team" />
</field>
<field name="user_id">
<field name="user_id" string="Salesman">
<filter icon="terp-personal+" string="My Case" help="My Case" domain="[('user_id','=',uid)]" />
</field>
</group>
+4 -4
View File
@@ -24,11 +24,11 @@ import tools
from crm import crm
AVAILABLE_STATES = [
('draft','Todo'),
('open','Todo'),
('draft','Draft'),
('open','Open'),
('cancel', 'Cancelled'),
('done', 'Held'),
('pending','Not Held')
('done', 'Closed'),
('pending','Pending')
]
@@ -76,13 +76,16 @@
<search string="Search">
<group col="16" colspan="8">
<filter string=" Year " icon="terp-go-year"
domain="[('create_date','&lt;=', time.strftime('%%Y-%%m-%%d')),('create_date','&gt;=',time.strftime('%%Y-01-01'))]"/>
domain="[('create_date','&lt;=', time.strftime('%%Y-%%m-%%d')),('create_date','&gt;=',time.strftime('%%Y-01-01'))]"
help="Phone calls made in current year"/>
<filter string=" Month " icon="terp-go-month" name="This Month"
domain="[('create_date','&lt;=', time.strftime('%%Y-%%m-%%d')),('create_date','&gt;=',time.strftime('%%Y-%%m-01'))]"/>
domain="[('create_date','&lt;=', time.strftime('%%Y-%%m-%%d')),('create_date','&gt;=',time.strftime('%%Y-%%m-01'))]"
help="Phone calls made in current month"/>
<filter icon="terp-go-week" string=" Month-1 " separator="1"
domain="[('create_date','&lt;=', (datetime.date (int(time.strftime('%%Y')), datetime.date.today().month, 1) - datetime.timedelta (days = 1)).strftime('%%Y-%%m-%%d')),('create_date','&gt;',(datetime.date (int(time.strftime('%%Y')), datetime.date.today().month-1, 1)).strftime('%%Y-%%m-%%d'))]"/>
<filter icon="terp-go-month" string=" Month-1 " separator="1"
domain="[('create_date','&lt;=', (datetime.date (int(time.strftime('%%Y')), datetime.date.today().month, 1) - datetime.timedelta (days = 1)).strftime('%%Y-%%m-%%d')),('create_date','&gt;',(datetime.date (int(time.strftime('%%Y')), datetime.date.today().month-1, 1)).strftime('%%Y-%%m-%%d'))]"
help="Phone calls made in last month"/>
<separator orientation="vertical" />
<filter icon="terp-check"
@@ -95,15 +98,15 @@
string="Done"
domain="[('state','=','done')]"/>
<separator orientation="vertical" />
<field name="section_id"
<field name="section_id" string="Sales Team"
default="context.get('section_id', False)"
context="{'invisible_section': False}">
<filter icon="terp-personal+"
context="{'invisible_section': False}"
domain="[('section_id.user_id','=',uid)]"
help="My section" />
help="My team" />
</field>
<field name="user_id" select="1">
<field name="user_id" string="Salesman" select="1">
<filter icon="terp-crm" string="My Case" help="My Case" domain="[('user_id','=',uid)]" />
</field>
</group>
-15
View File
@@ -35,21 +35,6 @@
<menuitem action="crm_claim_stage_act" name="Stages"
id="menu_crm_claim_stage_act" parent="menu_config_claim" />
<!-- Claim Resource Type -->
<record id="crm_claim_resource_act" model="ir.actions.act_window">
<field name="name">Claim Resource Type</field>
<field name="res_model">crm.case.resource.type</field>
<field name="view_type">form</field>
<field name="view_id" ref="crm.crm_case_resource_type_tree"/>
<field name="domain">[('object_id.model', '=', 'crm.claim')]</field>
<field name="context">{'object_id':'crm.claim'}</field>
</record>
<menuitem action="crm_claim_resource_act" name="Resource Type"
id="menu_crm_claim_type_act"
parent="menu_config_claim" />
<!-- Claims -->
<record model="ir.ui.view" id="crm_case_claims_tree_view">
@@ -79,15 +79,15 @@
<group col="16" colspan="8">
<filter string=" Year " icon="terp-go-year"
domain="[('create_date','&lt;=', time.strftime('%%Y-%%m-%%d')),('create_date','&gt;=',time.strftime('%%Y-01-01'))]"
help="Claims created in last 365 days"/>
help="Claims created in current year"/>
<filter string=" Month " icon="terp-go-month" name="This Month"
domain="[('create_date','&lt;=', time.strftime('%%Y-%%m-%%d')),('create_date','&gt;=',time.strftime('%%Y-%%m-01'))]"
help="Claims created in last 30 days"/>
help="Claims created in current month"/>
<filter icon="terp-go-week" string=" Month-1 " separator="1"
<filter icon="terp-go-month" string=" Month-1 " separator="1"
domain="[('create_date','&lt;=', (datetime.date (int(time.strftime('%%Y')), datetime.date.today().month, 1) - datetime.timedelta (days = 1)).strftime('%%Y-%%m-%%d')),('create_date','&gt;',(datetime.date (int(time.strftime('%%Y')), datetime.date.today().month-1, 1)).strftime('%%Y-%%m-%%d'))]"
help="Claims created in the previous month"/>
help="Claims created in last month"/>
<separator orientation="vertical" />
<filter icon="terp-document-new"
@@ -101,14 +101,14 @@
domain="[('state','=','pending')]"/>
<separator orientation="vertical" />
<field name="section_id"
<field name="section_id" string="Sales Team"
default="context.get('section_id', False)"
context="{'invisible_section': False}">
<filter icon="terp-personal+"
context="{'invisible_section': False}"
domain="[('section_id.user_id','=',uid)]"
help="My section" />
help="My team" />
</field>
<field name="company_id">
@@ -118,7 +118,7 @@
help="My company"/>
</field>
<field name="user_id" select="1">
<field name="user_id" string="Salesman" select="1">
<filter icon="terp-personal+" string="My Case" help="My Case" domain="[('user_id','=',uid)]" />
</field>
</group>
@@ -37,24 +37,6 @@
id="menu_crm_fundraising_stage_act"
parent="menu_config_fundrising" />
<!-- Fund Resource Type Form View -->
<record id="crm_fundraising_resource_act" model="ir.actions.act_window">
<field name="name">Fundraising Resource Type</field>
<field name="res_model">crm.case.resource.type</field>
<field name="view_type">form</field>
<field name="view_id" ref="crm.crm_case_resource_type_tree"/>
<field name="domain">[('object_id.model', '=', 'crm.fundraising')]</field>
<field name="context">{'object_id':'crm.fundraising'}</field>
</record>
<menuitem action="crm_fundraising_resource_act"
groups="base.group_extended" name="Resource Type"
id="menu_crm_fundraising_resource_act"
parent="menu_config_fundrising" />
<!-- Fund Raising Tree View -->
<record model="ir.ui.view" id="crm_case_tree_view_fund">
@@ -78,15 +78,15 @@
<group col="16" colspan="8">
<filter string=" Year " icon="terp-go-year"
domain="[('create_date','&lt;=', time.strftime('%%Y-%%m-%%d')),('create_date','&gt;=',time.strftime('%%Y-01-01'))]"
help="Funds raised in last 365 days"/>
help="Funds raised in current year"/>
<filter string=" Month " icon="terp-go-month" name="This Month"
domain="[('create_date','&lt;=', time.strftime('%%Y-%%m-%%d')),('create_date','&gt;=',time.strftime('%%Y-%%m-01'))]"
help="Funds raised in last 30 days"/>
help="Funds raised in current month"/>
<filter icon="terp-go-week" string=" Month-1 " separator="1"
<filter icon="terp-go-month" string=" Month-1 " separator="1"
domain="[('create_date','&lt;=', (datetime.date (int(time.strftime('%%Y')), datetime.date.today().month, 1) - datetime.timedelta (days = 1)).strftime('%%Y-%%m-%%d')),('create_date','&gt;',(datetime.date (int(time.strftime('%%Y')), datetime.date.today().month-1, 1)).strftime('%%Y-%%m-%%d'))]"
help="Funds raised in the previous month"/>
help="Funds raised in last month"/>
<separator orientation="vertical" />
<filter icon="terp-document-new"
@@ -100,14 +100,14 @@
domain="[('state','=','pending')]"/>
<separator orientation="vertical" />
<field name="section_id"
<field name="section_id" string="Sales Team"
default="context.get('section_id', False)"
context="{'invisible_section': False}">
<filter icon="terp-personal+"
context="{'invisible_section': False}"
domain="[('section_id.user_id','=',uid)]"
help="My section" />
help="My team" />
</field>
<field name="company_id">
@@ -117,7 +117,7 @@
help="My company"/>
</field>
<field name="user_id" select="1">
<field name="user_id" select="1" string="Salesman">
<filter icon="terp-personal+" string="My Case" help="My Case" domain="[('user_id','=',uid)]" />
</field>
</group>
@@ -146,15 +146,15 @@
<separator orientation="vertical" />
<filter string="Day" icon="terp-go-today"
domain="[]" context="{'group_by':'day'}"
help="Day on which fund is raised"/>
help="Date of fundraising"/>
<filter string="Month" icon="terp-go-month"
domain="[]" context="{'group_by':'month'}"
help="Month in which fund is raised"/>
help="Month of fundraising"/>
<filter string="Year" icon="terp-go-year"
domain="[]" context="{'group_by':'name'}"
help="Year in which fund is raised"/>
help="Year of fundraising"/>
</group>
<newline/>
@@ -9,7 +9,7 @@
<field name="model">crm.helpdesk.report</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree colors="blue:state in ('draft');black:state in ('open','pending');gray:state in ('done','cancel') " string="Helpdesk">
<tree string="Helpdesk">
<field name="name" invisible="1"/>
<field name="month" invisible="1"/>
<field name="section_id" invisible="1"/>
@@ -78,13 +78,13 @@
<group col="16" colspan="9">
<filter string=" Year " icon="terp-go-year"
domain="[('create_date','&lt;=', time.strftime('%%Y-%%m-%%d')),('create_date','&gt;=',time.strftime('%%Y-01-01'))]"
help="Helpdesk requests created in last 365 days"/>
help="Helpdesk requests occurred in current year"/>
<filter string=" Month " icon="terp-go-month" name="this_month"
domain="[('create_date','&lt;=', time.strftime('%%Y-%%m-%%d')),('create_date','&gt;=',time.strftime('%%Y-%%m-01'))]"
help="Helpdesk requests created in last 30 days"/>
<filter icon="terp-go-week" string=" Month-1 " separator="1"
help="Helpdesk requests occurred in current month"/>
<filter icon="terp-go-month" string=" Month-1 " separator="1"
domain="[('create_date','&lt;=', (datetime.date (int(time.strftime('%%Y')), datetime.date.today().month, 1) - datetime.timedelta (days = 1)).strftime('%%Y-%%m-%%d')),('create_date','&gt;',(datetime.date (int(time.strftime('%%Y')), datetime.date.today().month-1, 1)).strftime('%%Y-%%m-%%d'))]"
help="Helpdesk requests created in the previous month"/>
help="Helpdesk requests occurred in last month"/>
<separator orientation="vertical" />
<filter string="Current" icon="terp-check"
@@ -97,14 +97,14 @@
domain="[('state','=','cancel')]" />
<separator orientation="vertical" />
<field name="section_id"
<field name="section_id" string="Sales Team"
default="context.get('section_id', False)"
context="{'invisible_section': False}">
<filter icon="terp-personal+"
context="{'invisible_section': False}"
domain="[('section_id.user_id','=',uid)]"
help="My section" />
help="My team" />
</field>
<field name="company_id">
@@ -113,7 +113,7 @@
domain="[('section_id.user_id.company_id','=',uid)]"
help="My company"/>
</field>
<field name="user_id">
<field name="user_id" string="Salesman">
<filter icon="terp-personal+" string="My Case" help="My Case" domain="[('user_id','=',uid)]" />
</field>
</group>
@@ -145,7 +145,7 @@
<separator orientation="vertical" />
<filter string="Day" icon="terp-go-today"
domain="[]" context="{'group_by':'day'}" help="Day of helpdesk requests"/>
domain="[]" context="{'group_by':'day'}" help="Date of helpdesk requests"/>
<filter string="Month" icon="terp-go-month"
domain="[]" context="{'group_by':'month'}" help="Month of helpdesk requests"/>
<filter string="Year" icon="terp-go-year"
+25 -4
View File
@@ -45,6 +45,7 @@ class mrp_repair(osv.osv):
"""
res = {}
cur_obj = self.pool.get('res.currency')
for repair in self.browse(cr, uid, ids):
res[repair.id] = 0.0
for line in repair.operations:
@@ -62,6 +63,7 @@ class mrp_repair(osv.osv):
@return: Dictionary of values.
"""
res = {}
#return {}.fromkeys(ids, 0)
cur_obj = self.pool.get('res.currency')
tax_obj = self.pool.get('account.tax')
for repair in self.browse(cr, uid, ids):
@@ -94,6 +96,14 @@ class mrp_repair(osv.osv):
res[id] = cur_obj.round(cr, uid, cur, untax.get(id, 0.0) + tax.get(id, 0.0))
return res
def _get_lines(self, cr, uid, ids, context=None):
if context is None:
context = {}
result = {}
for line in self.pool.get('mrp.repair.line').browse(cr, uid, ids, context=context):
result[line.repair_id.id] = True
return result.keys()
_columns = {
'name': fields.char('Repair Reference',size=24, required=True),
'product_id': fields.many2one('product.product', string='Product to Repair', required=True, readonly=True, states={'draft':[('readonly',False)]}),
@@ -137,9 +147,21 @@ class mrp_repair(osv.osv):
'deliver_bool': fields.boolean('Deliver', help="Check this box if you want to manage the delivery once the product is repaired. If cheked, it will create a picking with selected product. Note that you can select the locations in the Info tab, if you have the extended view."),
'invoiced': fields.boolean('Invoiced', readonly=True),
'repaired': fields.boolean('Repaired', readonly=True),
'amount_untaxed': fields.function(_amount_untaxed, method=True, string='Untaxed Amount'),
'amount_tax': fields.function(_amount_tax, method=True, string='Taxes'),
'amount_total': fields.function(_amount_total, method=True, string='Total'),
'amount_untaxed': fields.function(_amount_untaxed, method=True, string='Untaxed Amount',
store={
'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10),
'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
}),
'amount_tax': fields.function(_amount_tax, method=True, string='Taxes',
store={
'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10),
'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
}),
'amount_total': fields.function(_amount_total, method=True, string='Total',
store={
'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10),
'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
}),
}
_defaults = {
@@ -163,7 +185,6 @@ class mrp_repair(osv.osv):
})
return super(mrp_repair, self).copy(cr, uid, id, default, context)
def onchange_product_id(self, cr, uid, ids, product_id=None):
""" On change of product sets some values.
@param product_id: Changed product
+5 -5
View File
@@ -377,23 +377,23 @@ class product_product(osv.osv):
res[product.id] = (res[product.id] or 0.0) * (product.price_margin or 1.0) + product.price_extra
return res
def _get_partner_code_name(self, cr, uid, ids, product_id, partner_id, context={}):
product = self.browse(cr, uid, [product_id], context)[0]
def _get_partner_code_name(self, cr, uid, ids, product, partner_id, context={}):
for supinfo in product.seller_ids:
if supinfo.name.id == partner_id:
return {'code': supinfo.product_code, 'name': supinfo.product_name, 'variants': ''}
return {'code' : product.default_code, 'name' : product.name, 'variants': product.variants}
res = {'code': product.default_code, 'name': product.name, 'variants': product.variants}
return res
def _product_code(self, cr, uid, ids, name, arg, context={}):
res = {}
for p in self.browse(cr, uid, ids, context):
res[p.id] = self._get_partner_code_name(cr, uid, [], p.id, context.get('partner_id', None), context)['code']
res[p.id] = self._get_partner_code_name(cr, uid, [], p, context.get('partner_id', None), context)['code']
return res
def _product_partner_ref(self, cr, uid, ids, name, arg, context={}):
res = {}
for p in self.browse(cr, uid, ids, context):
data = self._get_partner_code_name(cr, uid, [], p.id, context.get('partner_id', None), context)
data = self._get_partner_code_name(cr, uid, [], p, context.get('partner_id', None), context)
if not data['variants']:
data['variants'] = p.variants
if not data['code']:
+1 -1
View File
@@ -29,7 +29,7 @@
<field name="section_id" ref="crm.section_sales_department"/>
</record>
<record model="crm.case.resource.type" id="type2">
<record model="crm.case.resource.type" id="type3">
<field name="name">Version 6.0</field>
<field name="section_id" ref="crm.section_sales_department"/>
</record>
@@ -87,7 +87,7 @@ class project_issue_report(osv.osv):
'company_id' : fields.many2one('res.company', 'Company'),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
'project_id':fields.many2one('project.project', 'Project',readonly=True),
'type_id': fields.many2one('crm.case.resource.type', 'Version', domain="[('object_id.model', '=', 'project.issue')]"),
'type_id': fields.many2one('crm.case.resource.type', 'Version'),
'assigned_to' : fields.many2one('res.users', 'Assigned to',readonly=True),
'partner_id': fields.many2one('res.partner','Partner',domain="[('object_id.model', '=', 'project.issue')]"),
'canal_id': fields.many2one('res.partner.canal', 'Channel',readonly=True),
@@ -137,7 +137,7 @@
<separator orientation="vertical"/>
<field name="priority" />
<separator orientation="vertical"/>
<field name="type_id" widget="selection" domain="[('object_id.model', '=', 'project.issue')]"/>
<field name="type_id" widget="selection"/>
<field name="categ_id" widget="selection" domain="[('object_id.model', '=', 'project.issue')]"/>
<field name="stage_id" widget="selection" domain="[('object_id.model', '=', 'project.issue')]" />
<separator orientation="vertical"/>
+3 -3
View File
@@ -53,12 +53,12 @@
<group>
<filter icon="terp-go-year" string=" Year "
domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')),('date','&gt;=',time.strftime('%%Y-01-01'))]"
help="Sales order created in last 365 days"/>
help="Sales order created in current year"/>
<filter icon="terp-go-month" string=" Month "
name="month"
domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')),('date','&gt;=',time.strftime('%%Y-%%m-01'))]"
help="Sales order created in last 30 days"/>
<filter icon="terp-go-week"
help="Sales order created in current month"/>
<filter icon="terp-go-month"
string=" Month-1 "
separator="1"
domain="[('date','&lt;=', (datetime.date (int(time.strftime('%%Y')), datetime.date.today().month, 1) - datetime.timedelta (days = 1)).strftime('%%Y-%%m-%%d')),('date','&gt;',(datetime.date (int(time.strftime('%%Y')), datetime.date.today().month-1, 1)).strftime('%%Y-%%m-%%d'))]"
+2 -2
View File
@@ -268,12 +268,12 @@
</field>
<newline/>
<group expand="0" string="Group By..." colspan="11" col="11" groups="base.group_extended">
<filter string="Order Date" icon="terp-go-month" domain="[]" context="{'group_by':'date_order'}"/>
<separator orientation="vertical"/>
<filter string="Customer" icon="terp-personal" domain="[]" context="{'group_by':'partner_id'}"/>
<filter string="Salesman" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/>
<separator orientation="vertical"/>
<filter string="State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
<separator orientation="vertical"/>
<filter string="Order Date" icon="terp-go-month" domain="[]" context="{'group_by':'date_order'}"/>
</group>
</search>
</field>
+1 -38
View File
@@ -23,47 +23,10 @@ from osv import osv,fields
class sale_order(osv.osv):
_inherit = 'sale.order'
_columns = {
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
}
def action_cancel(self, cr, uid, ids, context=None):
res = super(sale_order, self).action_cancel(cr, uid, ids, context=context)
case_pool = self.pool.get('crm.lead')
data_pool = self.pool.get('ir.model.data')
data = data_pool._get_id(cr, uid, 'crm', 'stage_lead6')
res_data = data_pool.read(cr, uid, data, ['res_id'])
lost_stage_id = False
if res_data and res_data.get('res_id'):
lost_stage_id = res_data.get('res_id', False)
if not lost_stage_id:
return res
# After sale cancel, lead also lost
for sale_id in ids:
lead_ids = case_pool.search(cr, uid, [('ref','=','sale.order,%s'%(sale_id))])
case_pool.write(cr, uid, lead_ids, {'stage_id': lost_stage_id})
return res
def action_ship_create(self, cr, uid, ids, *args):
res = super(sale_order, self).action_ship_create(cr, uid, ids, *args)
case_pool = self.pool.get('crm.lead')
data_pool = self.pool.get('ir.model.data')
data = data_pool._get_id(cr, uid, 'crm', 'stage_lead5')
res_data = data_pool.read(cr, uid, data, ['res_id'])
win_stage_id = False
if res_data and res_data.get('res_id'):
win_stage_id = res_data.get('res_id', False)
if not win_stage_id:
return res
# After sale confimed, lead also win
for sale_id in ids:
lead_ids = case_pool.search(cr, uid, [('ref','=','sale.order,%s'%(sale_id))])
case_pool.write(cr, uid, lead_ids, {'stage_id': win_stage_id})
return res
def _get_section(self, cr, uid, context=None):
return context.get('context_section_id', False)
_defaults = {
'section_id': _get_section
}
sale_order()
+87 -98
View File
@@ -19,11 +19,11 @@
#
##############################################################################
import time
from osv import fields, osv
from tools.translate import _
import decimal_precision as dp
import time
class crm_make_sale(osv.osv_memory):
""" Make sale order for crm """
@@ -42,10 +42,12 @@ class crm_make_sale(osv.osv_memory):
"""
if not context:
context = {}
lead_obj = self.pool.get('crm.lead')
active_id = context and context.get('active_id', False) or False
if not active_id:
return False
lead = lead_obj.read(cr, uid, active_id, ['partner_id'])
return lead['partner_id']
@@ -53,14 +55,11 @@ class crm_make_sale(osv.osv_memory):
if context is None:
context = {}
if context.get('active_ids', False) and context['active_ids']:
oppr = self.pool.get('crm.lead').browse(cr, uid, context['active_ids'])
for line in oppr:
for line in self.pool.get('crm.lead').browse(cr, uid, context['active_ids']):
if not line.section_id:
raise osv.except_osv(_('Warning !'), _(' Sales Team is not specified.'))
return super(crm_make_sale, self).view_init(cr, uid, fields_list, context=context)
def makeOrder(self, cr, uid, ids, context=None):
"""
This function create Quotation on given case.
@@ -80,75 +79,65 @@ class crm_make_sale(osv.osv_memory):
partner_obj = self.pool.get('res.partner')
sale_line_obj = self.pool.get('sale.order.line')
result = mod_obj._get_id(cr, uid, 'sale', 'view_sales_order_filter')
data = context and context.get('active_ids', []) or []
for make in self.browse(cr, uid, ids):
default_partner_addr = partner_obj.address_get(cr, uid, [make.partner_id.id],
['invoice', 'delivery', 'contact'])
default_pricelist = partner_obj.browse(cr, uid, make.partner_id.id,
context).property_product_pricelist.id
fpos_data = partner_obj.browse(cr, uid, make.partner_id.id, context).property_account_position
for make in self.browse(cr, uid, ids, context=context):
partner = make.partner_id
partner_addr = partner_obj.address_get(cr, uid, [partner.id],
['default', 'invoice', 'delivery', 'contact'])
pricelist = partner.property_product_pricelist.id
fpos = partner.property_account_position and partner.property_account_position.id or False
new_ids = []
for case in case_obj.browse(cr, uid, data):
if case.partner_id and case.partner_id.id:
partner_id = case.partner_id.id
fpos = case.partner_id.property_account_position and case.partner_id.property_account_position.id or False
partner_addr = partner_obj.address_get(cr, uid, [case.partner_id.id],
for case in case_obj.browse(cr, uid, data, context=context):
if not partner and case.partner_id:
partner = case.partner_id
fpos = partner.property_account_position and partner.property_account_position.id or False
partner_addr = partner_obj.address_get(cr, uid, [partner.id],
['default', 'invoice', 'delivery', 'contact'])
pricelist = partner_obj.browse(cr, uid, case.partner_id.id,
context).property_product_pricelist.id
else:
partner_id = make.partner_id.id
fpos = fpos_data and fpos_data.id or False
partner_addr = default_partner_addr
pricelist = default_pricelist
pricelist = partner.property_product_pricelist.id
if False in partner_addr.values():
raise osv.except_osv(_('Data Insufficient!'),_('Customer has no addresses defined!'))
raise osv.except_osv(_('Data Insufficient!'), _('Customer has no addresses defined!'))
vals = {
'origin': 'Opportunity: %s' % str(case.id),
'section_id': case.section_id and case.section_id.id or False,
'shop_id': make.shop_id.id,
'partner_id': partner_id,
'pricelist_id': pricelist,
'partner_invoice_id': partner_addr['invoice'],
'partner_order_id': partner_addr['contact'],
'partner_shipping_id': partner_addr['delivery'],
'date_order': time.strftime('%Y-%m-%d'),
'fiscal_position': fpos,
'origin': _('Opportunity: %s') % str(case.id),
'section_id': case.section_id and case.section_id.id or False,
'shop_id': make.shop_id.id,
'partner_id': partner.id,
'pricelist_id': pricelist,
'partner_invoice_id': partner_addr['invoice'],
'partner_order_id': partner_addr['contact'],
'partner_shipping_id': partner_addr['delivery'],
'date_order': time.strftime('%Y-%m-%d'),
'fiscal_position': fpos,
}
if partner_id:
partner = partner_obj.browse(cr, uid, partner_id, context=context)
if partner.id:
vals['user_id'] = partner.user_id and partner.user_id.id or uid
if make.analytic_account.id:
vals['project_id'] = make.analytic_account.id
new_id = sale_obj.create(cr, uid, vals)
for line in make.sale_order_line:
value = {}
value['order_id'] = new_id
value['name'] = line.name
value['delay'] = line.delay
value['product_id'] =line.product_id and line.product_id.id or False
value['price_unit'] = line.price_unit
value['tax_id'] = line.tax_id and [(6,0,map(lambda x: x.id,line.tax_id))] or False
value['type'] = line.type
value['product_uom_qty']=line.product_uom_qty
value['product_uom']=line.product_uom.id
value['product_uos_qty']=line.product_uos_qty
value['product_uos']=line.product_uos and line.product_uos.id or False
value['product_packaging'] = line.product_packaging and line.product_packaging.id or False
value['discount']=line.discount
value['notes']=line.notes
sale_line_obj.create(cr, uid, value)
stage_data = mod_obj._get_id(cr, uid, 'crm', 'stage_lead3')
stage_data = mod_obj.read(cr, uid, stage_data, ['res_id'])
case_obj.write(cr, uid, [case.id], {'ref': 'sale.order,%s' % new_id, 'stage_id': stage_data['res_id']})
value = {
'order_id': new_id,
'name': line.name,
'delay': line.delay,
'product_id': line.product_id and line.product_id.id or False,
'price_unit': line.price_unit,
'tax_id': line.tax_id and [(6, 0, map(lambda x: x.id, line.tax_id))] or False,
'type': line.type,
'product_uom_qty': line.product_uom_qty,
'product_uom': line.product_uom.id,
'product_uos_qty': line.product_uos_qty,
'product_uos': line.product_uos and line.product_uos.id or False,
'product_packaging': line.product_packaging and line.product_packaging.id or False,
'discount': line.discount,
'notes': line.notes
}
sale_line_obj.create(cr, uid, value, context=context)
case_obj.write(cr, uid, [case.id], {'ref': 'sale.order,%s' % new_id})
new_ids.append(new_id)
message = _('Opportunity ') + " '" + case.name + "' "+ _("is converted to Sales Quotation.")
self.log(cr, uid, case.id, message)
@@ -160,22 +149,22 @@ class crm_make_sale(osv.osv_memory):
return {}
if len(new_ids)<=1:
value = {
'domain': str([('id', 'in', new_ids)]),
'view_type': 'form',
'view_mode': 'form',
'res_model': 'sale.order',
'view_id': False,
'type': 'ir.actions.act_window',
'domain': str([('id', 'in', new_ids)]),
'view_type': 'form',
'view_mode': 'form',
'res_model': 'sale.order',
'view_id': False,
'type': 'ir.actions.act_window',
'res_id': new_ids and new_ids[0]
}
else:
value = {
'domain': str([('id', 'in', new_ids)]),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'sale.order',
'view_id': False,
'type': 'ir.actions.act_window',
'domain': str([('id', 'in', new_ids)]),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'sale.order',
'view_id': False,
'type': 'ir.actions.act_window',
'res_id': new_ids
}
return value
@@ -188,22 +177,22 @@ class crm_make_sale(osv.osv_memory):
return shop and shop[0] or False
_columns = {
'shop_id': fields.many2one('sale.shop', 'Shop', required=True),
'partner_id': fields.many2one('res.partner', 'Customer', required=True),
'sale_order_line': fields.one2many('sale.order.make.line', 'opportunity_order_id', 'Product Line'),
'analytic_account': fields.many2one('account.analytic.account', 'Analytic Account'),
'close': fields.boolean('Close Case', help='Check this to close the case after having created the sale order.'),
'shop_id': fields.many2one('sale.shop', 'Shop', required=True),
'partner_id': fields.many2one('res.partner', 'Customer', required=True),
'sale_order_line': fields.one2many('sale.order.make.line', 'opportunity_order_id', 'Product Line'),
'analytic_account': fields.many2one('account.analytic.account', 'Analytic Account'),
'close': fields.boolean('Close Case', help='Check this to close the case after having created the sale order.'),
}
_defaults = {
'shop_id': _get_shop_id,
'partner_id': _selectPartner,
'shop_id': _get_shop_id,
'partner_id': _selectPartner,
}
crm_make_sale()
class sale_order_make_line(osv.osv_memory):
def product_id_change(self, cr, uid, ids, product, qty=0,
uom=False, qty_uos=0, uos=False, name='', partner_id=False,
def product_id_change(self, cr, uid, ids, product, qty=0,
uom=False, qty_uos=0, uos=False, name='', partner_id=False,
lang=False, update_tax=True, packaging=False, flag=False):
if not partner_id:
raise osv.except_osv(_('No Customer Defined !'), _('You have to select a customer in the sale form !\nPlease set one customer before choosing a product.'))
@@ -216,28 +205,28 @@ class sale_order_make_line(osv.osv_memory):
_name = 'sale.order.make.line'
_description = 'Opportunity Sale Order Line'
_columns = {
'opportunity_order_id': fields.many2one('crm.make.sale', 'Order Reference', required=True, ondelete='cascade', select=True, readonly=True, ),
'name': fields.char('Description', size=256, required=True, select=True, ),
'delay': fields.float('Delivery Lead Time', required=True, help="Number of days between the order confirmation the the shipping of the products to the customer"),
'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True)], change_default=True),
'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Sale Price')),
'tax_id': fields.many2many('account.tax', 'sale_order_tax', 'order_line_id', 'tax_id', 'Taxes'),
'type': fields.selection([('make_to_stock', 'from stock'), ('make_to_order', 'on order')], 'Procurement Method', required=True),
'product_uom_qty': fields.float('Quantity (UoM)', digits=(16, 2), required=True, ),
'product_uom': fields.many2one('product.uom', 'Unit of Measure ', required=True, ),
'product_uos_qty': fields.float('Quantity (UoS)'),
'product_uos': fields.many2one('product.uom', 'Product UoS'),
'product_packaging': fields.many2one('product.packaging', 'Packaging'),
'discount': fields.float('Discount (%)', digits=(16, 2)),
'notes': fields.text('Notes'),
'opportunity_order_id': fields.many2one('crm.make.sale', 'Order Reference', required=True, ondelete='cascade', select=True, readonly=True,),
'name': fields.char('Description', size=256, required=True, select=True,),
'delay': fields.float('Delivery Lead Time', required=True, help="Number of days between the order confirmation the the shipping of the products to the customer"),
'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True)], change_default=True),
'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Sale Price')),
'tax_id': fields.many2many('account.tax', 'sale_order_tax', 'order_line_id', 'tax_id', 'Taxes'),
'type': fields.selection([('make_to_stock', 'from stock'), ('make_to_order', 'on order')], 'Procurement Method', required=True),
'product_uom_qty': fields.float('Quantity (UoM)', digits=(16, 2), required=True,),
'product_uom': fields.many2one('product.uom', 'Unit of Measure ', required=True,),
'product_uos_qty': fields.float('Quantity (UoS)'),
'product_uos': fields.many2one('product.uom', 'Product UoS'),
'product_packaging': fields.many2one('product.packaging', 'Packaging'),
'discount': fields.float('Discount (%)', digits=(16, 2)),
'notes': fields.text('Notes'),
}
_order = 'sequence, id'
_defaults = {
'discount': 0.0,
'delay': 0.0,
'product_uom_qty': 1,
'product_uos_qty': 1,
'type': 'make_to_stock',
'discount': 0.0,
'delay': 0.0,
'product_uom_qty': 1,
'product_uos_qty': 1,
'type': 'make_to_stock',
'product_packaging': False
}
+3 -5
View File
@@ -17,11 +17,9 @@
<field name="invoicing_method" select="1"/>
<field name="active" select="1"/>
</group>
<notebook>
<page string="Notes">
<field name="note" colspan="2" nolabel="1"/>
</page>
</notebook>
<separator string="Notes" colspan="3"/>
<newline/>
<field name="note" colspan="3" nolabel="1"/>
</form>
</field>
</record>
+1 -1
View File
@@ -164,7 +164,7 @@ class wiki_wiki2(osv.osv):
@param uid: the current user’s ID for security checks,
@param id: Give wiki page's ID """
return super(Wiki, self).copy_data(cr, uid, id, {'wiki_id': False}, context)
return super(wiki_wiki2, self).copy_data(cr, uid, id, {'wiki_id': False}, context)
def create_history(self, cr, uid, ids, vals, context=None):
history_id = False