[MRG] mrege with lp:~openerp-dev/openobject-addons/trunk-v62_config_sale-uco
bzr revid: tpa@tinyerp.com-20120307054840-hpdvk78e1gcoilvb
This commit is contained in:
@@ -37,5 +37,4 @@ import ir_sequence
|
||||
import company
|
||||
import res_currency
|
||||
import edi
|
||||
import res_config
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
# -*- 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
|
||||
from tools.translate import _
|
||||
|
||||
class account_configuration(osv.osv_memory):
|
||||
_inherit = 'res.config.settings'
|
||||
|
||||
_columns = {
|
||||
'tax_policy': fields.selection([
|
||||
('no_tax', 'No Tax'),
|
||||
('global_on_order', 'Global On Order'),
|
||||
('on_order_line', 'On Order Lines'),
|
||||
], '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',
|
||||
}
|
||||
|
||||
def get_default_tax_policy(self, cr, uid, ids, context=None):
|
||||
applied_groups = self.get_default_applied_groups(cr, uid, ids, context=context)
|
||||
if applied_groups.get('group_sale_taxes_global_on_order'):
|
||||
applied_groups.update({'tax_policy': 'global_on_order'})
|
||||
elif applied_groups.get('group_sale_taxes_on_order_line'):
|
||||
applied_groups.update({'tax_policy': 'on_order_line'})
|
||||
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)
|
||||
res.update({'tax_value': 15.0})
|
||||
tax_id = self._check_default_tax(cr, uid, context)
|
||||
if tax_id:
|
||||
res.update({'tax_value': tax_id and tax_id[0]})
|
||||
return res
|
||||
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||
ir_values_obj = self.pool.get('ir.values')
|
||||
res = super(account_configuration, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
|
||||
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')
|
||||
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')
|
||||
tax_policy = vals.get('tax_policy')
|
||||
order_group_id = data_obj.get_object(cr, uid, 'base', 'group_sale_taxes_global_on_order').id
|
||||
order_line_group_id = data_obj.get_object(cr, uid, 'base', 'group_sale_taxes_on_order_line').id
|
||||
group_id = False
|
||||
remove_group_id = False
|
||||
|
||||
if tax_policy == 'global_on_order':
|
||||
group_id = order_group_id
|
||||
remove_group_id = order_line_group_id
|
||||
elif tax_policy == 'on_order_line':
|
||||
group_id = order_line_group_id
|
||||
remove_group_id = order_group_id
|
||||
|
||||
if group_id:
|
||||
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)])
|
||||
groups_obj.write(cr, uid, [user_group_id], {'implied_ids': [(3,remove_group_id)]})
|
||||
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, 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)])
|
||||
|
||||
account_configuration()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -113,7 +113,7 @@
|
||||
|
||||
<record id="view_contract_installation" model="ir.ui.view">
|
||||
<field name="name">Sales Application</field>
|
||||
<field name="model">res.config.settings</field>
|
||||
<field name="model">sale.config.settings</field>
|
||||
<field name="inherit_id" ref="sale.view_sales_config"/>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
|
||||
+16
-15
@@ -29,16 +29,16 @@ class crm_configuration(osv.osv_memory):
|
||||
help="""Allows Caldav features in Meeting, Share meeting with other calendar clients like sunbird.
|
||||
It installs crm_caldav module."""),
|
||||
'fetchmail_crm': fields.boolean("Lead/Opportunity mail gateway", help="Allows you to configure your incoming mail server. And creates leads for your mails."),
|
||||
'server' : fields.char('Server Name', size=256),
|
||||
'port' : fields.integer('Port'),
|
||||
'type': fields.selection([
|
||||
'default_server' : fields.char('Server Name', size=256),
|
||||
'default_port' : fields.integer('Port'),
|
||||
'default_type': fields.selection([
|
||||
('pop', 'POP Server'),
|
||||
('imap', 'IMAP Server'),
|
||||
('local', 'Local Server'),
|
||||
], 'Server Type'),
|
||||
'is_ssl': fields.boolean('SSL/TLS', help="Connections are encrypted with SSL/TLS through a dedicated port (default: IMAPS=993, POP=995)"),
|
||||
'user' : fields.char('Username', size=256),
|
||||
'password' : fields.char('Password', size=1024),
|
||||
'default_is_ssl': fields.boolean('SSL/TLS', help="Connections are encrypted with SSL/TLS through a dedicated port (default: IMAPS=993, POP=995)"),
|
||||
'default_user' : fields.char('Username', size=256),
|
||||
'default_password' : fields.char('Password', size=1024),
|
||||
'module_import_sugarcrm' : fields.boolean("SugarCRM Import",
|
||||
help="""Import SugarCRM Leads, Opportunities, Users, Accounts, Contacts, Employees, Meetings, Phonecalls, Emails, and Project, Project Tasks Data.
|
||||
It installs import_sugarcrm module.
|
||||
@@ -69,7 +69,7 @@ class crm_configuration(osv.osv_memory):
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'type': 'pop',
|
||||
'default_type': 'pop',
|
||||
}
|
||||
|
||||
def get_default_email_configurations(self, cr, uid, ids, context=None):
|
||||
@@ -80,7 +80,7 @@ class crm_configuration(osv.osv_memory):
|
||||
if server_ids:
|
||||
result.update({'fetchmail_crm': True})
|
||||
for val in ir_values_obj.get(cr, uid, 'default', False, ['fetchmail.server']):
|
||||
result.update({val[1]: val[2]})
|
||||
result.update({'default_'+val[1]: val[2]})
|
||||
return result
|
||||
|
||||
def onchange_server_type(self, cr, uid, ids, server_type=False, ssl=False):
|
||||
@@ -95,21 +95,22 @@ class crm_configuration(osv.osv_memory):
|
||||
values['port'] = port
|
||||
return {'value': values}
|
||||
|
||||
def set_email_configurations(self, cr, uid, ids, vals, context=None):
|
||||
def set_email_configurations(self, cr, uid, ids, context=None):
|
||||
model_obj = self.pool.get('ir.model')
|
||||
fetchmail_obj = self.pool.get('fetchmail.server')
|
||||
ir_values_obj = self.pool.get('ir.values')
|
||||
object_id = model_obj.search(cr, uid, [('model','=','crm.lead')])
|
||||
vals = self.read(cr, uid, ids[0], [], context=context)
|
||||
if vals.get('fetchmail_crm') and object_id:
|
||||
fetchmail_vals = {
|
||||
'name': 'Incoming Leads',
|
||||
'object_id': object_id[0],
|
||||
'server': vals.get('server'),
|
||||
'port': vals.get('port'),
|
||||
'is_ssl': vals.get('is_ssl'),
|
||||
'type': vals.get('type'),
|
||||
'user': vals.get('user'),
|
||||
'password': vals.get('password')
|
||||
'server': vals.get('default_server'),
|
||||
'port': vals.get('default_port'),
|
||||
'is_ssl': vals.get('default_is_ssl'),
|
||||
'type': vals.get('default_type'),
|
||||
'user': vals.get('default_user'),
|
||||
'password': vals.get('default_password')
|
||||
}
|
||||
server_ids = fetchmail_obj.search(cr, uid, [('name','=','Incoming Leads'),('state','!=','done')])
|
||||
if not server_ids:
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
@@ -8,18 +9,25 @@
|
||||
<field name="inherit_id" ref="base.view_res_config_settings"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//form/group[@name='crm']/group[@name='plugin']" position="inside">
|
||||
<group col="4" colspan="2">
|
||||
<separator string="Plugins" colspan="4"/>
|
||||
<newline/>
|
||||
<field name="module_plugin_thunderbird"/>
|
||||
<newline/>
|
||||
<field name="module_plugin_outlook"/>
|
||||
</group>
|
||||
<group col="2" colspan="2" name="emails">
|
||||
<separator string="Emails" colspan="2"/>
|
||||
<field name="fetchmail_crm"/>
|
||||
<newline/>
|
||||
<group col="4" colspan="2" attrs="{'invisible': [('fetchmail_crm','=',False)]}">
|
||||
<field name="server" attrs="{'required': [('fetchmail_crm','=',True)]}"/>
|
||||
<field name="type" nolabel="1" on_change="onchange_server_type(type, is_ssl)" attrs="{'required': [('fetchmail_crm','=',True)]}"/>
|
||||
<field name="port" attrs="{'required': [('fetchmail_crm','=',True)]}"/>
|
||||
<field name="is_ssl" on_change="onchange_server_type(type, is_ssl)"/>
|
||||
<field name="default_server" attrs="{'required': [('fetchmail_crm','=',True)]}"/>
|
||||
<field name="default_type" nolabel="1" on_change="onchange_server_type(type, is_ssl)" attrs="{'required': [('fetchmail_crm','=',True)]}"/>
|
||||
<field name="default_port" attrs="{'required': [('fetchmail_crm','=',True)]}"/>
|
||||
<field name="default_is_ssl" on_change="onchange_server_type(type, is_ssl)"/>
|
||||
<newline/>
|
||||
<field name="user" attrs="{'required': [('fetchmail_crm','=',True)]}"/>
|
||||
<field name="password" password="True" attrs="{'required': [('fetchmail_crm','=',True)]}"/>
|
||||
<field name="default_user" attrs="{'required': [('fetchmail_crm','=',True)]}"/>
|
||||
<field name="default_password" password="True" attrs="{'required': [('fetchmail_crm','=',True)]}"/>
|
||||
</group>
|
||||
</group>
|
||||
</xpath>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
!record {model: mrp.bom, id: mrp_bom_rearpanelarm1}:
|
||||
routing_id: mrp.mrp_routing_0
|
||||
-
|
||||
I create Production Order of Shelf 100cm to produce 5.0 Dozen PCE.
|
||||
I create Production Order of Shelf 100cm to produce 5.0 Dozen Unit.
|
||||
-
|
||||
!record {model: mrp.production, id: mrp_production_shelf100cm}:
|
||||
location_src_id: stock.stock_location_stock
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
woodmm10 = False
|
||||
metalcleats = False
|
||||
for line in order.product_lines:
|
||||
if line.product_id.id == ref('product.product_product_sidepanel0'): #SIDEPAN 2 PCE
|
||||
if line.product_id.id == ref('product.product_product_sidepanel0'): #SIDEPAN 2 Unit
|
||||
assert not sidepanel, "Production line is already generated for SIDEPAN."
|
||||
assert line.product_qty == (2.0*factor), "Qty is not correspond."
|
||||
assert line.product_uom.id == ref('product.product_uom_unit'), "UOM is not correspond"
|
||||
@@ -32,7 +32,7 @@
|
||||
assert line.product_qty == (0.25*factor), "Qty is not correspond."
|
||||
assert line.product_uom.id == ref('product.product_uom_meter'), "UOM is not correspond"
|
||||
woodmm0 = True
|
||||
elif line.product_id.id == ref('product.product_product_metalcleats0'): #METC000 4*3 PCE
|
||||
elif line.product_id.id == ref('product.product_product_metalcleats0'): #METC000 4*3 Unit
|
||||
assert not metalcleats, "Production line is already generated for METC000."
|
||||
assert line.product_qty == (4*3*factor), "Qty is not correspond."
|
||||
assert line.product_uom.id == ref('product.product_uom_unit'), "UOM is not correspond"
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
<field name="name">Sales Application</field>
|
||||
<field name="model">res.config.settings</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="mail.view_sales_config_plugin"/>
|
||||
<field name="inherit_id" ref="mail.view_sale_config_settings"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="module_plugin_outlook" position="after">
|
||||
<button name="%(action_outlook_installer)d" type="action" string="Configure Outlook" icon="gtk-execute"/>
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
<field name="name">Sales Application</field>
|
||||
<field name="model">res.config.settings</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="mail.view_sales_config_plugin"/>
|
||||
<field name="inherit_id" ref="mail.view_sale_config_settings"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="module_plugin_thunderbird" position="after">
|
||||
<button name="%(action_thunderbird_installer)d" type="action" string="Configure Thunderbird" icon="gtk-execute"/>
|
||||
|
||||
@@ -26,10 +26,12 @@ class product_groups_configuration(osv.osv_memory):
|
||||
|
||||
_columns = {
|
||||
'group_sale_pricelist_per_customer':fields.boolean("Pricelist per customer",
|
||||
group='base.group_user', implied_group='base.group_sale_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",
|
||||
group='base.group_user', implied_group='base.group_sale_uom_per_product',
|
||||
help="""
|
||||
Allows you to select and maintain different unit of measures per product.
|
||||
It assigns the "UOM per product" group to all employees.
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
assert product.price == product.lst_price, "Sell price is not correspond."
|
||||
|
||||
-
|
||||
I check sale price of IT componet if more than 3 PCE.
|
||||
I check sale price of IT componet if more than 3 Unit.
|
||||
-
|
||||
!python {model: product.product}: |
|
||||
context.update({'quantity':5})
|
||||
@@ -51,7 +51,7 @@
|
||||
product = self.browse(cr, uid, ref("product_product_pc2"), context=context)
|
||||
assert product.price == 450, "cost price is not correspond."
|
||||
-
|
||||
I check cost price of PC2 if more than 3 PCE.
|
||||
I check cost price of PC2 if more than 3 Unit.
|
||||
-
|
||||
!python {model: product.product}: |
|
||||
context.update({'quantity':3})
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
"__import_module": "purchase",
|
||||
"__import_model": "purchase.order.line",
|
||||
"name": "Basic PC",
|
||||
"product_uom": ["product:724f93ec-ddd0-11e0-88ec-701a04e25543.product_uom_unit", "PCE"],
|
||||
"product_uom": ["product:724f93ec-ddd0-11e0-88ec-701a04e25543.product_uom_unit", "Unit"],
|
||||
"product_qty": 1.0,
|
||||
"date_planned": "2011-09-30",
|
||||
"sequence": 10,
|
||||
@@ -102,7 +102,7 @@
|
||||
"__import_module": "purchase",
|
||||
"__import_model": "purchase.order.line",
|
||||
"name": "Medium PC",
|
||||
"product_uom": ["product:724f93ec-ddd0-11e0-88ec-701a04e25543.product_uom_unit", "PCE"],
|
||||
"product_uom": ["product:724f93ec-ddd0-11e0-88ec-701a04e25543.product_uom_unit", "Unit"],
|
||||
"product_qty": 10.0,
|
||||
"sequence": 11,
|
||||
"date_planned": "2011-09-15",
|
||||
@@ -125,11 +125,11 @@
|
||||
assert len(order_new.order_line) == 2, "Purchase order lines number mismatch"
|
||||
for purchase_line in order_new.order_line:
|
||||
if purchase_line.name == 'Basic PC':
|
||||
assert purchase_line.product_uom.name == "PCE" , "uom is not same"
|
||||
assert purchase_line.product_uom.name == "Unit" , "uom is not same"
|
||||
assert purchase_line.price_unit == 150 , "unit price is not same, got %s, expected 150"%(purchase_line.price_unit,)
|
||||
assert purchase_line.product_qty == 1 , "product qty is not same"
|
||||
elif purchase_line.name == 'Medium PC':
|
||||
assert purchase_line.product_uom.name == "PCE" , "uom is not same"
|
||||
assert purchase_line.product_uom.name == "Unit" , "uom is not same"
|
||||
assert purchase_line.price_unit == 20 , "unit price is not same, got %s, expected 20"%(purchase_line.price_unit,)
|
||||
assert purchase_line.product_qty == 10 , "product qty is not same"
|
||||
else:
|
||||
|
||||
@@ -66,7 +66,7 @@ Dashboard for Sales Manager that includes:
|
||||
'author': 'OpenERP SA',
|
||||
'website': 'http://www.openerp.com',
|
||||
'images': ['images/deliveries_to_invoice.jpeg','images/sale_dashboard.jpeg','images/Sale_order_line_to_invoice.jpeg','images/sale_order.jpeg','images/sales_analysis.jpeg'],
|
||||
'depends': ['stock', 'procurement', 'board'],
|
||||
'depends': ['stock', 'procurement', 'board', 'mail'],
|
||||
'init_xml': [],
|
||||
'update_xml': [
|
||||
'wizard/sale_make_invoice_advance.xml',
|
||||
|
||||
+95
-34
@@ -40,10 +40,11 @@ class sale_configuration(osv.osv_memory):
|
||||
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."""),
|
||||
'order_policy': fields.selection([
|
||||
('manual', 'Invoice Based on Sales Orders'),
|
||||
('picking', 'Invoice Based on Deliveries'),
|
||||
], 'Main Method Based On', required=True, help="You can generate invoices based on sales orders or based on shippings."),
|
||||
'default_order_policy': fields.selection([
|
||||
('manual', 'Invoice Based on Sales Orders'),
|
||||
('picking', 'Invoice Based on Deliveries'),
|
||||
], 'Main Method Based On', required=True, default_model='sale.order',
|
||||
help="You can generate invoices based on sales orders or based on shippings."),
|
||||
'module_delivery': fields.boolean('Do you charge the delivery?',
|
||||
help ="""
|
||||
Allows you to add delivery methods in sale orders and delivery orders.
|
||||
@@ -51,9 +52,12 @@ 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 on sale order that will allow you to deliver all products at once."),
|
||||
'group_sale_delivery_address':fields.boolean("Multiple Address",help="Allows you to set different delivery address and invoice 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."),
|
||||
'default_picking_policy' : fields.boolean("Deliver all products at once?", default_model='sale.order',
|
||||
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", group='base.group_user', implied_group='base.group_sale_delivery_address',
|
||||
help="Allows you to set different delivery address and invoice address. It assigns Multiple Address group to all employees."),
|
||||
'group_sale_disc_per_sale_order_line':fields.boolean("Discounts per sale order lines ", group='base.group_user', implied_group='base.group_sale_disc_per_sale_order_line',
|
||||
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 raise user specific warning messages on different products used in Sales Orders, Purchase Orders, Invoices and Deliveries.
|
||||
@@ -73,19 +77,36 @@ class sale_configuration(osv.osv_memory):
|
||||
'module_analytic_journal_billing_rate' : fields.boolean("Billing rates by contracts",
|
||||
help="""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.
|
||||
""")
|
||||
"""),
|
||||
'tax_policy': fields.selection([
|
||||
('no_tax', 'No Tax'),
|
||||
('global_on_order', 'Global On Order'),
|
||||
('on_order_line', 'On Order Lines'),
|
||||
], '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.
|
||||
"""),
|
||||
'group_sale_taxes_global_on_order':fields.boolean("Global on order", group='base.group_user', implied_group='base.group_sale_taxes_global_on_order'),
|
||||
'group_sale_taxes_on_order_line':fields.boolean("On order line", group='base.group_user', implied_group='base.group_sale_taxes_on_order_line'),
|
||||
}
|
||||
|
||||
def get_default_installed_modules(self, cr, uid, ids, context=None):
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
data_obj = self.pool.get('ir.model.data')
|
||||
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
|
||||
if installed_modules.get('module_account_analytic_analysis'):
|
||||
res = super(sale_configuration, self).default_get(cr, uid, fields, context)
|
||||
if res.get('module_project_mrp') and res.get('module_project_timesheet'):
|
||||
res.update({'task_work': True})
|
||||
if res.get('module_account_analytic_analysis'):
|
||||
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
|
||||
installed_modules.update({'time_unit': uom_id})
|
||||
return installed_modules
|
||||
res.update({'time_unit': uom_id})
|
||||
if res.get('group_sale_taxes_global_on_order'):
|
||||
res.update({'tax_policy': 'global_on_order'})
|
||||
elif res.get('group_sale_taxes_on_order_line'):
|
||||
res.update({'tax_policy': 'on_order_line'})
|
||||
else:
|
||||
res.update({'tax_policy': 'no_tax'})
|
||||
return res
|
||||
|
||||
def get_default_sale_configs(self, cr, uid, ids, context=None):
|
||||
ir_values_obj = self.pool.get('ir.values')
|
||||
@@ -104,21 +125,21 @@ class sale_configuration(osv.osv_memory):
|
||||
for res in ir_values_obj.get(cr, uid, 'default', False, ['sale.order']):
|
||||
result[res[1]] = res[2]
|
||||
return result
|
||||
|
||||
|
||||
_defaults = {
|
||||
'order_policy': 'manual',
|
||||
'default_order_policy': 'manual',
|
||||
'time_unit': lambda self, cr, uid, c: self.pool.get('product.uom').search(cr, uid, [('name', '=', _('Hour'))], context=c) and self.pool.get('product.uom').search(cr, uid, [('name', '=', _('Hour'))], context=c)[0] or False,
|
||||
'tax_policy': 'global_on_order',
|
||||
}
|
||||
|
||||
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 set_installed_modules(self, cr, uid, ids, vals, context=None):
|
||||
if vals.get('task_work'):
|
||||
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):
|
||||
def set_sale_defaults(self, cr, uid, ids, context=None):
|
||||
ir_values_obj = self.pool.get('ir.values')
|
||||
data_obj = self.pool.get('ir.model.data')
|
||||
menu_obj = self.pool.get('ir.ui.menu')
|
||||
@@ -136,7 +157,7 @@ class sale_configuration(osv.osv_memory):
|
||||
menu_obj.write(cr, uid, menu_id, {'groups_id':[(4,group_id)]})
|
||||
ir_values_obj.set(cr, uid, 'default', False, 'groups_id', ['ir.ui.menu'], [(4,group_id)])
|
||||
|
||||
if wizard.picking_policy:
|
||||
if wizard.default_picking_policy:
|
||||
ir_values_obj.set(cr, uid, 'default', False, 'picking_policy', ['sale.order'], 'one')
|
||||
|
||||
if wizard.time_unit:
|
||||
@@ -144,7 +165,7 @@ class sale_configuration(osv.osv_memory):
|
||||
product_obj = self.pool.get('product.product')
|
||||
product_obj.write(cr, uid, prod_id, {'uom_id': wizard.time_unit.id, 'uom_po_id': wizard.time_unit.id})
|
||||
|
||||
ir_values_obj.set(cr, uid, 'default', False, 'order_policy', ['sale.order'], wizard.order_policy)
|
||||
ir_values_obj.set(cr, uid, 'default', False, 'order_policy', ['sale.order'], wizard.default_order_policy)
|
||||
if wizard.task_work and wizard.time_unit:
|
||||
company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
|
||||
self.pool.get('res.company').write(cr, uid, [company_id], {
|
||||
@@ -154,18 +175,58 @@ class sale_configuration(osv.osv_memory):
|
||||
return res
|
||||
|
||||
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 {'value': {}}
|
||||
res = {'value': {}}
|
||||
if ids:
|
||||
self.set_tax_policy(cr, uid, ids, context=context)
|
||||
if tax_policy == 'global_on_order':
|
||||
res['value'].update({'group_sale_taxes_global_on_order': True})
|
||||
elif tax_policy == 'on_order_line':
|
||||
res['value'].update({'group_sale_taxes_on_order_line': True})
|
||||
else:
|
||||
res['value'].update({'group_sale_taxes_on_order_line': False, 'group_sale_taxes_global_on_order': False})
|
||||
return res
|
||||
|
||||
def set_default_taxes(self, cr, uid, ids, vals, context=None):
|
||||
def set_default_taxes(self, cr, uid, ids, context=None):
|
||||
ir_values_obj = self.pool.get('ir.values')
|
||||
taxes = self._check_default_tax(cr, uid, context=context)
|
||||
if isinstance(vals.get('tax_value'), list):
|
||||
taxes = vals.get('tax_value')
|
||||
if taxes:
|
||||
ir_values_obj.set(cr, uid, 'default', False, 'tax_id', ['sale.order'], taxes[0])
|
||||
ir_values_obj.set(cr, uid, 'default', False, 'tax_id', ['sale.order.line'], taxes)
|
||||
ir_values_obj.set(cr, uid, 'default', False, 'taxes_id', ['product.product'], taxes)
|
||||
|
||||
#TODO: TO BE REMOVED
|
||||
# def set_tax_policy(self, cr, uid, ids, 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')
|
||||
# tax_policy = self.browse(cr, uid, ids[0], context=context).tax_policy
|
||||
# order_group_id = data_obj.get_object(cr, uid, 'base', 'group_sale_taxes_global_on_order').id
|
||||
# order_line_group_id = data_obj.get_object(cr, uid, 'base', 'group_sale_taxes_on_order_line').id
|
||||
# group_id = False
|
||||
# remove_group_id = False
|
||||
#
|
||||
# if tax_policy == 'global_on_order':
|
||||
# group_id = order_group_id
|
||||
# remove_group_id = order_line_group_id
|
||||
# elif tax_policy == 'on_order_line':
|
||||
# group_id = order_line_group_id
|
||||
# remove_group_id = order_group_id
|
||||
#
|
||||
# if group_id:
|
||||
# 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)])
|
||||
# groups_obj.write(cr, uid, [user_group_id], {'implied_ids': [(3,remove_group_id)]})
|
||||
# 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, 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)])
|
||||
|
||||
sale_configuration()
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
@@ -21,11 +22,11 @@
|
||||
<newline/>
|
||||
</group>
|
||||
<group colspan="4" col="4">
|
||||
<field name="order_policy" attrs="{'invisible':['|',('sale_orders','=',False),('deli_orders','=',False)]}"/>
|
||||
<field name="default_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)]}"/>
|
||||
<field name="default_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>
|
||||
@@ -62,7 +63,7 @@
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<menuitem id="base.menu_sale_config" name="Sales" parent="base.menu_config" sequence="1" action="base.action_sale_config"/>
|
||||
|
||||
</data>
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
I set order policy "Deliver & invoice on demand" as default policy.
|
||||
-
|
||||
!record {model: res.config.settings, id: sale_configuration_0}:
|
||||
order_policy: 'manual'
|
||||
default_order_policy: 'manual'
|
||||
-
|
||||
!python {model: res.config.settings}: |
|
||||
self.execute(cr, uid, [ref("sale_configuration_0")], {})
|
||||
|
||||
Reference in New Issue
Block a user