Ravi Gadhia (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-social-account-rga into
lp:~openerp-dev/openobject-addons/trunk-social-tde.
Requested reviews:
Thibault Delavallée (OpenERP) (tde-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-social-account-rga/+merge/98341
Added social chatter notification for invoice
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-social-account-rga/+merge/98341
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-social-tde.
=== modified file 'account/account_invoice.py'
--- account/account_invoice.py 2012-02-28 14:08:16 +0000
+++ account/account_invoice.py 2012-03-20 05:48:54 +0000
@@ -178,6 +178,7 @@
return invoice_ids
_name = "account.invoice"
+ _inherit = "mail.thread"
_description = 'Invoice'
_order = "id desc"
@@ -357,12 +358,8 @@
context = {}
try:
res = super(account_invoice, self).create(cr, uid, vals, context)
- for inv_id, name in self.name_get(cr, uid, [res], context=context):
- ctx = context.copy()
- if vals.get('type', 'in_invoice') in ('out_invoice', 'out_refund'):
- ctx = self.get_log_context(cr, uid, context=ctx)
- message = _("Invoice '%s' is waiting for validation.") % name
- self.log(cr, uid, inv_id, message, context=ctx)
+ if res:
+ self.create_send_note(cr, uid, [res], context=context)
return res
except Exception, e:
if '"journal_id" viol' in e.args[0]:
@@ -375,9 +372,7 @@
if context is None:
context = {}
self.write(cr, uid, ids, {'state':'paid'}, context=context)
- for inv_id, name in self.name_get(cr, uid, ids, context=context):
- message = _("Invoice '%s' is paid.") % name
- self.log(cr, uid, inv_id, message)
+ self.invoice_paid_send_note(cr, uid, ids, context=context)
return True
def unlink(self, cr, uid, ids, context=None):
@@ -949,6 +944,11 @@
move_obj.post(cr, uid, [move_id], context=ctx)
self._log_event(cr, uid, ids)
return True
+
+ def invoice_validate(self, cr, uid, ids, context=None):
+ self.write(cr, uid, ids, {'state':'open'}, context=context)
+ self.invoice_validate_send_note(cr, uid, ids, context=context)
+ return True
def line_get_convert(self, cr, uid, x, part, date, context=None):
return {
@@ -1039,6 +1039,7 @@
# will be automatically deleted too
account_move_obj.unlink(cr, uid, move_ids, context=context)
self._log_event(cr, uid, ids, -1.0, 'Cancel Invoice')
+ self.invoice_cancel_send_note(cr, uid, ids, context=context)
return True
###################
@@ -1246,7 +1247,42 @@
# Update the stored value (fields.function), so we write to trigger recompute
self.pool.get('account.invoice').write(cr, uid, ids, {}, context=context)
return True
-
+ # -----------------------------
+ # OpenChatter and notifications
+ # -----------------------------
+ def _get_document_type(self, type):
+ type_dict = {
+ 'out_invoice': 'Customer invoice',
+ 'in_invoice': 'Supplier invoice',
+ 'out_refund': 'Customer Refund',
+ 'in_refund': 'Supplier Refund',
+ }
+ return type_dict[type]
+
+ def create_send_note(self, cr, uid, ids, context=None):
+ for obj in self.browse(cr, uid, ids, context=context):
+ self.message_append_note(cr, uid, [obj.id], _('System notification'),
+ _("""%s <b>created</b>.""") % (self._get_document_type(obj.type)),
+ type='notification', context=context)
+
+ def invoice_validate_send_note(self, cr, uid, ids, context=None):
+ for obj in self.browse(cr, uid, ids, context=context):
+ self.message_append_note(cr, uid, [obj.id], _('System notification'),
+ _("""%s <b>validated</b>.""") % (self._get_document_type(obj.type)),
+ type='notification', context=context)
+
+ def invoice_paid_send_note(self, cr, uid, ids, context=None):
+ for obj in self.browse(cr, uid, ids, context=context):
+ self.message_append_note(cr, uid, [obj.id], _('System notification'),
+ _("""%s <b>paid</b>.""") % (self._get_document_type(obj.type)),
+ type='notification', context=context)
+
+ def invoice_cancel_send_note(self, cr, uid, ids, context=None):
+ for obj in self.browse(cr, uid, ids, context=context):
+ self.message_append_note(cr, uid, [obj.id], _('System notification'),
+ _("""%s <b>cancelled</b>.""") % (self._get_document_type(obj.type)),
+ type='notification', context=context)
+
account_invoice()
class account_invoice_line(osv.osv):
=== modified file 'account/account_invoice_view.xml'
--- account/account_invoice_view.xml 2012-02-28 14:08:16 +0000
+++ account/account_invoice_view.xml 2012-03-20 05:48:54 +0000
@@ -245,6 +245,7 @@
</field>
</page>
</notebook>
+ <field name="message_ids_social" colspan="4" widget="ThreadView" nolabel="1"/>
</form>
</field>
</record>
@@ -343,6 +344,7 @@
</field>
</page>
</notebook>
+ <field name="message_ids_social" colspan="4" widget="ThreadView" nolabel="1"/>
</form>
</field>
</record>
=== modified file 'account/account_invoice_workflow.xml'
--- account/account_invoice_workflow.xml 2011-01-14 00:11:01 +0000
+++ account/account_invoice_workflow.xml 2012-03-20 05:48:54 +0000
@@ -27,7 +27,7 @@
<field name="action">action_date_assign()
action_move_create()
action_number()
-write({'state':'open'})</field>
+invoice_validate()</field>
<field name="kind">function</field>
</record>
<record model="workflow.activity" id="act_open_test">
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp