IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Odoo (ex-OpenERP) Discussion :

TVA produit et xml rpc vers odoo 8.0


Sujet :

Odoo (ex-OpenERP)

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2011
    Messages
    131
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Mars 2011
    Messages : 131
    Points : 49
    Points
    49
    Par défaut TVA produit et xml rpc vers odoo 8.0
    Bonjour,

    J'aimerais savoir commentpeut ont correctement gérer les tax d'une facturation d'un site de ecommerce vers Odoo.

    Mon pb est que odoo prend toujours les 20% ACH-20 sachant que mon produit est à 5.5
    j'ai aussi essayé de configuré le produit à 5.5 mais il prend 20 comme taxe.

    Merci

    Mon script

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    
          for ($o=0, $n=$count_products; $o<$n; $o++) {
    
    //******************************************
    // research invoice_id by origin invoice
    //***************************************
    // ====> mettre en relation avec la B2B
            $ids = $OSCOM_ODOO->odooSearch('default_code', '=', $order->products[$o]['model'], 'product.template');
    
    // **********************************
    // read id products odoo
    // **********************************
    
            $field_list = array('default_code',
                                'id'
                                );
    
            $Qodoo_products_id = $OSCOM_ODOO->readOdoo($ids, $field_list, 'product.template');
            $odoo_products_id = $Qodoo_products_id[0][id];
    
    // **********************************
    // tax
    // **********************************
    
    /*
            (0, 0, { values }) link to a new record that needs to be created with the given values dictionary
            (1, ID, { values }) update the linked record with id = ID (write *values* on it)
            (2, ID) remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well)
            (3, ID) cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself)
            (4, ID) link to existing record with id = ID (adds a relationship)
            (5) unlink all (like using (3,ID) for all linked records)
              (6, 0, [IDs]) replace the list of linked IDs (like using (5) then (4,ID) for each ID in the list of IDs)
            Example: [(6, 0, [8, 5, 6, 4])] sets the many2many to ids [8, 5, 6, 4]
    */
    
    
          $QProductsTax = $OSCOM_PDO->prepare('select products_tax
                                               from :table_orders_products
                                               where orders_id = :orders_id
                                               and products_id = :products_id
                                               ');
          $QProductsTax->bindInt(':orders_id', (int)$insert_id);
          $QProductsTax->bindValue(':products_id', $order->products[$o]['id']);
          $QProductsTax->execute();
    
          $products_tax = $QProductsTax->fetch();
          $products_tax = round($products_tax, 2);
    
    //******************************************
    // research tax_id by amount tax
    //***************************************
    
            $ids = $OSCOM_ODOO->odooSearch('amount', 'like', $products_tax, 'account.tax');
    // **********************************
    // read id  in account.tax
    // **********************************
    
            $field_list = array('id');
    
            $QodooProductsTaxId = $OSCOM_ODOO->readOdoo($ids, $field_list, 'account.tax');
            $odoo_products_tax_id = $QodooProductsTaxId[0][id];
    
            $tax = array(new xmlrpcval(
                                        array(
                                          new xmlrpcval(6, "int"),// 6 : id link
                                          new xmlrpcval(0, "int"),
                                          new xmlrpcval(array(new xmlrpcval($odoo_products_tax_id, "int")),"array")
                                        ),"array"
                                      )
                          );
    
    // **********************************
    // Write a new line concerning the invoice
    // **********************************
    
            $values = array (
                            "order_id" => new xmlrpcval($invoice_id, "int"),
                            "product_id" => new xmlrpcval($odoo_products_id, "int"),
                            "company_id" => new xmlrpcval($company_id, "int"),
                            "name" => new xmlrpcval($order->products[$o]['name'], "string"),
                            "price_unit" => new xmlrpcval($order->products[$o]['final_price'],"double"),
                            "product_uom_qty" => new xmlrpcval($order->products[$o]['qty'], 'int'),
                            "tax_id" =>  new xmlrpcval($tax, 'array'),
                            );
    
            $OSCOM_ODOO->createOdoo($values, "sale.order.line");
    
          } //end for

  2. #2
    Expert confirmé
    Avatar de N1bus
    Homme Profil pro
    Dev. Web & OpenERP
    Inscrit en
    Janvier 2003
    Messages
    2 827
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 59
    Localisation : France, Seine et Marne (Île de France)

    Informations professionnelles :
    Activité : Dev. Web & OpenERP
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Janvier 2003
    Messages : 2 827
    Points : 5 673
    Points
    5 673
    Par défaut
    Bonjour,

    Regarde dans Configuration -> Comptabilité -> Sélectionne la société et dans eFacturation & Fournisseur, mets la taxe d'achat par défaut ACH-5.5

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2011
    Messages
    131
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Mars 2011
    Messages : 131
    Points : 49
    Points
    49
    Par défaut
    Non c'est pas possible, les produits peuvent avoir plusieurs taux, sans taxes, TVA 20, tva 5.5 ....

    Donc voici ce que j'ai fait : Cela fonctionne en partie pour le moment. Mais à partir de la deuxième boucle, les taux partent en vrille.

    D'après ce post (https://www.odoo.com/forum/help-1/qu...cation-c-64823) (à la fin), il faudrait faire un : on_change_product_id dans sale.order.line . Hors la pour le moment je bloque.

    L'autre point que j'ai à régler, c'est que le système prenne la taxe de vente et non pas la taxe d'achat

    Voici mon script qui fonctionne
    Des idées pour l'améliorer

    Merci.


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    // count number of product
          $count_products = sizeof($order->products);
    
          for ($o=0, $n=$count_products; $o<$n; $o++) {
    
    
    //******************************************
    // research invoice_id by origin invoice
    //***************************************
    // ====> mettre en relation avec la B2B
            $ids = $OSCOM_ODOO->odooSearch('default_code', '=', $order->products[$o]['model'], 'product.template');
    
    // **********************************
    // read id products odoo
    // **********************************
    
            $field_list = array('default_code',
                                'id'
                                );
    
            $Qodoo_products_id = $OSCOM_ODOO->readOdoo($ids, $field_list, 'product.template');
            $odoo_products_id = $Qodoo_products_id[0][id];
    
    
    // **********************************
    // tax
    // **********************************
    
    /*
            (0, 0, { values }) link to a new record that needs to be created with the given values dictionary
            (1, ID, { values }) update the linked record with id = ID (write *values* on it)
            (2, ID) remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well)
            (3, ID) cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself)
            (4, ID) link to existing record with id = ID (adds a relationship)
            (5) unlink all (like using (3,ID) for all linked records)
              (6, 0, [IDs]) replace the list of linked IDs (like using (5) then (4,ID) for each ID in the list of IDs)
            Example: [(6, 0, [8, 5, 6, 4])] sets the many2many to ids [8, 5, 6, 4]
    */
    
    
          $QProductsTax = $OSCOM_PDO->prepare('select products_tax
                                               from :table_orders_products
                                               where orders_id = :orders_id
                                               and products_id = :products_id
                                               ');
          $QProductsTax->bindInt(':orders_id', (int)$insert_id);
          $QProductsTax->bindValue(':products_id', $order->products[$o]['id']);
          $QProductsTax->execute();
    
          $products_tax = $QProductsTax->fetch();
          $products_tax = round(($products_tax['products_tax']/100), 3);
     //     $products_tax = 0.055;
    //******************************************
    // research tax_id by amount tax
    //***************************************
    
    
    // **********************************
    // read id  in account.tax
    // **********************************
    
            $field_list = array('id',
                                'amount',
                               );
    
            $QodooProductsTaxId = $OSCOM_ODOO->readOdoo($ids, $field_list, 'account.tax');
            $odoo_products_tax_id = $QodooProductsTaxId[0][id];
            $odoo_products_tax_amount = $QodooProductsTaxId[0][amount];
    
            $tax = array(new xmlrpcval(
                                        array(
                                          new xmlrpcval(6, "int"),// 6 : id link
                                          new xmlrpcval(0, "int"),
                                          new xmlrpcval(array(new xmlrpcval($odoo_products_tax_id, "int")),"array")
                                        ),"array"
                                      )
                          );
    
    
    
    // **********************************
    // Write a new line concerning the invoice
    // **********************************
    
            $values = array (
                            "order_id" => new xmlrpcval($invoice_id, "int"),
                            "product_id" => new xmlrpcval($odoo_products_id, "int"),
                            "company_id" => new xmlrpcval($company_id, "int"),
                            "name" => new xmlrpcval($order->products[$o]['name'], "string"),
                            "price_unit" => new xmlrpcval($order->products[$o]['final_price'],"double"),
                            "product_uom_qty" => new xmlrpcval($order->products[$o]['qty'], 'int'),
                            "tax_id" =>  new xmlrpcval($tax, 'array'),
                            );
    
            $OSCOM_ODOO->createOdoo($values, "sale.order.line");
          } //end for

Discussions similaires

  1. [V8] Créer une quantité de produit en xml rpc dans Odoo
    Par oitsuki dans le forum Odoo (ex-OpenERP)
    Réponses: 8
    Dernier message: 12/12/2014, 16h05
  2. [V8] Envoyer une image dans odoo xml-rpc
    Par oitsuki dans le forum Odoo (ex-OpenERP)
    Réponses: 3
    Dernier message: 11/12/2014, 02h35
  3. [SOAP] [XML-RPC] la différence
    Par david42 dans le forum XML/XSL et SOAP
    Réponses: 2
    Dernier message: 02/03/2004, 08h52
  4. XML/XSL vers HTML: comment transformer les linefeed en <B
    Par AlainM dans le forum XSL/XSLT/XPATH
    Réponses: 5
    Dernier message: 18/11/2003, 12h30

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo