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 :

Devis, Taxes intermédiaires


Sujet :

Odoo (ex-OpenERP)

  1. #1
    Membre à l'essai
    Homme Profil pro
    Traiteur, Evénementiel
    Inscrit en
    Octobre 2014
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : France, Pas de Calais (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Traiteur, Evénementiel

    Informations forums :
    Inscription : Octobre 2014
    Messages : 7
    Points : 12
    Points
    12
    Par défaut Devis, Taxes intermédiaires
    Bonjour,

    J'ai essayé de modifier un peu le module sale dans odoo pour détailler les taxes sur les lignes de devis mais j'ai quelques soucis. (J'avoue je suis quelque peu débutant)

    Au niveau de mon code voilà ce que j'ai dans sale.py class sale_order_line :

    J'ai rajouté ces deux fonctions :
    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
    def _tax_line(self, cr, uid, line, context=None):
            val = 0.0
            for c in self.pool.get('account.tax').compute_all(cr, uid, line.tax_id, line.price_unit * (1-(line.discount or 0.0)/100.0), line.product_uom_qty, line.product_id, line.order_id.partner_id)['taxes']:
            val += c.get('amount', 0.0)
            return res
    
        def _taxed_line(self, cr, uid, ids, field_name, arg, context=None):
            tax_obj = self.pool.get('account.tax')
            cur_obj = self.pool.get('res.currency')
            res = {}
            if context is None:
                context = {}
            for line in self.browse(cr, uid, ids, context=context):
                price = line._amount_line(self, cr, uid, ids, field_name, arg, context=None):
                tax = line._tax_line(self, cr, uid, line, context=context)
                res = price + tax
            return res
    Ensuite j'ai ajouté toujours dans cette classe les deux champs suivants :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
            'tax_subtotal': fields.function(_tax_line, string = 'Tax Subtotal', digits_compute= dp.get_precision('Account')),
            'taxed_price_subtotal': fields.(_taxed_line, string = 'Taxed Subtotal', digits_compute= dp.get_precision('Account')),
    Puis dans le fichier sale_view.xml j'ai ajouté un champ
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
                                                <field name="tax_subtotal"/>
                                                <field name="taxed_price_subtotal"/>
    Après chaque
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
                                                <field name="price_unit"/>
    J'ai droit à ce message quand je lance mon client
    Internal Server Error

    The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.


    1 - J'aimerais donc savoir où je me suis trompé :p

    2 - Et par contre dans mon fichier /var/log/odoo... .log je n'ai que des anciens messages d'il y a plus ou moins un mois, comment est-il possible de réactualiser ce fichier afin d'avoir une erreur un peu plus détaillée ?

    3 - Comment pourrais-je intégrer ça comme un module que l'on pourrait activer dans la partie configuration en cochant une petite case ? Car après si ça peut servir à quelqu'un je le partagerai (si j'arrive un jour à quelque chose !)

    Merci d'avance,
    Cordialement,
    Martin

    PS : S'il existe déjà un module je suis preneur
    NB : Odoo8

  2. #2
    Membre à l'essai
    Homme Profil pro
    Traiteur, Evénementiel
    Inscrit en
    Octobre 2014
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : France, Pas de Calais (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Traiteur, Evénementiel

    Informations forums :
    Inscription : Octobre 2014
    Messages : 7
    Points : 12
    Points
    12
    Par défaut
    Bonsoir,
    Je me suis entre deux penché sur la création d'un module pour arriver à mes fins.
    Je pense qu'il est à peu près terminé, cependant je ne le vois pas dans ma liste de modules dans la configuration.

    Je ne pense pas que cela soit un problème de droits étant donné qu'en bougeant un module non installé (type sale_layout) dans mon répertoire de modules persos je l'ai dans la liste, mais bon j'suis pas un expert des droits sur les dossiers non plus.

    Architecture du dossier :
    Dossier sale_order_line_tax
    | -- Dossier i 18n
    | -- __init__.py
    | -- __openerp__.py
    | -- sale_order_line_tax.py
    | -- sale_order_line_tax_view.xml
    | -- sale_order_line_tax_report.xml

    Je vous copie colle mes codes :

    __init__.py
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    import sale_order_line_tax
    __openerp.py__
    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
    {
        'name': 'Tax lines on Sales Order',
        'version': '1.1',
        'category': 'Sales Tax',
        'description': """
    Add additional date information to the sales order.
    ===================================================
    
    You can add the following additional dates to a sales order:
    ------------------------------------------------------------
        * Requested Date (will be used as the expected date on pickings)
        * Commitment Date
        * Effective Date
    """,
        'author': 'Martin Morez',
        'website': 'http://www.mh-receptions.com',
        'images': [],
        'depends': ['sale', 'account_voucher', 'report', 'account'],
        'data': ['sale_order_line_tax_view.xml', 'sale_order_line_tax_report.xml',],
        'demo': [],
        'test': [],
        'installable': True,
        'auto_install': False,
    }
    sale_order_line_tax.py
    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
    from openerp.osv import fields, osv
    from openerp.tools.translate import _
    
    class sale_order_tax_line(osv.osv):
        _inherit = 'sale.order.line'
    
        def _unit_tax(self, cr, uid, id, product, context=None):
            res = 0
            tax_obj = self.pool.get('account.tax')
            for line in self.browse(cr, uid, ids, context=context):
                price_unit = line.price_unit * (1 - (line.discount or 0.0)/100.0)
                partner = line.order_id.partner_id
                res = tax_obj.compute_all(cr, uid, line.tax_id, price_unit, quantity=1.0, partner)
            return res
    
        def _taxed_unit_price(self, cr, uid, id, product, context=None):
            res = 0
            for line in self.browse(cr, uid, ids, context=context):
                price_unit = line.price_unit*(1 - (line.discount or 0.0)/100)
                tax = line.unit_tax
                res = price_unit + tax
            return res
    
        def _line_order_tax(self, cr, uid, id, product, context=None):
            res = 0
            tax_obj = self.pool.get('account.tax')
            for line in self.browse(cr, uid, ids, context=context):
                price_unit = line.price_unit*(1 - (line.discount or 0.0)/100)
                tax = tax_obj.compute_all(cr, uid, line.tax_id, price_unit, line.product_uom_qty, line.product_id, line.order_id.partner_id)
    
        def _taxed_line_order(self, cr, uid, id, product, context=None):
            res = 0
            for line in self.browse(cr, uid, ids, context=context):
                price = line.price_subtotal
                tax = line.line_order_tax
                res = price + tax
            return res
    
    
        _columns = {
            'unit_tax' : fields.function(_unit_tax, string='Unit Tax', digits_compute=dp.get_precision('Account')),
            'taxed_unit_price' : fields.function(_taxed_unit_price, string='Taxed Unit Price', digits_compute=dp.get_precision('Account')),
            'line_order_tax' : fields.function(_line_order_tax, string='Tax Subtotal', digits_compute=dp.get_precision('Account')),
            'taxed_line_order' : fields.function(_taxed_line_order, string='Taxed Subtotal', digits_compute=dp.get_precision('Account')),
        }
    sale_order_line_tax_report.xml
    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
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    <?xml version="1.0" encoding="utf-8"?>
    <openerp>
    <data>
    <template id="report_saleorder_document" inherit_id="sale.report_saleorder_document">
        <t t-call="report.external_layout">
            <div class="page">
                <div class="oe_structure"/>
                <div class="row">
                    <div class="col-xs-6">
                        <p t-if="o.partner_shipping_id == o.partner_invoice_id">Invoice and shipping address:</p>
                        <p t-if="o.partner_shipping_id != o.partner_invoice_id">Invoice address: </p>
                        <div t-field="o.partner_invoice_id" 
                            t-field-options='{"widget": "contact", "fields": ["address", "name", "phone", "fax"], "no_marker": true}'/>
                        <p t-if="o.partner_id.vat">VAT: <span t-field="o.partner_id.vat"/></p>
                        <div t-if="o.partner_shipping_id != o.partner_invoice_id">
                            <p>Shipping address :</p>
                            <div t-field="o.partner_shipping_id" 
                                t-field-options='{"widget": "contact", "fields": ["address", "name", "phone", "fax"], "no_marker": true}'/>
                            <p t-if="o.partner_id.vat">VAT: <span t-field="o.partner_id.vat"/></p>
                        </div>                        
                    </div>
                    <div class="col-xs-5 col-xs-offset-1">
                        <div t-field="o.partner_id"
                            t-field-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}' />
                    </div>
                </div>
    
                <h2>
                    <span t-if="o.state not in ['draft','sent']">Order N° </span>
                    <span t-if="o.state in ['draft','sent']">Quotation N° </span>
                    <span t-field="o.name"/>
                </h2>
    
                <div class="row mt32 mb32" id="informations">
                    <div t-if="o.client_order_ref" class="col-xs-3">
                        <strong>Your Reference:</strong>
                        <p t-field="o.client_order_ref"/>
                    </div>
                    <div t-if="o.date_order" class="col-xs-3">
                        <strong t-if="o.state not in ['draft','sent']">Date Ordered:</strong>
                        <strong t-if="o.state in ['draft','sent']">Quotation Date:</strong>
                        <p t-field="o.date_order"/>
                    </div>
                    <div t-if="o.user_id.name" class="col-xs-3">
                        <strong>Salesperson:</strong>
                        <p t-field="o.user_id.name"/>
                    </div>
                    <div t-if="o.payment_term" class="col-xs-3">
                        <strong>Payment Term:</strong>
                        <p t-field="o.payment_term"/>
                    </div>
                </div>
    
                <table class="table table-condensed">
                    <thead>
                        <tr>
                            <th>Quantity</th>
                            <th>Description</th>
                            <th class="text-right">Unit Price</th>
                            <th class="text-right">Taxes</th>
                            <th class="text-right">Taxed Unit Price
                            <th groups="sale.group_discount_per_so_line">Disc.(%)</th>
                            <th class="text-right">Subtotal</th>
                            <th class="text-right">Taxes Subtotal</th>
                            <th class="text-right">Taxed Subtotal</th>
                        </tr>
                   </thead>
                   <tbody class="sale_tbody">
                        <tr t-foreach="o.order_line" t-as="l">
                            <td class="text-right">
                                <span t-field="l.product_uom_qty"/>
                                <span groups="product.group_uom" t-field="l.product_uom"/>
                            </td>
                            <td>
                               <span t-field="l.name"/>
                            </td>
                            <td class="text-right">
                                <span t-field="l.price_unit"/>
                            </td>
                            <td>
                                <span t-esc="', '.join(map(lambda x: x.name, l.tax_id))"/>
                                <span t-field="l.unit_tax" t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
                            </td>
                            <td class="text-right">
                                <span t-field="l.taxed_unit_price" t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'>
                            <td groups="sale.group_discount_per_so_line">
                                <span t-field="l.discount"/>
                            </td>
                            <td class="text-right">
                                <span t-field="l.price_subtotal"
                                    t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
                            </td>
                            <td class="text-right">
                                <span t-field="l.line_order_tax" t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
                            </td>
                            <td class="text-right">
                                <span t-field="l.taxed_line_order" t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
                            </td>
                        </tr>
                    </tbody>
                </table>
                
                <div class="row">
                    <div class="col-xs-4 pull-right">
                        <table class="table table-condensed">
                            <thead>
                                <tr>
                                    <th class="text-right">Total Without Taxes</th>
                                    <th class="text-right">Taxes</th>
                                    <th>Total</th>
                                </tr>
                            </thead>
                            <tr>
                                <td class="text-right">
                                    <span t-field="o.amount_untaxed" t-field-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: &quot;o.pricelist_id.currency_id&quot;}"/>
                                </td>
                                <td class="text-right">
                                    <span t-field="o.amount_tax" t-field-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: &quot;o.pricelist_id.currency_id&quot;}"/>
                                </td>
                                <td class="text-right">
                                    <span t-field="o.amount_total" t-field-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: &quot;o.pricelist_id.currency_id&quot;}"/>
                                </td>
                            </tr>
                        </table>    
                    </div>
                </div>
    
                <p t-field="o.note" />
                <p t-if="o.payment_term">
                    <strong>Payment Term:</strong>
                    <span t-field="o.payment_term"/>
                </p>
                <div class="oe_structure"/>
            </div>
        </t>
    </template>
    
    <template id="report_saleorder">
        <t t-call="report.html_container">
            <t t-foreach="doc_ids" t-as="doc_id">
                <t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'sale.report_saleorder_document')"/>
            </t>
        </t>
    </template>
    </data>
    </openerp>
    sale_order_line_tax_view.xml
    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
    <?xml version="1.0" encoding="utf-8"?>
    <openerp>
        <data>
            <record id="sale_order_line_tax_form" model="ir.ui.views">
                <field name="name">sale.order.line.form2.inherit</field>
                <field name="model">sale.order.line</field>
                <field name="inherit_id" ref="view_order_line_form2"/>
                <field name="arch" type="xml">
                    <group>
                        <field name="unit_tax"/>
                        <field name="taxed_unit_price"/>
                        <field name="line_order_tax"/>
                        <field name="taxed_line_order"/>
                    </group>
            </record>
            <record id="sale_order_line_tax_tree" model="ir.ui.views">
                <field name="name">sale.order.line.tree.inherit</field>
                <field name="model">sale.order.line</field>
                <field name="inherit_id" ref="view_order_line_tree"/>
                <field name="arch" type="xml">
                    <group>
                        <field name="unit_tax"/>
                        <field name="taxed_unit_price"/>
                        <field name="line_order_tax"/>
                        <field name="taxed_line_order"/>
                    </group>
            </record>
            <menuitem/>
        </data>
    </openerp>
    Merci d'avance, je ne sais plus trop quoi faire!

Discussions similaires

  1. [intermédiaire][TOpenDialog] conflit avec opendir
    Par thecaptain dans le forum C++Builder
    Réponses: 9
    Dernier message: 21/12/2005, 02h50
  2. [devis] Création site web pro
    Par sheepk dans le forum Général Conception Web
    Réponses: 7
    Dernier message: 28/11/2005, 13h07
  3. Réponses: 13
    Dernier message: 14/09/2005, 16h21
  4. [XSL] Arbres intermédiaires avec xsl:sort ?
    Par Blustuff dans le forum XSL/XSLT/XPATH
    Réponses: 3
    Dernier message: 04/07/2005, 10h09
  5. envoyer des données par l'intermédiaire d'un bouton
    Par mathilde50 dans le forum Access
    Réponses: 26
    Dernier message: 28/10/2004, 16h49

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