Skip to Content
Menu
This question has been flagged

i try to send invoice email via XMLRPC with Ripcord in PHP.. i find something like https://www.odoo.com/id_ID/forum/help-1/send-invoice-mail-from-python-code-148921

but, it using Python

Any ideas how to send invoice email via XMLRPC with Ripcord in PHP?


i already try this :

$send_email_button = $object->execute_kw
            $this->db,
            $login,
            $request->password,
            'account.invoice',
            'action_invoice_sent',
            [
                (int)$id
            ]
        );


but it just return some invoice data template


and i try this to send the email :

$send_email = $object->execute_kw
            $this->db,
            $login,
            $request->password,
            'mail.compose.message',
            'send_mail',
            [$send_email_button['context']]


but it just return error like this :

{
    "faultCode"1,
    "faultString""Traceback (most recent call last):\n  File \"/odoo/odoo-server/odoo/fields.py\", line 940, in __get__\n    value = record.env.cache.get(record, self)\n  File \"/odoo/odoo-server/odoo/api.py\", line 967, in get\n    value = self._data[key][field][record._ids[0]]\nKeyError: 'default_use_template'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/odoo/odoo-server/odoo/service/wsgi_server.py\", line 124, in wsgi_xmlrpc\n    result = odoo.http.dispatch_rpc(service, method, params)\n  File \"/odoo/odoo-server/odoo/http.py\", line 118, in dispatch_rpc\n    result = dispatch(method, params)\n  File \"/odoo/odoo-server/odoo/service/model.py\", line 39, in dispatch\n    res = fn(db, uid, *params)\n  File \"/odoo/odoo-server/odoo/service/model.py\", line 153, in execute_kw\n    return execute(db, uid, obj, method, *args, **kw or {})\n  File \"/odoo/odoo-server/odoo/service/model.py\", line 97, in wrapper\n    return f(dbname, *args, **kwargs)\n  File \"/odoo/odoo-server/odoo/service/model.py\", line 160, in execute\n    res = execute_cr(cr, uid, obj, method, *args, **kw)\n  File \"/odoo/odoo-server/addons/smile_perf_analyzer/models/service.py\", line 16, in execute_cr\n    res = profile(native_execute_cr)(cr, uid, obj, method, *args, **kw)\n  File \"/odoo/odoo-server/addons/smile_perf_analyzer/tools/decorators.py\", line 26, in wrapper\n    return func(*args, **kwargs)\n  File \"/odoo/odoo-server/odoo/service/model.py\", line 149, in execute_cr\n    return odoo.api.call_kw(recs, method, args, kw)\n  File \"/odoo/odoo-server/odoo/api.py\", line 689, in call_kw\n    return call_kw_multi(method, model, args, kwargs)\n  File \"/odoo/odoo-server/odoo/api.py\", line 680, in call_kw_multi\n    result = method(recs, *args, **kwargs)\n  File \"/odoo/odoo-server/addons/purchase/models/purchase.py\", line 1151, in send_mail\n    return super(MailComposeMessage, self).send_mail(auto_commit=auto_commit)\n  File \"/odoo/odoo-server/addons/sale/wizard/mail_compose_message.py\", line 17, in send_mail\n    return super(MailComposeMessage, self).send_mail(auto_commit=auto_commit)\n  File \"/odoo/odoo-server/addons/account/models/account_invoice.py\", line 1846, in send_mail\n    return super(MailComposeMessage, self).send_mail(auto_commit=auto_commit)\n  File \"/odoo/odoo-server/addons/mail/wizard/mail_compose_message.py\", line 205, in send_mail\n    if wizard.attachment_ids and wizard.composition_mode != 'mass_mail' and wizard.template_id:\n  File \"/odoo/odoo-server/odoo/fields.py\", line 944, in __get__\n    self.determine_value(record)\n  File \"/odoo/odoo-server/odoo/fields.py\", line 1045, in determine_value\n    record._prefetch_field(self)\n  File \"/odoo/odoo-server/odoo/models.py\", line 2653, in _prefetch_field\n    result = records.read([f.name for f in fs], load='_classic_write')\n  File \"/odoo/odoo-server/addons/mail/models/mail_message.py\", line 800, in read\n    self.check_access_rule('read')\n  File \"/odoo/odoo-server/addons/mail/wizard/mail_compose_message.py\", line 147, in check_access_rule\n    return super(MailComposer, self).check_access_rule(operation)\n  File \"/odoo/odoo-server/addons/mail/models/mail_message.py\", line 620, in check_access_rule\n    WHERE m.id = ANY (%%(ids)s)\"\"\" % self._table, dict(pid=self.env.user.partner_id.id, ids=self.ids))\n  File \"/odoo/odoo-server/addons/smile_perf_analyzer/tools/decorators.py\", line 45, in wrapper\n    return func(self, query, params, log_exceptions)\n  File \"/odoo/odoo-server/odoo/sql_db.py\", line 155, in wrapper\n    return f(self, *args, **kwargs)\n  File \"/odoo/odoo-server/odoo/sql_db.py\", line 232, in execute\n    res = self._obj.execute(query, params)\npsycopg2.ProgrammingError: operator does not exist: integer = text\nLINE 16:                 WHERE m.id = ANY (ARRAY['default_use_templat...\n                                    ^\nHINT:  No operator matches the given name and argument types. You might need to add explicit type casts.\n\n"
}


Avatar
Discard
Author Best Answer

Nevermind,


I try another way with Odoo Custom Module, i create odoo custom module and create Class that contain function like this : 


class AccountInvoice(models.Model):

        _inherit = 'account.invoice'

        @api.multi

        def send_invoice_email(self):

                template = self.env.ref('account.email_template_edi_invoice')

                template.send_mail(self.id, force_send=True)

                return True



and call this in PHP Ripcord :

$send_email = $object->execute_kw
            $this->db,
            $login,
            $request->password,
            'account.invoice',
            'send_invoice_email' 
            [
                (int)$invoice_id
            ]
        );
Avatar
Discard
Related Posts Replies Views Activity
0
Apr 22
1671
2
Apr 22
6408
2
Jan 20
12771
5
Jul 17
4630
3
Mar 15
3398