diff --git a/addons/sale/sale.py b/addons/sale/sale.py
index f564096451c..27e52cbd8cb 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -50,6 +50,12 @@ class sale_order(osv.osv):
_inherit = ['mail.thread', 'ir.needaction_mixin']
_description = "Sales Order"
+ _track = {
+ 'state': {
+ 'sale.mt_order_confirmed': lambda self, cr, uid, obj, ctx=None: obj.state in ['manual', 'progress']
+ },
+ }
+
def onchange_shop_id(self, cr, uid, ids, shop_id, context=None):
v = {}
if shop_id:
@@ -187,7 +193,8 @@ class sale_order(osv.osv):
('manual', 'Sale to Invoice'),
('invoice_except', 'Invoice Exception'),
('done', 'Done'),
- ], 'Status', readonly=True, tracked=True, help="Gives the status of the quotation or sales order. \nThe exception status is automatically set when a cancel operation occurs in the processing of a document linked to the sale order. \nThe 'Waiting Schedule' status is set when the invoice is confirmed but waiting for the scheduler to run on the order date.", select=True),
+ ], 'Status', readonly=True, track_visibility=1,
+ help="Gives the status of the quotation or sales order. \nThe exception status is automatically set when a cancel operation occurs in the processing of a document linked to the sale order. \nThe 'Waiting Schedule' status is set when the invoice is confirmed but waiting for the scheduler to run on the order date.", select=True),
'date_order': fields.date('Date', required=True, readonly=True, select=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),
'create_date': fields.datetime('Creation Date', readonly=True, select=True, help="Date on which sales order is created."),
'date_confirm': fields.date('Confirmation Date', readonly=True, select=True, help="Date on which sales order is confirmed."),
@@ -213,24 +220,24 @@ class sale_order(osv.osv):
fnct_search=_invoiced_search, type='boolean', help="It indicates that sale order has at least one invoice."),
'note': fields.text('Terms and conditions'),
- 'amount_untaxed': fields.function(_amount_all, digits_compute= dp.get_precision('Account'), string='Untaxed Amount',
- store = {
+ 'amount_untaxed': fields.function(_amount_all, digits_compute=dp.get_precision('Account'), string='Untaxed Amount',
+ store={
'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10),
'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
},
multi='sums', help="The amount without tax."),
- 'amount_tax': fields.function(_amount_all, digits_compute= dp.get_precision('Account'), string='Taxes',
- store = {
+ 'amount_tax': fields.function(_amount_all, digits_compute=dp.get_precision('Account'), string='Taxes',
+ store={
'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10),
'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
},
multi='sums', help="The tax amount."),
- 'amount_total': fields.function(_amount_all, digits_compute= dp.get_precision('Account'), string='Total',
- store = {
+ 'amount_total': fields.function(_amount_all, digits_compute=dp.get_precision('Account'), string='Total',
+ store={
'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10),
'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
},
- multi='sums', help="The total amount."),
+ multi='sums', track_visibility=2, help="The total amount."),
'invoice_quantity': fields.selection([('order', 'Ordered Quantities')], 'Invoice on', help="The sale order will automatically create the invoice proposition (draft invoice).", required=True, readonly=True, states={'draft': [('readonly', False)]}),
'payment_term': fields.many2one('account.payment.term', 'Payment Term'),
@@ -323,10 +330,7 @@ class sale_order(osv.osv):
def create(self, cr, uid, vals, context=None):
if vals.get('name','/')=='/':
vals['name'] = self.pool.get('ir.sequence').get(cr, uid, 'sale.order') or '/'
- order = super(sale_order, self).create(cr, uid, vals, context=context)
- if order:
- self.create_send_note(cr, uid, [order], context=context)
- return order
+ return super(sale_order, self).create(cr, uid, vals, context=context)
def button_dummy(self, cr, uid, ids, context=None):
return True
@@ -561,7 +565,6 @@ class sale_order(osv.osv):
wf_service.trg_validate(uid, 'account.invoice', inv, 'invoice_cancel', cr)
sale_order_line_obj.write(cr, uid, [l.id for l in sale.order_line],
{'state': 'cancel'})
- self.cancel_send_note(cr, uid, [sale.id], context=None)
self.write(cr, uid, ids, {'state': 'cancel'})
return True
@@ -596,7 +599,6 @@ class sale_order(osv.osv):
else:
self.write(cr, uid, [o.id], {'state': 'progress', 'date_confirm': fields.date.context_today(self, cr, uid, context=context)})
self.pool.get('sale.order.line').button_confirm(cr, uid, [x.id for x in o.order_line])
- self.confirm_send_note(cr, uid, ids, context)
return True
def action_quotation_send(self, cr, uid, ids, context=None):
@@ -634,7 +636,6 @@ class sale_order(osv.osv):
}
def action_done(self, cr, uid, ids, context=None):
- self.done_send_note(cr, uid, ids, context=context)
return self.write(cr, uid, ids, {'state': 'done'}, context=context)
# ------------------------------------------------
@@ -642,23 +643,7 @@ class sale_order(osv.osv):
# ------------------------------------------------
def needaction_domain_get(self, cr, uid, ids, context=None):
- return [('state', '=', 'draft'), ('user_id','=',uid)]
-
- def create_send_note(self, cr, uid, ids, context=None):
- for obj in self.browse(cr, uid, ids, context=context):
- self.message_post(cr, uid, [obj.id], body=_("Quotation for %s created.") % (obj.partner_id.name), context=context)
-
- def confirm_send_note(self, cr, uid, ids, context=None):
- for obj in self.browse(cr, uid, ids, context=context):
- self.message_post(cr, uid, [obj.id], body=_("Quotation for %s converted to Sale Order of %s %s.") % (obj.partner_id.name, obj.amount_total, obj.pricelist_id.currency_id.symbol), subtype="sale.mt_order_confirmed", context=context)
-
- def cancel_send_note(self, cr, uid, ids, context=None):
- for obj in self.browse(cr, uid, ids, context=context):
- self.message_post(cr, uid, [obj.id], body=_("Sale Order for %s cancelled.") % (obj.partner_id.name), context=context)
-
- def done_send_note(self, cr, uid, ids, context=None):
- for obj in self.browse(cr, uid, ids, context=context):
- self.message_post(cr, uid, [obj.id], body=_("Sale Order for %s set to Done") % (obj.partner_id.name), context=context)
+ return [('state', '=', 'draft'), ('user_id', '=', uid)]
def invoice_paid_send_note(self, cr, uid, ids, context=None):
self.message_post(cr, uid, ids, body=_("Invoice paid."), context=context)
diff --git a/addons/sale/sale_data.xml b/addons/sale/sale_data.xml
index 3346540907e..4a08063ea81 100644
--- a/addons/sale/sale_data.xml
+++ b/addons/sale/sale_data.xml
@@ -48,22 +48,12 @@
Quotation sent
sale.order
+ Quotation <b>send</b>
Sale Order Confirmed
sale.order
-
-
-
-
- Quotation sent
- crm.case.section
-
-
-
- Sale Order Confirmed
- crm.case.section
-
+ Quotation <b>confirmed</b>
diff --git a/addons/sale_crm/__openerp__.py b/addons/sale_crm/__openerp__.py
index 4ef6b6059f2..6591589342e 100644
--- a/addons/sale_crm/__openerp__.py
+++ b/addons/sale_crm/__openerp__.py
@@ -41,6 +41,7 @@ modules.
'data': [
'wizard/crm_make_sale_view.xml',
'sale_crm_view.xml',
+ 'sale_crm_data.xml',
'process/sale_crm_process.xml',
'security/sale_crm_security.xml',
'security/ir.model.access.csv',
diff --git a/addons/sale_crm/sale_crm.py b/addons/sale_crm/sale_crm.py
index 927b89befde..75799da5c54 100644
--- a/addons/sale_crm/sale_crm.py
+++ b/addons/sale_crm/sale_crm.py
@@ -29,15 +29,8 @@ class sale_order(osv.osv):
domain="['|',('section_id','=',section_id),('section_id','=',False), ('object_id.model', '=', 'crm.lead')]")
}
- def create(self, cr, uid, vals, context=None):
- order = super(sale_order, self).create(cr, uid, vals, context=context)
- section_id = self.browse(cr, uid, order, context=context).section_id
- if section_id:
- # subscribe salesteam followers & subtypes to the sale order
- self._subscribe_followers_subtype(cr, uid, [order], section_id, 'crm.case.section', context=context)
- return order
-
def write(self, cr, uid, ids, vals, context=None):
+ # TDE todo: will be replaced by automatic in mail.thread
if vals.get('section_id'):
section_id = self.pool.get('crm.case.section').browse(cr, uid, vals.get('section_id'), context=context)
vals['message_follower_ids'] = [(6, 0, [follower.id]) for follower in section_id.message_follower_ids]
diff --git a/addons/sale_crm/sale_crm_data.xml b/addons/sale_crm/sale_crm_data.xml
new file mode 100644
index 00000000000..4a57a9dfe2b
--- /dev/null
+++ b/addons/sale_crm/sale_crm_data.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+ Quotation sent
+ crm.case.section
+
+ section_id
+
+
+ Sale Order Confirmed
+ crm.case.section
+
+ section_id
+
+
+
+