From 187b0d3532a468637915f3a1aa60a14e1024b459 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Thu, 23 Feb 2012 15:16:26 +0530 Subject: [PATCH 01/80] [IMP] changes for sale configuration view bzr revid: tpa@tinyerp.com-20120223094626-7vt2ufe2qjeoudc2 --- addons/delivery/delivery.py | 36 +++---- addons/delivery/delivery_view.xml | 4 +- addons/sale/sale.py | 163 +++++++++++++++--------------- addons/sale/sale_view.xml | 29 +++--- 4 files changed, 116 insertions(+), 116 deletions(-) diff --git a/addons/delivery/delivery.py b/addons/delivery/delivery.py index 9f95a430f4e..cc2b66dd9e7 100644 --- a/addons/delivery/delivery.py +++ b/addons/delivery/delivery.py @@ -106,7 +106,7 @@ class delivery_carrier(osv.osv): # if using advanced pricing per destination: do not change if record.use_detailed_pricelist: continue - + # not using advanced pricing per destination: override grid grid_id = grid_pool.search(cr, uid, [('carrier_id', '=', record.id)], context=context) @@ -250,23 +250,23 @@ class delivery_grid_line(osv.osv): delivery_grid_line() -class define_delivery_steps(osv.osv_memory): - _name = 'delivery.define.delivery.steps.wizard' - - _columns = { - 'picking_policy' : fields.selection([('direct', 'Deliver each product when available'), ('one', 'Deliver all products at once')], 'Picking Policy'), - } - _defaults = { - 'picking_policy': lambda s,c,u,ctx: s.pool.get('sale.order').default_get(c,u,['picking_policy'],context=ctx)['picking_policy'] - } - - def apply_cb(self, cr, uid, ids, context=None): - ir_values_obj = self.pool.get('ir.values') - wizard = self.browse(cr, uid, ids, context=context)[0] - ir_values_obj.set(cr, uid, 'default', False, 'picking_policy', ['sale.order'], wizard.picking_policy) - return {'type' : 'ir.actions.act_window_close'} - -define_delivery_steps() +#class define_delivery_steps(osv.osv_memory): +# _name = 'delivery.define.delivery.steps.wizard' +# +# _columns = { +# 'picking_policy' : fields.selection([('direct', 'Deliver each product when available'), ('one', 'Deliver all products at once')], 'Picking Policy'), +# } +# _defaults = { +# 'picking_policy': lambda s,c,u,ctx: s.pool.get('sale.order').default_get(c,u,['picking_policy'],context=ctx)['picking_policy'] +# } +# +# def apply_cb(self, cr, uid, ids, context=None): +# ir_values_obj = self.pool.get('ir.values') +# wizard = self.browse(cr, uid, ids, context=context)[0] +# ir_values_obj.set(cr, uid, 'default', False, 'picking_policy', ['sale.order'], wizard.picking_policy) +# return {'type' : 'ir.actions.act_window_close'} +# +#define_delivery_steps() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/delivery/delivery_view.xml b/addons/delivery/delivery_view.xml index 1e47d815084..4928f77bc3e 100644 --- a/addons/delivery/delivery_view.xml +++ b/addons/delivery/delivery_view.xml @@ -337,7 +337,7 @@ 10 - + diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 82bfda7b580..95d4e9762af 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -789,7 +789,7 @@ class sale_order(osv.osv): return True def _get_date_planned(self, cr, uid, order, line, start_date, context=None): - date_planned = datetime.strptime(start_date, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(days=line.delay or 0.0) + date_planned = datetime.strptime(start_date, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(days=line.delay or 0.0) date_planned = (date_planned - timedelta(days=order.company_id.security_lead)).strftime(DEFAULT_SERVER_DATETIME_FORMAT) return date_planned @@ -1331,94 +1331,93 @@ class sale_order_line(osv.osv): sale_order_line() class sale_config_picking_policy(osv.osv_memory): - _name = 'sale.config.picking_policy' - _inherit = 'res.config' + _inherit = 'sale.config.picking_policy' _columns = { - 'name': fields.char('Name', size=64), - 'sale_orders': fields.boolean('Based on Sales Orders',), - 'deli_orders': fields.boolean('Based on Delivery Orders'), - 'task_work': fields.boolean('Based on Tasks\' Work'), - 'timesheet': fields.boolean('Based on Timesheet'), - '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."), - 'charge_delivery': fields.boolean('Do you charge the delivery?'), +# 'name': fields.char('Name', size=64), +# 'sale_orders': fields.boolean('Based on Sales Orders',), +# 'deli_orders': fields.boolean('Based on Delivery Orders'), +# 'task_work': fields.boolean('Based on Tasks\' Work'), +# 'timesheet': fields.boolean('Based on Timesheet'), +# '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."), +# 'charge_delivery': fields.boolean('Do you charge the delivery?'), 'time_unit': fields.many2one('product.uom','Main Working Time Unit') } _defaults = { - 'order_policy': 'manual', +# '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, } - - def onchange_order(self, cr, uid, ids, sale, deli, context=None): - res = {} - if sale: - res.update({'order_policy': 'manual'}) - elif deli: - res.update({'order_policy': 'picking'}) - return {'value':res} - - def execute(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') - module_obj = self.pool.get('ir.module.module') - module_upgrade_obj = self.pool.get('base.module.upgrade') - module_name = [] - - group_id = data_obj.get_object(cr, uid, 'base', 'group_sale_salesman').id - - wizard = self.browse(cr, uid, ids)[0] - - if wizard.sale_orders: - menu_id = data_obj.get_object(cr, uid, 'sale', 'menu_invoicing_sales_order_lines').id - menu_obj.write(cr, uid, menu_id, {'groups_id':[(4,group_id)]}) - - if wizard.deli_orders: - menu_id = data_obj.get_object(cr, uid, 'sale', 'menu_action_picking_list_to_invoice').id - menu_obj.write(cr, uid, menu_id, {'groups_id':[(4,group_id)]}) - - if wizard.task_work: - module_name.append('project_timesheet') - module_name.append('project_mrp') - module_name.append('account_analytic_analysis') - - if wizard.timesheet: - module_name.append('account_analytic_analysis') - - if wizard.charge_delivery: - module_name.append('delivery') - - if len(module_name): - module_ids = [] - need_install = False - module_ids = [] - for module in module_name: - data_id = module_obj.name_search(cr, uid , module, [], '=') - module_ids.append(data_id[0][0]) - - for module in module_obj.browse(cr, uid, module_ids): - if module.state == 'uninstalled': - module_obj.state_update(cr, uid, [module.id], 'to install', ['uninstalled'], context) - need_install = True - cr.commit() - if need_install: - pooler.restart_pool(cr.dbname, update_module=True)[1] - - if wizard.time_unit: - prod_id = data_obj.get_object(cr, uid, 'product', 'product_consultant').id - 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) - 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], { - 'project_time_mode_id': wizard.time_unit.id - }, context=context) - +# +# def onchange_order(self, cr, uid, ids, sale, deli, context=None): +# res = {} +# if sale: +# res.update({'order_policy': 'manual'}) +# elif deli: +# res.update({'order_policy': 'picking'}) +# return {'value':res} +# +# def execute(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') +# module_obj = self.pool.get('ir.module.module') +# module_upgrade_obj = self.pool.get('base.module.upgrade') +# module_name = [] +# +# group_id = data_obj.get_object(cr, uid, 'base', 'group_sale_salesman').id +# +# wizard = self.browse(cr, uid, ids)[0] +# +# if wizard.sale_orders: +# menu_id = data_obj.get_object(cr, uid, 'sale', 'menu_invoicing_sales_order_lines').id +# menu_obj.write(cr, uid, menu_id, {'groups_id':[(4,group_id)]}) +# +# if wizard.deli_orders: +# menu_id = data_obj.get_object(cr, uid, 'sale', 'menu_action_picking_list_to_invoice').id +# menu_obj.write(cr, uid, menu_id, {'groups_id':[(4,group_id)]}) +# +# if wizard.task_work: +# module_name.append('project_timesheet') +# module_name.append('project_mrp') +# module_name.append('account_analytic_analysis') +# +# if wizard.timesheet: +# module_name.append('account_analytic_analysis') +# +# if wizard.charge_delivery: +# module_name.append('delivery') +# +# if len(module_name): +# module_ids = [] +# need_install = False +# module_ids = [] +# for module in module_name: +# data_id = module_obj.name_search(cr, uid , module, [], '=') +# module_ids.append(data_id[0][0]) +# +# for module in module_obj.browse(cr, uid, module_ids): +# if module.state == 'uninstalled': +# module_obj.state_update(cr, uid, [module.id], 'to install', ['uninstalled'], context) +# need_install = True +# cr.commit() +# if need_install: +# pooler.restart_pool(cr.dbname, update_module=True)[1] +# +# if wizard.time_unit: +# prod_id = data_obj.get_object(cr, uid, 'product', 'product_consultant').id +# 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) +# 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], { +# 'project_time_mode_id': wizard.time_unit.id +# }, context=context) +# sale_config_picking_policy() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index 90d3838f5a0..4c7cadd6cdb 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -503,14 +503,14 @@ - + Setup Your Invoicing Method sale.config.picking_policy form - + - -
+ + + + + + + - + + once - + From 0be2e5e274227ff82c3c460b10fb569f513a88f5 Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Thu, 23 Feb 2012 18:05:56 +0530 Subject: [PATCH 02/80] [IMP]: Improved as per specifications. bzr revid: uco@tinyerp.com-20120223123556-gnpo1bu9bpnzs3jc --- addons/sale/sale.py | 186 ++++++++++++++++++++++---------------- addons/sale/sale_view.xml | 113 ++++++++++++----------- 2 files changed, 164 insertions(+), 135 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 95d4e9762af..a0fe02dbffe 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1334,90 +1334,116 @@ class sale_config_picking_policy(osv.osv_memory): _inherit = 'sale.config.picking_policy' _columns = { -# 'name': fields.char('Name', size=64), -# 'sale_orders': fields.boolean('Based on Sales Orders',), -# 'deli_orders': fields.boolean('Based on Delivery Orders'), -# 'task_work': fields.boolean('Based on Tasks\' Work'), -# 'timesheet': fields.boolean('Based on Timesheet'), -# '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."), -# 'charge_delivery': fields.boolean('Do you charge the delivery?'), - 'time_unit': fields.many2one('product.uom','Main Working Time Unit') + 'sale_orders': fields.boolean('Based on Sales Orders',), + 'deli_orders': fields.boolean('Based on Delivery Orders'), + 'task_work': fields.boolean('Based on Tasks\' Work'), + 'timesheet': fields.boolean('Based on Timesheet'), + '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."), + 'charge_delivery': fields.boolean('Do you charge the delivery?'), + 'time_unit': fields.many2one('product.uom','Main Working Time Unit'), + 'picking_policy' : fields.boolean("Deliver all products at once?"), + 'group_sale_pricelist_per_customer':fields.boolean("Activate pricelist to manage prices per customer "), + 'group_sale_uom_per_product':fields.boolean("Allow different unit of measure per product"), + 'group_sale_delivery_address':fields.boolean(" Allow delivery address different from invoice address"), + 'group_sale_disc_per_sale_order_line':fields.boolean("Allow to apply discounts per sale order lines "), + 'group_sale_notes_subtotal':fields.boolean("Allow notes and subtotals"), + 'group_sale_alerts_per_customer_products':fields.boolean("Allow to define alerts by products or customers"), + 'tax_value' : fields.float('Value'), + 'tax_policy': fields.selection([ + ('no_tax', 'No Tax'), + ('global_on_order', 'Global On Order'), + ('on_order_line', 'On Order Lines'), + ], 'Taxes'), + 'sale_margin' : fields.boolean("Display Margin For Users"), + 'sale_journal' : fields.boolean("Invoice_journal?"), } + + def default_module_get(self, cr, uid, ids, context=None): + #TODO: Need to be implemented + return {} + _defaults = { -# 'order_policy': 'manual', + 'order_policy': 'manual', + 'tax_policy': 'no_tax', '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, + 'task_work': default_module_get, + 'timesheet': default_module_get, } -# -# def onchange_order(self, cr, uid, ids, sale, deli, context=None): -# res = {} -# if sale: -# res.update({'order_policy': 'manual'}) -# elif deli: -# res.update({'order_policy': 'picking'}) -# return {'value':res} -# -# def execute(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') -# module_obj = self.pool.get('ir.module.module') -# module_upgrade_obj = self.pool.get('base.module.upgrade') -# module_name = [] -# -# group_id = data_obj.get_object(cr, uid, 'base', 'group_sale_salesman').id -# -# wizard = self.browse(cr, uid, ids)[0] -# -# if wizard.sale_orders: -# menu_id = data_obj.get_object(cr, uid, 'sale', 'menu_invoicing_sales_order_lines').id -# menu_obj.write(cr, uid, menu_id, {'groups_id':[(4,group_id)]}) -# -# if wizard.deli_orders: -# menu_id = data_obj.get_object(cr, uid, 'sale', 'menu_action_picking_list_to_invoice').id -# menu_obj.write(cr, uid, menu_id, {'groups_id':[(4,group_id)]}) -# -# if wizard.task_work: -# module_name.append('project_timesheet') -# module_name.append('project_mrp') -# module_name.append('account_analytic_analysis') -# -# if wizard.timesheet: -# module_name.append('account_analytic_analysis') -# -# if wizard.charge_delivery: -# module_name.append('delivery') -# -# if len(module_name): -# module_ids = [] -# need_install = False -# module_ids = [] -# for module in module_name: -# data_id = module_obj.name_search(cr, uid , module, [], '=') -# module_ids.append(data_id[0][0]) -# -# for module in module_obj.browse(cr, uid, module_ids): -# if module.state == 'uninstalled': -# module_obj.state_update(cr, uid, [module.id], 'to install', ['uninstalled'], context) -# need_install = True -# cr.commit() -# if need_install: -# pooler.restart_pool(cr.dbname, update_module=True)[1] -# -# if wizard.time_unit: -# prod_id = data_obj.get_object(cr, uid, 'product', 'product_consultant').id -# 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) -# 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], { -# 'project_time_mode_id': wizard.time_unit.id -# }, context=context) -# + + def onchange_order(self, cr, uid, ids, sale, deli, context=None): + res = {} + if sale: + res.update({'order_policy': 'manual'}) + elif deli: + res.update({'order_policy': 'picking'}) + return {'value':res} + + def write(self, cr, uid, ids, vals, context=None): + self.execute(cr, uid, ids, context=context) + return super(sale_config_picking_policy, self).write(cr, uid, ids, vals, context=context) + + def execute(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') + module_obj = self.pool.get('ir.module.module') + module_upgrade_obj = self.pool.get('base.module.upgrade') + module_name = [] + + group_id = data_obj.get_object(cr, uid, 'base', 'group_sale_salesman').id + + wizard = self.browse(cr, uid, ids)[0] + + if wizard.sale_orders: + menu_id = data_obj.get_object(cr, uid, 'sale', 'menu_invoicing_sales_order_lines').id + menu_obj.write(cr, uid, menu_id, {'groups_id':[(4,group_id)]}) + + if wizard.deli_orders: + menu_id = data_obj.get_object(cr, uid, 'sale', 'menu_action_picking_list_to_invoice').id + menu_obj.write(cr, uid, menu_id, {'groups_id':[(4,group_id)]}) + + if wizard.task_work: + module_name.append('project_timesheet') + module_name.append('project_mrp') + module_name.append('account_analytic_analysis') + + if wizard.timesheet: + module_name.append('account_analytic_analysis') + + if wizard.charge_delivery: + module_name.append('delivery') + + if len(module_name): + module_ids = [] + need_install = False + module_ids = [] + for module in module_name: + data_id = module_obj.name_search(cr, uid , module, [], '=') + module_ids.append(data_id[0][0]) + + for module in module_obj.browse(cr, uid, module_ids): + if module.state == 'uninstalled': + module_obj.state_update(cr, uid, [module.id], 'to install', ['uninstalled'], context) + need_install = True + cr.commit() + if need_install: + pooler.restart_pool(cr.dbname, update_module=True)[1] + + if wizard.time_unit: + prod_id = data_obj.get_object(cr, uid, 'product', 'product_consultant').id + 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) + 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], { + 'project_time_mode_id': wizard.time_unit.id + }, context=context) + sale_config_picking_policy() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index 4c7cadd6cdb..b6b08732c9d 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -501,68 +501,71 @@ - + - - Setup Your Invoicing Method + + Configure Sales Applications sale.config.picking_policy form - + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - From a5fba77a0d0ccf1ffe499f88d4e127c30b6ebbe3 Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Fri, 24 Feb 2012 12:27:20 +0530 Subject: [PATCH 03/80] [IMP]: Improved code. bzr revid: uco@tinyerp.com-20120224065720-loj9rahg5mc7gmxc --- addons/sale/sale.py | 29 ++++++++++++++++++++++------- addons/sale/sale_view.xml | 12 ++++++------ 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index a0fe02dbffe..f5c39c6a15a 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1330,8 +1330,8 @@ class sale_order_line(osv.osv): sale_order_line() -class sale_config_picking_policy(osv.osv_memory): - _inherit = 'sale.config.picking_policy' +class sale_configuration(osv.osv_memory): + _inherit = 'sale.configuration' _columns = { 'sale_orders': fields.boolean('Based on Sales Orders',), @@ -1360,10 +1360,21 @@ class sale_config_picking_policy(osv.osv_memory): 'sale_margin' : fields.boolean("Display Margin For Users"), 'sale_journal' : fields.boolean("Invoice_journal?"), } - - def default_module_get(self, cr, uid, ids, context=None): + + def default_module_get(self, cr, uid, ids, selectable=[], context=None): #TODO: Need to be implemented - return {} + selectable = ['project_timesheet','project_mrp','account_analytic_analysis','delivery','sale_margin','sale_journal'] + res = super(sale_configuration, self).default_module_get(cr, uid, ids, selectable=selectable, context=context) + for k in res.keys(): + if k in ['project_timesheet','project_mrp','account_analytic_analysis']: + res.update({'task_work': True}) + if k in ['account_analytic_analysis']: + res.update({'timesheet': True}) + if k == 'delivery': + res.update({'sale_orders': True, 'deli_orders': True}) + else: + res.update({k: False}) + return res _defaults = { 'order_policy': 'manual', @@ -1371,6 +1382,10 @@ class sale_config_picking_policy(osv.osv_memory): '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, 'task_work': default_module_get, 'timesheet': default_module_get, + 'sale_orders': default_module_get, + 'deli_orders': default_module_get, + 'sale_margin' : default_module_get, + 'sale_journal': default_module_get, } def onchange_order(self, cr, uid, ids, sale, deli, context=None): @@ -1383,7 +1398,7 @@ class sale_config_picking_policy(osv.osv_memory): def write(self, cr, uid, ids, vals, context=None): self.execute(cr, uid, ids, context=context) - return super(sale_config_picking_policy, self).write(cr, uid, ids, vals, context=context) + return super(sale_configuration, self).write(cr, uid, ids, vals, context=context) def execute(self, cr, uid, ids, context=None): ir_values_obj = self.pool.get('ir.values') @@ -1444,6 +1459,6 @@ class sale_config_picking_policy(osv.osv_memory): 'project_time_mode_id': wizard.time_unit.id }, context=context) -sale_config_picking_policy() +sale_configuration() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index b6b08732c9d..c87a3e38601 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -504,8 +504,8 @@ - Configure Sales Applications - sale.config.picking_policy + Configure Sales Application + sale.configuration form @@ -524,13 +524,13 @@ - + - + - + - + From c31cea585bce1965c04e45738fe949cb509b6452 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Fri, 24 Feb 2012 14:38:47 +0530 Subject: [PATCH 04/80] [ADD] add the new usability groups in sales bzr revid: tpa@tinyerp.com-20120224090847-f8v7cg22xxmain4b --- addons/sale/sale.py | 6 ++-- addons/sale/sale_view.xml | 40 +++++++++++++------------- addons/sale/security/sale_security.xml | 30 +++++++++++++++++++ 3 files changed, 53 insertions(+), 23 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index f5c39c6a15a..1036f383db0 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1350,7 +1350,7 @@ class sale_configuration(osv.osv_memory): 'group_sale_delivery_address':fields.boolean(" Allow delivery address different from invoice address"), 'group_sale_disc_per_sale_order_line':fields.boolean("Allow to apply discounts per sale order lines "), 'group_sale_notes_subtotal':fields.boolean("Allow notes and subtotals"), - 'group_sale_alerts_per_customer_products':fields.boolean("Allow to define alerts by products or customers"), + 'warning':fields.boolean("Allow to define alerts by products or customers"), 'tax_value' : fields.float('Value'), 'tax_policy': fields.selection([ ('no_tax', 'No Tax'), @@ -1375,7 +1375,7 @@ class sale_configuration(osv.osv_memory): else: res.update({k: False}) return res - + _defaults = { 'order_policy': 'manual', 'tax_policy': 'no_tax', @@ -1395,7 +1395,7 @@ class sale_configuration(osv.osv_memory): elif deli: res.update({'order_policy': 'picking'}) return {'value':res} - + def write(self, cr, uid, ids, vals, context=None): self.execute(cr, uid, ids, context=context) return super(sale_configuration, self).write(cr, uid, ids, vals, context=context) diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index c87a3e38601..dee42ec3c93 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -117,9 +117,9 @@ - - - + + + @@ -139,7 +139,7 @@ on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, False, False, parent.date_order, product_packaging, parent.fiscal_position, True, context)"/> + nolabel="1" groups="base.group_sale_uom_per_product"/> @@ -149,9 +149,9 @@ context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'shop':parent.shop_id, 'uom':product_uom}" on_change="product_packaging_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, parent.partner_id, product_packaging, True, context)" domain="[('product_id','=',product_id)]" groups="base.group_extended" colspan="3"/> - - - + + + @@ -183,12 +183,12 @@ - + - + - + @@ -240,8 +240,8 @@ - - + + @@ -361,9 +361,9 @@ - + - + @@ -382,7 +382,7 @@ - + @@ -390,11 +390,11 @@ - - + + - - + + @@ -533,7 +533,7 @@ - + diff --git a/addons/sale/security/sale_security.xml b/addons/sale/security/sale_security.xml index ae8c8bf62e3..8dbc9c1385b 100644 --- a/addons/sale/security/sale_security.xml +++ b/addons/sale/security/sale_security.xml @@ -20,6 +20,36 @@ + + Selse Pricelist + + + + + Product UOM + + + + + Addresses in sales order + + + + + Discounts per sale order lines + + + + + Notes and subtotals + + + + + Sales Taxes Global/on line + + + From d27e795433a465d0207a9f02c1f0d279a5123f4c Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Fri, 24 Feb 2012 15:38:11 +0530 Subject: [PATCH 05/80] [IMP]: Improved code. bzr revid: uco@tinyerp.com-20120224100811-me5r7269x5h7btmi --- addons/sale/sale.py | 47 ++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 1036f383db0..dca0180ba8e 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1357,35 +1357,38 @@ class sale_configuration(osv.osv_memory): ('global_on_order', 'Global On Order'), ('on_order_line', 'On Order Lines'), ], 'Taxes'), - 'sale_margin' : fields.boolean("Display Margin For Users"), - 'sale_journal' : fields.boolean("Invoice_journal?"), + 'sale_margin': fields.boolean("Display Margin For Users"), + 'sale_journal': fields.boolean("Invoice journal?"), } - def default_module_get(self, cr, uid, ids, selectable=[], context=None): - #TODO: Need to be implemented - selectable = ['project_timesheet','project_mrp','account_analytic_analysis','delivery','sale_margin','sale_journal'] - res = super(sale_configuration, self).default_module_get(cr, uid, ids, selectable=selectable, context=context) - for k in res.keys(): + def default_get(self, cr, uid, fields_list, context=None): + ir_values_obj = self.pool.get('ir.values') + res = super(sale_configuration, self).default_get( + cr, uid, fields_list, context=context) + defaults = {} + module_list = ['project_timesheet','project_mrp','account_analytic_analysis','delivery', + 'sale_margin', 'sale_journal'] + defaults.update(self.get_installed_modules(cr, uid, module_list, context=context)) + for val in ir_values_obj.get(cr, uid, 'default', False, ['sale.order']): + defaults.update({val[1]: val[2]}) + for k in defaults.keys(): if k in ['project_timesheet','project_mrp','account_analytic_analysis']: - res.update({'task_work': True}) + defaults.update({'task_work': True}) if k in ['account_analytic_analysis']: - res.update({'timesheet': True}) + defaults.update({'timesheet': True}) if k == 'delivery': - res.update({'sale_orders': True, 'deli_orders': True}) + defaults.update({'sale_orders': True, 'deli_orders': True, 'charge_delivery': True}) + if k == 'picking_policy' and defaults[k]=='one': + defaults.update({'picking_policy': True}) else: res.update({k: False}) + res.update(defaults) return res _defaults = { 'order_policy': 'manual', 'tax_policy': 'no_tax', '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, - 'task_work': default_module_get, - 'timesheet': default_module_get, - 'sale_orders': default_module_get, - 'deli_orders': default_module_get, - 'sale_margin' : default_module_get, - 'sale_journal': default_module_get, } def onchange_order(self, cr, uid, ids, sale, deli, context=None): @@ -1396,16 +1399,14 @@ class sale_configuration(osv.osv_memory): res.update({'order_policy': 'picking'}) return {'value':res} - def write(self, cr, uid, ids, vals, context=None): - self.execute(cr, uid, ids, context=context) - return super(sale_configuration, self).write(cr, uid, ids, vals, context=context) - def execute(self, cr, uid, ids, context=None): + #TODO: TO BE IMPLEMENTED ir_values_obj = self.pool.get('ir.values') data_obj = self.pool.get('ir.model.data') menu_obj = self.pool.get('ir.ui.menu') module_obj = self.pool.get('ir.module.module') - module_upgrade_obj = self.pool.get('base.module.upgrade') + + super(sale_configuration, self).execute(cr, uid, ids, context=context) module_name = [] group_id = data_obj.get_object(cr, uid, 'base', 'group_sale_salesman').id @@ -1431,8 +1432,10 @@ class sale_configuration(osv.osv_memory): if wizard.charge_delivery: module_name.append('delivery') + if wizard.picking_policy: + ir_values_obj.set(cr, uid, 'default', False, 'picking_policy', ['sale.order'], 'one') + if len(module_name): - module_ids = [] need_install = False module_ids = [] for module in module_name: From 650151e6fc520ce76ce3673049a7b2a16b2daa2c Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Fri, 24 Feb 2012 15:58:01 +0530 Subject: [PATCH 06/80] [IMP] change field name bzr revid: tpa@tinyerp.com-20120224102801-x7nfb4fgtvr5w0xi --- addons/sale/sale_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index dee42ec3c93..31b8bb97f97 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -546,7 +546,7 @@ - + From 49b2920b8298e20e12944bb067f3ede1b02d07b7 Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Mon, 27 Feb 2012 11:26:35 +0530 Subject: [PATCH 07/80] [IMP]: Improved code. bzr revid: uco@tinyerp.com-20120227055635-ugxsh4rh6flw3ryu --- addons/account/account_installer.xml | 7 -- addons/plugin_outlook/plugin_outlook.xml | 15 ++-- .../plugin_thunderbird/plugin_thunderbird.xml | 16 +++-- addons/sale/sale.py | 70 +++++++++++-------- addons/sale/sale_view.xml | 1 - addons/sale/security/sale_security.xml | 8 +-- addons/sale/test/manual_order_policy.yml | 6 +- 7 files changed, 70 insertions(+), 53 deletions(-) diff --git a/addons/account/account_installer.xml b/addons/account/account_installer.xml index 430d65e0bf9..01c684a0736 100644 --- a/addons/account/account_installer.xml +++ b/addons/account/account_installer.xml @@ -55,13 +55,6 @@ 5 - - - - 3 - automatic - - Review your Financial Accounts ir.actions.act_window diff --git a/addons/plugin_outlook/plugin_outlook.xml b/addons/plugin_outlook/plugin_outlook.xml index 37b924f319f..68e265e0730 100644 --- a/addons/plugin_outlook/plugin_outlook.xml +++ b/addons/plugin_outlook/plugin_outlook.xml @@ -48,11 +48,16 @@ new - - - - 4 - automatic + + Sales Application + sale.configuration + form + + + +