Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
7957 Lượt xem

I'm new to Odoo and one area where I'm having trouble is understanding the context around the python code you can put in server actions (what I can do, and what I can't), and what I can and can't do through XML data files.

If anybody could point me to examples of addons which do this, and thorough reference documentation and/or tutorials, it would help.

 

Edit: Digging into the XML, I have a more specific question which could be answered by pointing me at the right documentation. I can see that you add rows to a table in the DB, using XML record tags, like so:

        <record id="stock_location_locations" model="stock.location">
            <field name="name">Physical Locations</field>
            ...snip..
        </record>

Where model="" the model name, but what is the id attribute? Where can I read about what is supposed to go in there? The stock.location model doesn't have an ID field, but I would expect it to have a surrgate key called that which is managed by the ORM, so I don't know what to put there in the XML. Is it just string which is unique to the XML record tag?

Ảnh đại diện
Huỷ bỏ

An advice, you might want to pick up how to use grep. It will be an invaluable tool to search for samples within addons.

Câu trả lời hay nhất

Hello Darrel,

You can find server action example in CRM module.

STEPS:

1.GO to crm module
2.Open crm_action_rule_demo.xml
3. You can find ir.action.server example something like this:

 <record id="action_email_reminder_lead" model="ir.actions.server">
            <field name="name">Reminder to User</field>
            <field name="model_id" ref="model_crm_lead"/>
            <field name="condition">True</field>
            <field name="type">ir.actions.server</field>
            <field name="state">email</field>
            <field name="email">object.user_id.email</field>
            <field name="subject">Reminder on Lead: [[object.id ]] [[object.partner_id and 'of ' +object.partner_id.name or '']]</field>
            <field name="message">Warning unprocessed incoming lead is more than 5 day old.
Name: [[object.name ]]
ID: [[object.id ]]
Description: [[object.description]]
            </field>
        </record>

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 3 25
1284
0
thg 11 24
1479
2
thg 8 24
1451
0
thg 7 24
930
0
thg 6 24
1548