This question has been flagged
1 Reply
3087 Views

Hi,

I'm creating a data module and i want to simulate a complete workflow from sale order in draft state to a paid invoice.

When i install the module i have 2 types of problems :
- if data noupdate=0 the invoice is paid and the worflow fulfilled but i can't update the module.  To my mind this is normal.
- if data noudpdate=1, the sale order is created but it stays in draft mode. 

I don't understant why the order_confirm action is not executed in this case. Have you got an idea ?

That's my sale_order_data.xml file :

 <data noupdate="0">    
     <record id="sale_order_1" model="sale.order">
        <field name="name">SO001</field>
        <field name="partner_id" ref="res_partner_6"/>
        <field name="partner_invoice_id" ref="res_partner_6"/>
        <field name="partner_shipping_id" ref="res_partner_6"/>
        <field name="date_order" eval="time.strftime('%Y-%m-%d %H:%M')"/>
        <field name="section_id" ref="website.salesteam_website_sales"/>
        <field name="user_id" ref="res_users_5"/>
        <field name="pricelist_id" ref="product.list0"/>        
        <field name="warehouse_id" ref="stock_warehouse_1"/>        
        <field name="picking_policy">direct</field>
        <field name="order_policy">prepaid</field>        
        </record>
     <record model="sale.order.line" id="sale_order_line_1">
              <field name="order_id" ref="sale_order_1"/>
              <field name="product_id" ref="product_product_10"/>
               <field name="name">[159] SUPERLEC</field>
               <field name="price_unit">851.2</field>
               <field name="product_uom_qty">1</field>
               <field name="product_uom" ref="product.product_uom_unit"/>
          </record>    

    <!-- confirmation devis => bon de commande + création facture brouillon : 1a8 13a22
    la facture ne se crée pas qd noupadte=1-->
    <workflow action="order_confirm" model="sale.order" ref="sale_order_1"/>

    <!-- création d'une référence pour la facture et les lignes dans ir.model.data 1a8 14a22-->
    <record model="ir.model.data" id="account_invoice_SO001">
        <field name="name">account_invoice_SO001</field>        
        <field name="module">account</field>
        <field name="model">account.invoice</field>
        <field name="res_id" model="account.invoice" search="[('reference', '=', 'SO001')]"/>
        </record>


    <record model="ir.model.data" id="account_invoice_SO001_line1">
        <field name="name">account_invoice_so001_line1</field>        
        <field name="module">account</field>
        <field name="model">account.invoice.line</field>
        <field name="res_id" model="account.invoice.line" search="[('origin', '=', 'SO001'),('name','=','[159] SUPERLEC')]"/>
    </record>
    
    <workflow action="invoice_open" model="account.invoice" ref="account.account_invoice_SO001"/>

    <function model="account.invoice" name="pay_and_reconcile">
        <value eval="[ref('account.account_invoice_SO001')]"/>
        <value eval="1021.44"/>
            <value eval="ref('l10n_fr.pcg_78161')"/>
            <value eval="ref('account.fiscalyear_1_period_'+time.strftime('%m'))"/>
            <value eval="ref('account.bank_journal')"/>
            <value eval="ref('l10n_fr.pcg_78161')"/>
            <value eval="ref('account.fiscalyear_1_period_'+time.strftime('%m'))"/>
            <value eval="ref('account.bank_journal')"/>
            <value eval="{}"/>
        <value eval="str('Paiement '+str(ref('account.account_invoice_SO001')))"/>
    </function>    

  </data>

   

Avatar
Discard
Author Best Answer

Hi,

I found the problem and the solution : when we define an ir.model.data record we have to set the field noupdate to TRUE in this case (and in other places in the module).

At the end of the module installation, the program try to delete all records in ir.model.data where noupdate=0 and res_id is not null.

I hope it coult by helpfull to someone ...

Avatar
Discard