[MRG] merge with lp:~openerp-dev/openobject-addons/trunk-v62_config_sale-uco
bzr revid: tpa@tinyerp.com-20120302090850-evcay5oi6ravwy5e
This commit is contained in:
@@ -30,17 +30,16 @@ class account_configuration(osv.osv_memory):
|
||||
('no_tax', 'No Tax'),
|
||||
('global_on_order', 'Global On Order'),
|
||||
('on_order_line', 'On Order Lines'),
|
||||
], 'Taxes', required=True,
|
||||
help = """
|
||||
This allows you to set tax policy to sale order.
|
||||
if you want to set global tax on sale order then select Global On Order it will add 'Global On Order' group to employees.
|
||||
if you want to set tax On Order Lines then select On Order Lines it will add 'On Order Lines' group to employees.
|
||||
], 'Taxes', required=True,
|
||||
help="""
|
||||
If you want to apply global tax on sale order then select 'Global On Order' it will add 'Global On Order' group to employees.
|
||||
If you want to apply different taxes for sale order lines then select 'On Order Lines' it will add 'On Order Lines' group to employees.
|
||||
"""),
|
||||
'tax_value': fields.float('Value'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'tax_policy': 'global_on_order',
|
||||
'tax_policy': 'global_on_order',
|
||||
}
|
||||
|
||||
def get_default_tax_policy(self, cr, uid, ids, context=None):
|
||||
@@ -52,14 +51,14 @@ class account_configuration(osv.osv_memory):
|
||||
else:
|
||||
applied_groups.update({'tax_policy': 'no_tax'})
|
||||
return applied_groups
|
||||
|
||||
|
||||
def _check_default_tax(self, cr, uid, context=None):
|
||||
ir_values_obj = self.pool.get('ir.values')
|
||||
for tax in ir_values_obj.get(cr, uid, 'default', False, ['product.product']):
|
||||
if tax[1] == 'taxes_id':
|
||||
return tax[2]
|
||||
return False
|
||||
|
||||
|
||||
def default_get(self, cr, uid, fields_list, context=None):
|
||||
ir_values_obj = self.pool.get('ir.values')
|
||||
res = super(account_configuration, self).default_get(cr, uid, fields_list, context=context)
|
||||
@@ -75,7 +74,7 @@ class account_configuration(osv.osv_memory):
|
||||
if self._check_default_tax(cr, uid, context) and res['fields'].get('tax_value'):
|
||||
res['fields']['tax_value'] = {'domain': [], 'views': {}, 'context': {}, 'selectable': True, 'type': 'many2one', 'relation': 'account.tax', 'string': 'Value'}
|
||||
return res
|
||||
|
||||
|
||||
def set_tax_policy(self, cr, uid, ids, vals, context=None):
|
||||
data_obj = self.pool.get('ir.model.data')
|
||||
users_obj = self.pool.get('res.users')
|
||||
@@ -103,30 +102,10 @@ class account_configuration(osv.osv_memory):
|
||||
users_obj.write(cr, uid, [uid], {'groups_id': [(3,remove_group_id)]})
|
||||
ir_values_obj.set(cr, uid, 'default', False, 'groups_id', ['res.users'], [(3,remove_group_id)])
|
||||
else:
|
||||
groups = [order_group_id, remove_group_id]
|
||||
groups = [order_group_id, order_line_group_id]
|
||||
for group_id in groups:
|
||||
groups_obj.write(cr, uid, [user_group_id], {'implied_ids': [(3,group_id)]})
|
||||
users_obj.write(cr, uid, [uid], {'groups_id': [(3,group_id)]})
|
||||
ir_values_obj.set(cr, uid, 'default', False, 'groups_id', ['res.users'], [(3,group_id)])
|
||||
|
||||
def set_tax_value(self, cr, uid, ids, vals, context=None):
|
||||
chart_account_obj = self.pool.get('wizard.multi.charts.accounts')
|
||||
acc_installer_obj = self.pool.get('account.installer')
|
||||
chart_template_obj = self.pool.get('account.chart.template')
|
||||
tax_obj = self.pool.get('account.tax')
|
||||
chart_template_ids = chart_template_obj.search(cr, uid, [('visible', '=', True)], context=context)
|
||||
taxes = []
|
||||
if chart_template_ids:
|
||||
name = _('Tax %.2f%%') % vals.get('tax_value')
|
||||
taxes = tax_obj.search(cr, uid, [('name', '=', name)], context=context)
|
||||
check_default_taxes = self._check_default_tax(cr, uid, context)
|
||||
if not check_default_taxes and not taxes:
|
||||
installer_id = acc_installer_obj.create(cr, uid, {}, context=context)
|
||||
acc_installer_obj.execute(cr, uid, [installer_id], context=context)
|
||||
if chart_template_ids:
|
||||
code_digits = chart_account_obj.onchange_chart_template_id(cr, uid, [], chart_template_ids[0], context=context)['value']['code_digits']
|
||||
object_id = chart_account_obj.create(cr, uid, {'code_digits': code_digits}, context=context)
|
||||
chart_account_obj.execute(cr, uid, [object_id], context=context)
|
||||
return check_default_taxes
|
||||
|
||||
account_configuration()
|
||||
@@ -117,11 +117,13 @@
|
||||
<field name="inherit_id" ref="sale.view_sales_config"/>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="module_account_analytic_analysis" position="after">
|
||||
<newline/>
|
||||
<field name="module_analytic_user_function" attrs="{'invisible': [('account_analytic_analysis','=',False)]}"/>
|
||||
<field name="module_analytic_journal_billing_rate" attrs="{'invisible': [('account_analytic_analysis','=',False)]}"/>
|
||||
</field>
|
||||
<group name="sale_order" position="after">
|
||||
<group col="4" colspan="4">
|
||||
<separator string="Contracts" colspan="4"/>
|
||||
<field name="module_analytic_user_function" attrs="{'invisible': [('module_account_analytic_analysis','=',False)]}"/>
|
||||
<field name="module_analytic_journal_billing_rate" attrs="{'invisible': [('module_account_analytic_analysis','=',False)]}"/>
|
||||
</group>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
+11
-15
@@ -25,16 +25,12 @@ class crm_configuration(osv.osv_memory):
|
||||
_inherit = 'res.config'
|
||||
|
||||
_columns = {
|
||||
'module_crm_caldav' : fields.boolean("Caldav synchronization",
|
||||
help="""
|
||||
This allows you Caldav features in Meeting, Share meeting with other calendar clients like sunbird.
|
||||
It installs crm_caldav module.
|
||||
"""),
|
||||
'module_fetchmail_crm': fields.boolean("Lead/Opportunity mail gateway",
|
||||
help = """
|
||||
this allows you to configure your incoming mail server.
|
||||
It installs fetchmail_crm module.
|
||||
"""),
|
||||
'module_crm_caldav' : fields.boolean("Use caldav to synchronize Meetings",
|
||||
help="""This allows you Caldav features in Meeting, Share meeting with other calendar clients like sunbird.
|
||||
It installs crm_caldav module."""),
|
||||
'module_fetchmail_crm': fields.boolean("Lead/Opportunity mail gateway", help="""
|
||||
This allows you to configure your incoming mail server,
|
||||
It installs fetchmail_crm module."""),
|
||||
'server' : fields.char('Server Name', size=256),
|
||||
'port' : fields.integer('Port'),
|
||||
'type': fields.selection([
|
||||
@@ -99,7 +95,7 @@ class crm_configuration(osv.osv_memory):
|
||||
ir_values_obj = self.pool.get('ir.values')
|
||||
result = {}
|
||||
installed_modules = self.get_default_installed_modules(cr, uid, ids, context=context)
|
||||
if 'fetchmail_crm' in installed_modules.keys():
|
||||
if 'module_fetchmail_crm' in installed_modules.keys():
|
||||
for val in ir_values_obj.get(cr, uid, 'default', False, ['fetchmail.server']):
|
||||
result.update({val[1]: val[2]})
|
||||
return result
|
||||
@@ -120,11 +116,11 @@ class crm_configuration(osv.osv_memory):
|
||||
model_obj = self.pool.get('ir.model')
|
||||
fetchmail_obj = self.pool.get('fetchmail.server')
|
||||
ir_values_obj = self.pool.get('ir.values')
|
||||
if vals.get('fetchmail_crm'):
|
||||
object_id = model_obj.search(cr, uid, [('model','=','crm.lead')])[0]
|
||||
object_id = model_obj.search(cr, uid, [('model','=','crm.lead')])
|
||||
if vals.get('module_fetchmail_crm') and object_id:
|
||||
fetchmail_vals = {
|
||||
'name': 'Incoming Leads',
|
||||
'object_id': object_id,
|
||||
'object_id': object_id[0],
|
||||
'server': vals.get('server'),
|
||||
'port': vals.get('port'),
|
||||
'is_ssl': vals.get('is_ssl'),
|
||||
@@ -133,7 +129,7 @@ class crm_configuration(osv.osv_memory):
|
||||
'password': vals.get('password')
|
||||
}
|
||||
server_ids = fetchmail_obj.search(cr, uid, [])
|
||||
if not self.get_default_installed_modules(cr, uid, ['fetchmail_crm'], context) or not server_ids:
|
||||
if not self.get_default_installed_modules(cr, uid, ids, context) or not server_ids:
|
||||
tt = fetchmail_obj.create(cr, uid, fetchmail_vals, context=context)
|
||||
else:
|
||||
fetchmail_ids = fetchmail_obj.search(cr, uid, [('name','=','Incoming Leads')], context=context)
|
||||
|
||||
@@ -5,34 +5,34 @@
|
||||
<field name="name">Sales Application</field>
|
||||
<field name="model">res.config</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="base.res_config_view_base"/>
|
||||
<field name="inherit_id" ref="base.res_config_view_for_all"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//form/group[@name='Contracts']" position="after">
|
||||
<group col="8" colspan="4" name="emails">
|
||||
<group col="4" colspan="2">
|
||||
<separator string="Plugins" colspan="4"/>
|
||||
<newline/>
|
||||
<field name="module_plugin_thunderbird" colspan="2"/>
|
||||
<newline/>
|
||||
<field name="module_plugin_outlook" colspan="2"/>
|
||||
<newline/>
|
||||
</group>
|
||||
<group name="crm" position="inside">
|
||||
<group col="8" colspan="4" name="emails">
|
||||
<group col="4" colspan="2">
|
||||
<separator string="Plugins" colspan="4"/>
|
||||
<newline/>
|
||||
<field name="module_plugin_thunderbird" colspan="2"/>
|
||||
<newline/>
|
||||
<field name="module_plugin_outlook" colspan="2"/>
|
||||
<newline/>
|
||||
</group>
|
||||
|
||||
<group col="4" colspan="2">
|
||||
<separator string="Emails" colspan="4"/>
|
||||
<field name="module_fetchmail_crm" />
|
||||
<newline/>
|
||||
<group col="4" colspan="2"
|
||||
attrs="{'invisible': [('module_fetchmail_crm','=',False)]}">
|
||||
<field name="server" attrs="{'required': [('module_fetchmail_crm','=',True)]}"/>
|
||||
<field name="type" nolabel="1" on_change="onchange_server_type(type, is_ssl)" attrs="{'required': [('module_fetchmail_crm','=',True)]}"/>
|
||||
<field name="port" attrs="{'required': [('module_fetchmail_crm','=',True)]}"/>
|
||||
<field name="is_ssl" on_change="onchange_server_type(type, is_ssl)"/>
|
||||
<newline/>
|
||||
<field name="user" attrs="{'required': [('module_fetchmail_crm','=',True)]}"/>
|
||||
<field name="password" password="True" attrs="{'required': [('module_fetchmail_crm','=',True)]}"/>
|
||||
</group>
|
||||
</group>
|
||||
<group col="4" colspan="2">
|
||||
<separator string="Emails" colspan="4"/>
|
||||
<field name="module_fetchmail_crm" />
|
||||
<newline/>
|
||||
<group col="4" colspan="2"
|
||||
attrs="{'invisible': [('module_fetchmail_crm','=',False)]}">
|
||||
<field name="server" attrs="{'required': [('module_fetchmail_crm','=',True)]}"/>
|
||||
<field name="type" nolabel="1" on_change="onchange_server_type(type, is_ssl)" attrs="{'required': [('module_fetchmail_crm','=',True)]}"/>
|
||||
<field name="port" attrs="{'required': [('module_fetchmail_crm','=',True)]}"/>
|
||||
<field name="is_ssl" on_change="onchange_server_type(type, is_ssl)"/>
|
||||
<newline/>
|
||||
<field name="user" attrs="{'required': [('module_fetchmail_crm','=',True)]}"/>
|
||||
<field name="password" password="True" attrs="{'required': [('module_fetchmail_crm','=',True)]}"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
<group colspan="4" col="4" name="synchronization">
|
||||
@@ -59,8 +59,11 @@
|
||||
<field name="module_google_map"/>
|
||||
</group>
|
||||
</group>
|
||||
</xpath>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="base.menu_sale_config" name="Sales" parent="base.menu_config" sequence="1" action="base.action_sale_config"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -52,9 +52,9 @@
|
||||
<field name="name">Sales Application</field>
|
||||
<field name="model">res.config</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="base.res_config_view_base"/>
|
||||
<field name="inherit_id" ref="base.res_config_view_for_all"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="plugin_outlook" position="after">
|
||||
<field name="module_plugin_outlook" position="after">
|
||||
<button name="%(action_outlook_installer)d" type="action" string="Configure" icon="gtk-execute"/>
|
||||
</field>
|
||||
</field>
|
||||
|
||||
@@ -59,9 +59,9 @@
|
||||
<field name="name">Sales Application</field>
|
||||
<field name="model">res.config</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="base.res_config_view_base"/>
|
||||
<field name="inherit_id" ref="base.res_config_view_for_all"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="plugin_thunderbird" position="after">
|
||||
<field name="module_plugin_thunderbird" position="after">
|
||||
<button name="%(action_thunderbird_installer)d" type="action" string="Configure" icon="gtk-execute"/>
|
||||
</field>
|
||||
</field>
|
||||
|
||||
@@ -25,15 +25,14 @@ class product_groups_configuration(osv.osv_memory):
|
||||
_inherit = 'res.config'
|
||||
|
||||
_columns = {
|
||||
'group_sale_pricelist_per_customer':fields.boolean("Pricelist per customer ",
|
||||
help="""
|
||||
Allows to manage different prices based on rules per category of customers. Example: 10% for retailers, promotion of 5 EUR on this product,
|
||||
It assigns the "pricelist" group to all employees
|
||||
"""),
|
||||
'group_sale_pricelist_per_customer':fields.boolean("Pricelist per customer",
|
||||
help="""Allows to manage different prices based on rules per category of customers.
|
||||
Example: 10% for retailers, promotion of 5 EUR on this product, etc.
|
||||
It assigns the "Pricelist" group to all employees."""),
|
||||
'group_sale_uom_per_product':fields.boolean("UOM per product",
|
||||
help="""
|
||||
This allow different unit of measure per product,
|
||||
It assigns the "UOM per product" group to all employees
|
||||
Allows you to select and maintain different unit of measures per product.
|
||||
It assigns the "UOM per product" group to all employees.
|
||||
"""),
|
||||
}
|
||||
|
||||
|
||||
+25
-106
@@ -23,31 +23,23 @@ from osv import fields, osv
|
||||
import pooler
|
||||
from tools.translate import _
|
||||
|
||||
MODULE_LIST = [
|
||||
'analytic_user_function', 'analytic_journal_billing_rate', 'import_sugarcrm',
|
||||
'import_google', 'crm_caldav', 'wiki_sale_faq', 'base_contact','sale_layout','warning',
|
||||
'google_map', 'fetchmail_crm', 'plugin_thunderbird', 'plugin_outlook','account_analytic_analysis',
|
||||
'project_timesheet', 'account_analytic_analysis', 'project_mrp', 'delivery',
|
||||
'sale_margin', 'sale_journal'
|
||||
]
|
||||
|
||||
class sale_configuration(osv.osv_memory):
|
||||
_inherit = 'res.config'
|
||||
|
||||
_columns = {
|
||||
'sale_orders': fields.boolean('Based on Sales Orders',),
|
||||
'deli_orders': fields.boolean('Based on Delivery Orders'),
|
||||
'sale_orders': fields.boolean('Based on Sales Orders',
|
||||
help="To allow your salesman to make invoices for sale order lines using 'Lines to Invoice' menu."),
|
||||
'deli_orders': fields.boolean('Based on Delivery Orders',
|
||||
help="To allow your salesman to make invoices for Delivery Orders using 'Deliveries to Invoice' menu."),
|
||||
'task_work': fields.boolean('Based on Tasks\' Work',
|
||||
help="""
|
||||
This allows to you transfer the entries under tasks defined for Project Management to
|
||||
help="""Lets you transfer the entries under tasks defined for Project Management to
|
||||
the Timesheet line entries for particular date and particular user with the effect of creating, editing and deleting either ways.
|
||||
Automatically creates project tasks from procurement lines.
|
||||
It installs the project_timesheet and project_mrp module.
|
||||
"""),
|
||||
'timesheet': fields.boolean('Based on Timesheet',
|
||||
and to automatically creates project tasks from procurement lines.
|
||||
It installs the project_timesheet and project_mrp module"""),
|
||||
'module_account_analytic_analysis': fields.boolean('Based on Timesheet',
|
||||
help = """For modifying account analytic view to show important data to project manager of services companies,
|
||||
You can also view the report of account analytic summary user-wise as well as month wise
|
||||
,It installs the account_analytic_analysis module."""),
|
||||
You can also view the report of account analytic summary user-wise as well as month wise.
|
||||
It installs the account_analytic_analysis module."""),
|
||||
'order_policy': fields.selection([
|
||||
('manual', 'Invoice Based on Sales Orders'),
|
||||
('picking', 'Invoice Based on Deliveries'),
|
||||
@@ -59,9 +51,9 @@ class sale_configuration(osv.osv_memory):
|
||||
It installs the delivery module.
|
||||
"""),
|
||||
'time_unit': fields.many2one('product.uom','Working Time Unit'),
|
||||
'picking_policy' : fields.boolean("Deliver all products at once?", help = "You can set picking policy from sale order that will allow you to deliver all products at one."),
|
||||
'group_sale_delivery_address':fields.boolean("Multiple Address",help="This allows you to set different delivery address and picking address.It assigns Multiple Address group to employee."),
|
||||
'group_sale_disc_per_sale_order_line':fields.boolean("Discounts per sale order lines ",help="This allows you to apply discounts per sale order lines. It assigns Discounts per sale order lines group to employee."),
|
||||
'picking_policy' : fields.boolean("Deliver all products at once?", help = "You can set picking policy on sale order that will allow you to deliver all products at once."),
|
||||
'group_sale_delivery_address':fields.boolean("Multiple Address",help="This allows you to set different delivery address and picking address,it assigns Multiple Address group to all employees."),
|
||||
'group_sale_disc_per_sale_order_line':fields.boolean("Discounts per sale order lines ",help="This allows you to apply discounts per sale order lines, it assigns Discounts per sale order lines group to all employees."),
|
||||
'module_sale_layout':fields.boolean("Notes & subtotals per line",help="Allows to format sale order lines using notes, separators, titles and subtotals. It installs the sale_layout module."),
|
||||
'module_warning': fields.boolean("Alerts by products or customers",
|
||||
help="""To trigger warnings in OpenERP objects.
|
||||
@@ -81,50 +73,16 @@ class sale_configuration(osv.osv_memory):
|
||||
'module_analytic_journal_billing_rate' : fields.boolean("Billing rates by contracts",
|
||||
help=""" This allows you to define what is the default invoicing rate for a specific journal on a given account.
|
||||
It installs analytic_journal_billing_rate module.
|
||||
"""),
|
||||
'module_account_analytic_analysis': fields.boolean('Contracts',
|
||||
help = """
|
||||
For modifying account analytic view to show important data to project manager of services companies,
|
||||
You can also view the report of account analytic summary user-wise as well as month wise.
|
||||
It installs the account_analytic_analysis module."""),
|
||||
""")
|
||||
}
|
||||
|
||||
def get_default_applied_groups(self, cr, uid, ids, context=None):
|
||||
applied_groups = {}
|
||||
user_obj = self.pool.get('res.users')
|
||||
dataobj = self.pool.get('ir.model.data')
|
||||
|
||||
groups = []
|
||||
user_group_ids = user_obj.browse(cr, uid, uid, context=context).groups_id
|
||||
|
||||
for group_id in user_group_ids:
|
||||
groups.append(group_id.id)
|
||||
|
||||
for id in groups:
|
||||
key_id = dataobj.search(cr, uid,[('res_id','=',id),('model','=','res.groups')],context=context)
|
||||
key = dataobj.browse(cr, uid, key_id[0], context=context).name
|
||||
applied_groups[key] = True
|
||||
|
||||
return applied_groups
|
||||
|
||||
|
||||
def get_default_installed_modules(self, cr, uid, ids, context=None):
|
||||
module_obj = self.pool.get('ir.module.module')
|
||||
data_obj = self.pool.get('ir.model.data')
|
||||
module_ids = module_obj.search(cr, uid,
|
||||
[('name','in',MODULE_LIST),
|
||||
('state','in',['to install', 'installed', 'to upgrade'])],
|
||||
context=context)
|
||||
installed_modules = dict([(mod.name,True) for mod in module_obj.browse(cr, uid, module_ids, context=context)])
|
||||
if installed_modules.get('project_mrp') and installed_modules.get('project_timesheet'):
|
||||
installed_modules = super(sale_configuration, self).get_default_installed_modules(cr, uid, ids, context=context)
|
||||
if installed_modules.get('module_project_mrp') and installed_modules.get('module_project_timesheet'):
|
||||
installed_modules['task_work'] = True
|
||||
prod_id = data_obj.get_object(cr, uid, 'product', 'product_consultant').id
|
||||
uom_id = self.pool.get('product.product').browse(cr, uid, prod_id).uom_id.id
|
||||
defaults.update({'time_unit': uom_id})
|
||||
if installed_modules.get('account_analytic_analysis'):
|
||||
installed_modules['timesheet'] = True
|
||||
prod_id = data_obj.get_object(cr, uid, 'product', 'product_consultant').id
|
||||
uom_id = self.pool.get('product.product').browse(cr, uid, prod_id).uom_id.id
|
||||
defaults.update({'time_unit': uom_id})
|
||||
return installed_modules
|
||||
|
||||
def get_default_sale_configs(self, cr, uid, ids, context=None):
|
||||
@@ -145,13 +103,6 @@ class sale_configuration(osv.osv_memory):
|
||||
result[res[1]] = res[2]
|
||||
return result
|
||||
|
||||
def get_default_groups(self, cr, uid, ids, context=None):
|
||||
ir_values_obj = self.pool.get('ir.values')
|
||||
result = {}
|
||||
for res in ir_values_obj.get(cr, uid, 'default', False, ['res.users']):
|
||||
result[res[1]] = res[2]
|
||||
return result
|
||||
|
||||
def default_get(self, cr, uid, fields_list, context=None):
|
||||
result = super(sale_configuration, self).default_get(
|
||||
cr, uid, fields_list, context=context)
|
||||
@@ -178,27 +129,16 @@ class sale_configuration(osv.osv_memory):
|
||||
#TODO: TO BE IMPLEMENTED
|
||||
for method in dir(self):
|
||||
if method.startswith('set_'):
|
||||
vals['modules'] = MODULE_LIST
|
||||
getattr(self, method)(cr, uid, ids, vals, context)
|
||||
return True
|
||||
|
||||
def set_modules(self, cr, uid, ids, vals, context=None):
|
||||
module_obj = self.pool.get('ir.module.module')
|
||||
MODULE_LIST = vals.get('modules')
|
||||
def set_installed_modules(self, cr, uid, ids, vals, context=None):
|
||||
if vals.get('task_work'):
|
||||
vals.update({'project_timesheet': True,'project_mrp': True})
|
||||
if vals.get('timesheet'):
|
||||
vals.update({'account_analytic_analysis': True})
|
||||
for k, v in vals.items():
|
||||
if k in MODULE_LIST:
|
||||
installed = self.get_default_installed_modules(cr, uid, [k], context)
|
||||
if v == True and not installed.get(k):
|
||||
module_id = module_obj.search(cr, uid, [('name','=',k)])
|
||||
module_obj.button_immediate_install(cr, uid, module_id, context)
|
||||
elif v == False and installed.get(k):
|
||||
module_id = module_obj.search(cr, uid, [('name','=',k)])
|
||||
module_obj.button_uninstall(self, cr, uid, module_id, context=None)
|
||||
module_obj.button_upgrade(self, cr, uid, module_id, context=None)
|
||||
vals.update({'module_project_timesheet': True, 'module_project_mrp': True})
|
||||
else:
|
||||
vals.update({'module_project_timesheet': False, 'module_project_mrp': False})
|
||||
|
||||
super(sale_configuration, self).set_installed_modules(cr, uid, ids, vals, context=context)
|
||||
|
||||
def set_sale_defaults(self, cr, uid, ids, vals, context=None):
|
||||
ir_values_obj = self.pool.get('ir.values')
|
||||
@@ -235,30 +175,9 @@ class sale_configuration(osv.osv_memory):
|
||||
|
||||
return res
|
||||
|
||||
def set_groups(self, cr, uid, ids, vals, context=None):
|
||||
data_obj = self.pool.get('ir.model.data')
|
||||
users_obj = self.pool.get('res.users')
|
||||
groups_obj = self.pool.get('res.groups')
|
||||
ir_values_obj = self.pool.get('ir.values')
|
||||
dummy,user_group_id = data_obj.get_object_reference(cr, uid, 'base', 'group_user')
|
||||
for group in vals.keys():
|
||||
if group.startswith('group_'):
|
||||
dummy,group_id = data_obj.get_object_reference(cr, uid, 'base', group)
|
||||
if vals[group]:
|
||||
groups_obj.write(cr, uid, [user_group_id], {'implied_ids': [(4,group_id)]})
|
||||
users_obj.write(cr, uid, [uid], {'groups_id': [(4,group_id)]})
|
||||
ir_values_obj.set(cr, uid, 'default', False, 'groups_id', ['res.users'], [(4,group_id)])
|
||||
else:
|
||||
groups_obj.write(cr, uid, [user_group_id], {'implied_ids': [(3,group_id)]})
|
||||
users_obj.write(cr, uid, [uid], {'groups_id': [(3,group_id)]})
|
||||
ir_values_obj.set(cr, uid, 'default', False, 'groups_id', ['res.users'], [(3,group_id)])
|
||||
|
||||
def onchange_tax_policy(self, cr, uid, ids, tax_policy, tax_value, context=None):
|
||||
res = {'value': {}}
|
||||
if isinstance(tax_value, (int)):
|
||||
self.set_default_taxes(cr, uid, ids, {'tax_value': [tax_value]}, context=context)
|
||||
def onchange_tax_policy(self, cr, uid, ids, tax_policy, context=None):
|
||||
self.set_tax_policy(cr, uid, ids, {'tax_policy': tax_policy}, context=context)
|
||||
return res
|
||||
return {'value': {}}
|
||||
|
||||
def set_default_taxes(self, cr, uid, ids, vals, context=None):
|
||||
ir_values_obj = self.pool.get('ir.values')
|
||||
|
||||
@@ -5,87 +5,65 @@
|
||||
<field name="name">Sales Application</field>
|
||||
<field name="model">res.config</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="base.res_config_view_base"/>
|
||||
<field name="inherit_id" ref="base.res_config_view_for_all"/>
|
||||
<field name="arch" type="xml">
|
||||
<form position="replace">
|
||||
<form string="Sale Configuration">
|
||||
<separator string="Picking and Invoice Policy" colspan="4"/>
|
||||
<group colspan="4" col="8">
|
||||
<group colspan="4" col="4">
|
||||
<field name="sale_orders"/>
|
||||
<newline/>
|
||||
<field name="deli_orders"/>
|
||||
<newline/>
|
||||
<field name="task_work"/>
|
||||
<newline/>
|
||||
<field name="timesheet"/>
|
||||
<newline/>
|
||||
</group>
|
||||
<group colspan="4" col="4">
|
||||
<field name="order_policy" attrs="{'invisible':['|',('sale_orders','=',False),('deli_orders','=',False)]}"/>
|
||||
<newline/>
|
||||
<field name="module_delivery" attrs="{'invisible':[('sale_orders','=',False), ('deli_orders','=',False)]}"/>
|
||||
<newline/>
|
||||
<field name="picking_policy" attrs="{'invisible':[('deli_orders','=',False)]}"/>
|
||||
<newline/>
|
||||
<field name="time_unit" domain="[('category_id.name','=','Working Time')]" attrs="{'invisible':[('task_work','=',False),('timesheet','=',False)],'required': [('timesheet','=',True)]}"/>
|
||||
</group>
|
||||
<group name="sales" position="inside">
|
||||
<separator string="Picking and Invoice Policy" colspan="4"/>
|
||||
<group colspan="4" col="8">
|
||||
<group colspan="4" col="4">
|
||||
<field name="sale_orders"/>
|
||||
<newline/>
|
||||
<field name="deli_orders"/>
|
||||
<newline/>
|
||||
<field name="task_work"/>
|
||||
<newline/>
|
||||
<field name="module_account_analytic_analysis"/>
|
||||
<newline/>
|
||||
</group>
|
||||
|
||||
<separator string="Sale Order" colspan="4"/>
|
||||
<group colspan="4" col="8">
|
||||
<group colspan="4" col="4">
|
||||
<field name="group_sale_pricelist_per_customer"/>
|
||||
<newline/>
|
||||
<group colspan="4" col="4">
|
||||
<field name="tax_policy" on_change="onchange_tax_policy(tax_policy,tax_value)"/>
|
||||
<field name="tax_value" nolabel="1" attrs="{'invisible':[('tax_policy','=','no_tax')]}"
|
||||
on_change="onchange_tax_policy(tax_policy,tax_value)"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<field name="module_sale_margin"/>
|
||||
<newline/>
|
||||
<field name="module_warning"/>
|
||||
<newline/>
|
||||
</group>
|
||||
<group colspan="4" col="4">
|
||||
<newline/>
|
||||
<field name="group_sale_uom_per_product"/>
|
||||
<newline/>
|
||||
<field name="group_sale_delivery_address"/>
|
||||
<newline/>
|
||||
<field name="group_sale_disc_per_sale_order_line"/>
|
||||
<newline/>
|
||||
<field name="module_sale_layout"/>
|
||||
<newline/>
|
||||
<field name="module_sale_journal"/>
|
||||
<newline/>
|
||||
</group>
|
||||
<group colspan="4" col="4">
|
||||
<field name="order_policy" attrs="{'invisible':['|',('sale_orders','=',False),('deli_orders','=',False)]}"/>
|
||||
<newline/>
|
||||
<field name="module_delivery" attrs="{'invisible':[('sale_orders','=',False), ('deli_orders','=',False)]}"/>
|
||||
<newline/>
|
||||
<field name="picking_policy" attrs="{'invisible':[('deli_orders','=',False)]}"/>
|
||||
<newline/>
|
||||
<field name="time_unit" domain="[('category_id.name','=','Working Time')]" attrs="{'invisible':[('task_work','=',False),('module_account_analytic_analysis','=',False)],'required': [('module_account_analytic_analysis','=',True)]}"/>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
<separator string="Contracts" colspan="4"/>
|
||||
<group name="Contracts" colspan="4" col="4">
|
||||
<group colspan="4" col="4">
|
||||
<field name="module_account_analytic_analysis"/>
|
||||
<newline/>
|
||||
</group>
|
||||
<separator string="Sale Order" colspan="4"/>
|
||||
<group colspan="4" col="8" name="sale_order">
|
||||
<group colspan="4" col="4">
|
||||
<field name="group_sale_pricelist_per_customer"/>
|
||||
<newline/>
|
||||
<group col="2" colspan="1">
|
||||
<field name="tax_policy" on_change="onchange_tax_policy(tax_policy)"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<field name="module_sale_margin"/>
|
||||
<newline/>
|
||||
<field name="module_warning"/>
|
||||
<newline/>
|
||||
</group>
|
||||
|
||||
</form>
|
||||
</form>
|
||||
<group colspan="4" col="4">
|
||||
<newline/>
|
||||
<field name="group_sale_uom_per_product"/>
|
||||
<newline/>
|
||||
<field name="group_sale_delivery_address"/>
|
||||
<newline/>
|
||||
<field name="group_sale_disc_per_sale_order_line"/>
|
||||
<newline/>
|
||||
<field name="module_sale_layout"/>
|
||||
<newline/>
|
||||
<field name="module_sale_journal"/>
|
||||
<newline/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_sale_config" model="ir.actions.act_window">
|
||||
<field name="name">Configure Sales Application</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">res.config</field>
|
||||
<field name="view_id" ref="view_sales_config"/>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_sale_config" name="Sales" parent="base.menu_config" sequence="1" action="action_sale_config"/>
|
||||
<menuitem id="base.menu_sale_config" name="Sales" parent="base.menu_config" sequence="1" action="base.action_sale_config"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
+9
-1
@@ -270,7 +270,7 @@ class sale_order(osv.osv):
|
||||
'payment_term': fields.many2one('account.payment.term', 'Payment Term'),
|
||||
'fiscal_position': fields.many2one('account.fiscal.position', 'Fiscal Position'),
|
||||
'company_id': fields.related('shop_id','company_id',type='many2one',relation='res.company',string='Company',store=True,readonly=True),
|
||||
'tax_id': fields.many2one('account.tax','Global Tax'),
|
||||
'tax_id': fields.many2one('account.tax', 'Tax'),
|
||||
}
|
||||
_defaults = {
|
||||
'picking_policy': 'direct',
|
||||
@@ -310,6 +310,14 @@ class sale_order(osv.osv):
|
||||
if shop.pricelist_id.id:
|
||||
v['pricelist_id'] = shop.pricelist_id.id
|
||||
return {'value': v}
|
||||
|
||||
def onchange_taxes(self, cr, uid, ids, tax_id, context=None):
|
||||
sol_obj = self.pool.get('sale.order.line')
|
||||
res = {'value': {}}
|
||||
for order in self.browse(cr, uid, ids, context=context):
|
||||
for line in order.order_line:
|
||||
sol_obj.write(cr, uid, line.id, {'tax_id': [(4,tax_id)]})
|
||||
return res
|
||||
|
||||
def action_cancel_draft(self, cr, uid, ids, *args):
|
||||
if not len(ids):
|
||||
|
||||
@@ -155,7 +155,8 @@
|
||||
<separator colspan="5" string="Notes" groups="base.group_sale_notes_subtotal"/>
|
||||
<field colspan="5" name="notes" nolabel="1" groups="base.group_sale_notes_subtotal"/>
|
||||
<separator colspan="5" string="Taxes" groups="base.group_sale_taxes_on_order_line"/>
|
||||
<field colspan="5" name="tax_id" nolabel="1" domain="[('parent_id','=',False),('type_tax_use','<>','purchase')]" groups="base.group_sale_taxes_on_order_line"/>
|
||||
<field colspan="5" name="tax_id" nolabel="1" domain="[('parent_id','=',False),('type_tax_use','<>','purchase')]"
|
||||
groups="base.group_sale_taxes_on_order_line" />
|
||||
<group colspan="5" col="5" groups="base.group_extended">
|
||||
<separator colspan="5" string="States"/>
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,confirmed,done" statusbar_colors='{"exception":"red","cancel":"red"}'/>
|
||||
@@ -195,7 +196,7 @@
|
||||
</field>
|
||||
<newline/>
|
||||
<group col="13" colspan="10">
|
||||
<field name="tax_id" groups="base.group_sale_taxes_global_on_order"/>
|
||||
<field name="tax_id" groups="base.group_sale_taxes_global_on_order" on_change="onchange_taxes(tax_id)"/>
|
||||
<field name="amount_untaxed" sum="Untaxed amount" groups="base.group_sale_taxes_on_order_line,base.group_sale_taxes_global_on_order"/>
|
||||
<field name="amount_tax" groups="base.group_sale_taxes_on_order_line,base.group_sale_taxes_global_on_order"/>
|
||||
<field name="amount_total"/>
|
||||
|
||||
Reference in New Issue
Block a user