From 67d025a4cb6cd176c7d3966b9dcca427caca36bf Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Mon, 11 Feb 2013 15:42:57 +0530 Subject: [PATCH] [IMP] sales terms & conditions note per company bzr revid: cha@tinyerp.com-20130211101257-nw5pvqrs841pe2l9 --- addons/sale/res_config.py | 17 ++++++++++++++++- addons/sale/res_config_view.xml | 19 ++++++++++++++++++- addons/sale/sale.py | 12 +++++++++++- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/addons/sale/res_config.py b/addons/sale/res_config.py index a693fd11024..2a0c8761d0e 100644 --- a/addons/sale/res_config.py +++ b/addons/sale/res_config.py @@ -76,14 +76,25 @@ Example: Product: this product is deprecated, do not purchase more than 5. 'module_sale_stock': fields.boolean("Trigger delivery orders automatically from sales orders", help="""Allows you to Make Quotation, Sale Order using different Order policy and Manage Related Stock. This installs the module sale_stock."""), + 'sale_note': fields.text('Terms & Conditions', translate=True), + 'company_id': fields.many2one('res.company', 'Company', required=True), } + def onchange_company_id(self, cr, uid, ids, company_id): + res = {'value':{}} + if company_id: + company = self.pool.get('res.company').browse(cr, uid, company_id) + res['value'].update({'sale_note': company.sale_note}) + return res + def default_get(self, cr, uid, fields, context=None): ir_model_data = self.pool.get('ir.model.data') res = super(sale_configuration, self).default_get(cr, uid, fields, context) if res.get('module_project'): user = self.pool.get('res.users').browse(cr, uid, uid, context) res['time_unit'] = user.company_id.project_time_mode_id.id + res['sale_note'] = user.company_id.sale_note + res['company_id'] = user.company_id.id else: try: product = ir_model_data.get_object(cr, uid, 'product', 'product_product_consultant') @@ -104,7 +115,7 @@ Example: Product: this product is deprecated, do not purchase more than 5. def set_sale_defaults(self, cr, uid, ids, context=None): ir_model_data = self.pool.get('ir.model.data') wizard = self.browse(cr, uid, ids)[0] - + if wizard.time_unit: try: product = ir_model_data.get_object(cr, uid, 'product', 'product_product_consultant') @@ -115,6 +126,10 @@ Example: Product: this product is deprecated, do not purchase more than 5. if wizard.module_project and wizard.time_unit: user = self.pool.get('res.users').browse(cr, uid, uid, context) user.company_id.write({'project_time_mode_id': wizard.time_unit.id}) + + if wizard.company_id: + self.pool.get('res.company').write(cr, uid, wizard.company_id.id, {'sale_note': wizard.sale_note}, context=context) + return {} def onchange_task_work(self, cr, uid, ids, task_work, context=None): diff --git a/addons/sale/res_config_view.xml b/addons/sale/res_config_view.xml index b150fb276b7..e3226a869bb 100644 --- a/addons/sale/res_config_view.xml +++ b/addons/sale/res_config_view.xml @@ -31,7 +31,24 @@ - + + + + +
diff --git a/addons/sale/sale.py b/addons/sale/sale.py index cddde4a5f08..23b05977e40 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -261,6 +261,7 @@ class sale_order(osv.osv): 'shop_id': _get_default_shop, 'partner_invoice_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').address_get(cr, uid, [context['partner_id']], ['invoice'])['invoice'], 'partner_shipping_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').address_get(cr, uid, [context['partner_id']], ['delivery'])['delivery'], + 'note': lambda self, cr, uid, context: self.pool.get('res.company').browse(cr, uid, uid, context=context).sale_note } _sql_constraints = [ ('name_uniq', 'unique(name, company_id)', 'Order Reference must be unique per Company!'), @@ -324,12 +325,16 @@ class sale_order(osv.osv): payment_term = part.property_payment_term and part.property_payment_term.id or False fiscal_position = part.property_account_position and part.property_account_position.id or False dedicated_salesman = part.user_id and part.user_id.id or uid + context_lang = context.copy() + context_lang.update({'lang': part.lang}) + company = self.pool.get('res.company').browse(cr, uid, uid, context=context_lang) val = { 'partner_invoice_id': addr['invoice'], 'partner_shipping_id': addr['delivery'], 'payment_term': payment_term, 'fiscal_position': fiscal_position, 'user_id': dedicated_salesman, + 'note': company.sale_note } if pricelist: val['pricelist_id'] = pricelist @@ -983,7 +988,12 @@ class sale_order_line(osv.osv): raise osv.except_osv(_('Invalid Action!'), _('Cannot delete a sales order line which is in state \'%s\'.') %(rec.state,)) return super(sale_order_line, self).unlink(cr, uid, ids, context=context) - +class res_company(osv.Model): + _inherit = "res.company" + _columns = { + 'sale_note': fields.text('sales_note', translate=True, placeholder="Terms & Conditions"), + } + class mail_compose_message(osv.Model): _inherit = 'mail.compose.message'