postgresql 发票报告-在线发票中显示折扣- Odoo 12 - Qweb

0dxa2lsx  于 2023-02-12  发布在  PostgreSQL
关注(0)|答案(2)|浏览(142)

我正在为发票行做一个报告,我已经在第三方odoo商店购买了一个模块,它执行它的功能很好。
但我看不到发票行上的折扣。
我想这是因为模块阻止了我,但我已经没有开发人员支持了。
我需要的是折扣(价目表)可以在发票行上看到。
发票行折扣的哪个表或要素?
我把报告里的代码留给你
''''

<tbody class="invoice_tbody">

                <tr t-foreach="invoice_lines[0]" t-as="line">

                    <td><b><span t-esc="line['client_ref']"/></b>

                        <span t-esc="line['description']"/></td>

                    <td class="text-right">

                        <span t-esc="line['qty']"/>

                    </td>

                    <td class="text-right">

                        <span t-esc="line['price_unit']"/>

                    </td>

                    <td t-if="display_discount" class="text-right">

                    </td>

                    <td class="text-right" id="subtotal">

                        <t t-if="line['price_subtotal']">

                        <span t-esc = "line ['price_subtotal']" t-options = "{& quot; widget & quot ;: & quot; monetario & quot ;, & quot; display_currency & quot ;: o.currency_id}" /> </t>

                    </td>

                </tr>

                <tr t-foreach = "range (max (5-len (o.invoice_line_ids), 0))" t-as = "l">

                    <td t-translation = "off"> & amp; nbsp; </td>

                    <td class = "hidden" />

                    <td />

                    <td />

                    <td t-if = "display_discount" />

                    <td />

                    <td />

                </tr>

            </tbody>

        </t>

'''

bvpmtnay

bvpmtnay1#

是,此参数在报表“视图/报表_发票_文档”中
但我尝试修改的报告是这样的

报表发票单据继承

<?xml version="1.0"?>
<data inherit_id="account.report_invoice_document">
        <xpath expr="//table[@name='invoice_line_table']/tbody" position="replace">
            <t t-if="res_company.is_group_by_so">
                <t t-set="invoice_lines" t-value="o.get_invoice_lines()"/>
                <tbody class="invoice_tbody">
                    <tr t-foreach="invoice_lines[0]" t-as="line">
                        <td><b><span t-esc="line['client_ref']"/></b>
                            <span t-esc="line['description']"/></td>
                        <!-- <td class="hidden"><span t-esc="line['client_ref']"/></td> -->
                        <td class="text-right">
                            <span t-esc="line['qty']"/>
                            <!-- <span t-field="l.uom_id"  groups="product.group_uom"/> -->
                        </td>
                        <td class="text-right">
                            <span t-esc="line['price_unit']"/>
                        </td>
                      </td>
                        <td t-if="display_discount" class="text-right">
                            <!-- <span t-esc="line['price_unit']"/> -->
                        </td>
                        <td class="text-right" id="subtotal">
                            <t t-if="line['price_subtotal']">
                            <span t-esc="line['price_subtotal']" t-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: o.currency_id}"/></t>
                        </td>
                    </tr>
                    <tr t-foreach="range(max(5-len(o.invoice_line_ids),0))" t-as="l">
                        <td t-translation="off">&amp;nbsp;</td>
                        <td class="hidden"/>
                        <td/>
                        <td/>
                        <td t-if="display_discount"/>
                        <td/>
                        <td/>
                    </tr>
                </tbody>
            </t>
            <t t-else="">
                <tbody class="invoice_tbody">
                    <tr t-foreach="o.invoice_line_ids" t-as="l">
                        <td><span t-field="l.name"/></td>
                        <td class="hidden"><span t-field="l.origin"/></td>
                        <td class="text-right">
                            <span t-field="l.quantity"/>
                            <span t-field="l.uom_id" groups="product.group_uom"/>
                        </td>
                        <td class="text-right">
                            <span t-field="l.price_unit"/>
                        </td>
                        <td t-if="display_discount" class="text-right">
                            <span t-field="l.discount"/>
                        </td>
                        <td class="text-right">
                            <span t-esc="', '.join(map(lambda x: (x.description or x.name), l.invoice_line_tax_ids))"/>
                        </td>
                        <td class="text-right" id="subtotal">
                            <span t-field="l.price_subtotal" t-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: o.currency_id}"/>
                        </td>
                    </tr>
                    <tr t-foreach="range(max(5-len(o.invoice_line_ids),0))" t-as="l">
                        <td t-translation="off">&amp;nbsp;</td>
                        <td class="hidden"/>
                        <td/>
                        <td/>
                        <td t-if="display_discount"/>
                        <td/>
                        <td/>
                    </tr>
                </tbody>
            </t>   
        </xpath>
    </data>

我已经尝试修改第二个报告,并查看了python代码,以防出现问题

发票报告分组依据\报告\帐户发票.py

# -*- coding: utf-8 -*-

从odoo导入API,从日期时间导入日期时间
类帐户发票(型号。型号):_inherit =“账户.发票”

def get_notation_amt(self, amt):
    '''This method help us to return the value of the product pricing'''
    amount = str(amt).split('.')
    if len(amount) == 2:
        amount = amount[0] + "," + amount[1]
        return amount
    return amt

@api.multi
def get_product_invoice_lines(self, client_ref=False):
    '''This method helps to get the data for the following Invoice Line.'''
    product_invoices = []
    client_order_ref = []
    for line in self.invoice_line_ids:
        sale_line = (False, line)
        if line.sale_line_ids:
            sale_line = (line.sale_line_ids[0].order_id, line)
        client_order_ref.append(sale_line)
    if client_order_ref:
        for ref in client_order_ref:
            if (client_ref == ref[0]):
                product_invoices.append({'price_subtotal': ref[1].price_unit * ref[1].quantity,
                                         'default_code': ref[1].product_id.default_code,
                                         'client_ref': False,
                                         'discount': ref[1].discount,
                                         'taxes': ",".join(map(lambda x: (x.description or x.name), ref[1].invoice_line_tax_ids)),
                                         'description': ref[1].name,
                                         'qty': self.get_notation_amt(ref[1].quantity),
                                         'price_unit': self.get_notation_amt("{0:.3f}".format(ref[1].price_unit)),
                                         })
    else:
        for line in self.invoice_line_ids:
            product_invoices.append({'price_subtotal': line.price_unit * line.quantity,
                                     'default_code': line.product_id.default_code,
                                     'client_ref': False,
                                     'discount': line.discount,
                                     'taxes': ",".join(map(lambda x: (x.description or x.name), ref[1].invoice_line_tax_ids)),
                                     'description': line.name,
                                     'qty': self.get_notation_amt(line.quantity),
                                     'price_unit': self.get_notation_amt("{0:.3f}".format(line.price_unit)),
                                     })
    return product_invoices

@api.multi
def get_invoice_lines(self):
    '''This method help to get the invoice line group by Sale order'''
    vals = []
    sale_order_lines = []
    false_sale_order_lines = []
    for line in self.invoice_line_ids:
        sale_line = False
        if line.sale_line_ids:
            sale_line = line.sale_line_ids[0].order_id
        if sale_line:
            sale_order_lines.append(sale_line)
        else:
            false_sale_order_lines.append(sale_line)
    sale_order_lines = list(set(sale_order_lines))
    false_sale_order_lines = list(set(false_sale_order_lines))

    for sale_order in sale_order_lines:
        if sale_order and self.origin:
            confirmation_date = str(
                sale_order.confirmation_date, '%d-%m-%Y %H:%M:%S').strftime('%d/%m/%Y')
            client_ref = sale_order.name + ' - ' + confirmation_date
            if sale_order.client_order_ref:
                client_ref = client_ref + ' - ' + sale_order.client_order_ref
            vals.append({'price_subtotal': False, 'default_code': False,
                         'client_ref': client_ref, 'description': False,
                         'qty': False, 'price_unit': False, 'taxes': False, 'discount': False})
        vals.extend(self.get_product_invoice_lines(client_ref=sale_order))

    # for sort false sale order, display manually invoice line at last
    for so in false_sale_order_lines:
        vals.extend(self.get_product_invoice_lines(client_ref=so))

    return [vals, len(vals)]
nnsrf1az

nnsrf1az2#

您可以在此处查看默认报告:
https://github.com/odoo/odoo/blob/06f9baae968674547cb2592b1c22147bfb2e8ba9/addons/account/views/report_invoice.xml#L49

<t t-set="display_discount" t-value="any([l.discount for l in o.invoice_line_ids])"/>

这意味着,如果任何行有折扣,则应显示折扣。
我认为有两个选项可以禁用它,一个是从报告中删除该行,另一个选项是将display_discount设置为false,知道了破坏报告的模块,问题应该很容易找到。
但是没有看到你的模块,很难说出确切的原因。

相关问题