[IMP] sales terms & conditions note per company
bzr revid: cha@tinyerp.com-20130211101257-nw5pvqrs841pe2l9
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -31,7 +31,24 @@
|
||||
</div>
|
||||
</div>
|
||||
</group>
|
||||
</div>
|
||||
</div>
|
||||
<group name="Sale" position="before">
|
||||
<group>
|
||||
<label for="sale_note"/>
|
||||
<div>
|
||||
<div>
|
||||
<label for="company_id" string="Select Company"/>
|
||||
<field name="company_id"
|
||||
widget="selection"
|
||||
on_change="onchange_company_id(company_id)"
|
||||
class="oe_inline"/>
|
||||
</div>
|
||||
<div>
|
||||
<field name="sale_note" nolabel="1" class="oe_inline" placeholder="Terms & Conditions"/>
|
||||
</div>
|
||||
</div>
|
||||
</group>
|
||||
</group>
|
||||
<div name="Customer Features" position="inside">
|
||||
<div>
|
||||
<field name="group_sale_pricelist" class="oe_inline"/>
|
||||
|
||||
+11
-1
@@ -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'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user