Yenthe666 / Odoo_Samples

This repository contains samples with Odoo code
GNU Affero General Public License v3.0
241 stars 306 forks source link

Can you help me #2

Closed diezcode closed 8 years ago

diezcode commented 8 years ago

Can you help me with this email script?

I dont get it, this is my base.py file:

from openerp import models, fields, api from openerp.osv import fields, osv

def send_mail_example(self,cr,uid,ids,odoo_record,context=None):
    ir_mail_server = self.pool.get('ir.mail_server')
    title = "Your e-mail title"
    message = "This is the concent from your e-mail. An example from a field inside the e-mail: " + odoo_record.odoo_dns_url + "\n\nWith kind regards,\nYenthe"
    #Structure mail function: def build_email(self, email_from, email_to, subject, body, email_cc=None, email_bcc=None, reply_to=False,
        msg = ir_mail_server.build_email("stee.diez@gmx.ch", ["stee.diez@gmx.ch"], title, message,["stee.diez@gmx.ch"],[],"stee.diez@gmx.ch")
        ir_mail_server.send_email(cr, uid, msg)

The form is with this:

              <form name="mailsend" method="post">
                <table border="0" cellspacing="0" cellpadding="2">
                    <tbody>
                        <p>text:</p>
                            <tr>
                            <td><textarea cols="50" rows="5" name="Mitteilung">Ihre Mitteilung</textarea></td>
                            </tr>
                            <tr>
                            <td>
                            <!--<input type="submit" value="Abschicken" />--><button name="send_mail_example" type="object" string="Send E-mail">SEND</button>
                            </td>
                            </tr>
                    </tbody>
                </table>
              </form>
Yenthe666 commented 8 years ago

@diezcode what exactly is your problem and/or is not working? I'll need some more information before I can help you along. :+1:

diezcode commented 8 years ago

Thank you for you're time. @Yenthe666 I never getting an email with this example. I'm receiving nothing and I don't know why. I want to add a button in odoo, that when I push it, it sends me a simple email with a subject and a text.

diezcode commented 8 years ago

no idea? ;)

Yenthe666 commented 8 years ago

Sorry @diezcode this got lost in my filled up mailbox.. :sheep: Add some log statements and see if the function is triggered when you click on the button. Also make sure that you have an outgoing mailserver & that it is working fine.

diezcode commented 8 years ago

No, it's not going in the function... I don't know why,

Yenthe666 commented 8 years ago

Sounds to me like either your Python files are not loaded or that you haven't included them. Could you place your code on your Github and link it here? I'll try to have a look at it then.

diezcode commented 8 years ago

So here is it: https://github.com/diezcode/test_mail_module

I hope you can tell me what I am doing wrong in this module.

Thank you my friend

Yenthe666 commented 8 years ago

@diezcode see https://github.com/diezcode/test_mail_module/pull/1 you've missed the @api.one statement before the method.

diezcode commented 8 years ago

I have this error:

@api.one

NameError: name 'api' is not defined

diezcode commented 8 years ago

Ok the modul works, but it don't going in the function. How can I call this function send_mail_example.

Yenthe666 commented 8 years ago

Update your modules list + db and see if works then. Add log statements to double check it doesn't go there. I'm going to guess you didn't update your module.

diezcode commented 8 years ago

2015-11-13 11:09:54,762 3720 ERROR db_testing_modul werkzeug: Error on request: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 177, in run_wsgi execute(self.server.app) File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 165, in execute application_iter = app(environ, start_response) File "/usr/lib/python2.7/dist-packages/openerp/service/server.py", line 281, in app return self.app(e, s) File "/usr/lib/python2.7/dist-packages/openerp/service/wsgi_server.py", line 216, in application return application_unproxied(environ, start_response) File "/usr/lib/python2.7/dist-packages/openerp/service/wsgi_server.py", line 202, in application_unproxied result = handler(environ, start_response) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1280, in call return self.dispatch(environ, start_response) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1254, in call return self.app(environ, start_wrapped) File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 579, in call return self.app(environ, start_response) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1412, in dispatch ir_http = request.registry['ir.http'] File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 339, in registry return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 335, in get update_module) File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 366, in new openerp.modules.load_modules(registry._db, force_demo, status, update_module) File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 351, in load_modules force, status, report, loaded_modules, update_module) File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 255, in load_marked_modules loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks) File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 152, in load_module_graph models = registry.load(cr, package) File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 162, in load model = cls._build_model(self, cr) File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 591, in _build_model original_module = pool[name]._original_module if name in parents else cls._module File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 101, in getitem return self.models[model_name] KeyError: 'mail.mail'

what means this? _inherit = 'mail.mail' is wrong?

atchuthan commented 8 years ago

add 'mail' module in your dependency list at openerp.py

Yenthe666 commented 8 years ago

Exactly what atchuthan says. Add it here: https://github.com/diezcode/test_mail_module/blob/master/base_mail_test/__openerp__.py#L9

diezcode commented 8 years ago

Okay that works now, thank you guys, The function isn't called out . I updated the modul and tryed to debug the function, but it's not going inside....

diezcode commented 8 years ago

@Yenthe666 @atchuthan i'ts not working ;(

diezcode commented 8 years ago

I don't get it , why it's never going in the function when I click the button ;(

Yenthe666 commented 8 years ago

See https://github.com/diezcode/test_mail_module/pull/2