首页 > 其他分享 >odoo16里面的常用方法

odoo16里面的常用方法

时间:2023-05-17 15:25:21浏览次数:36  
标签:常用 里面 name odoo16 align limit tg products border

一、全局搜索与显示

    def name_get(self):
        res = []
        for order in self:
            name = order.name
            if order.draw_number:
                name = "%s-%s" % (name, order.draw_number)
            res += [(order.id, name)]
        return res


@api.model def name_search(self, name='', args=None, operator='ilike', limit=100): if not args: args = [] if name: positive_operators = ['=', 'ilike', '=ilike', 'like', '=like'] products = self.env['product.template'] if operator in positive_operators: products = self.search([('name', 'ilike', name)] + args, limit=limit) if not products: products = self.search([('draw_number', 'ilike', name)] + args, limit=limit) if not products: products = self.search([('default_code', 'ilike', name)] + args, limit=limit) else: products = self.search(args, limit=limit) return products.name_get()

 

 

二、继承修改xml

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <record id="view_product_template_form_inherit" model="ir.ui.view">
        <field name="name">product.template.form.inherit</field>
        <field name="model">product.template</field>
        <field name="inherit_id" ref="product.product_template_only_form_view"/>
        <field name="arch" type="xml">
           <xpath expr="//field[@name='default_code']" position="attributes">
                <attribute name="string">物料编码</attribute>
            </xpath>
            <xpath expr="//field[@name='default_code']" position="after">
                 <field name="draw_number"/>
            </xpath>
        </field>
    </record>
</odoo>

 

 

三、qweb实现打印单

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <template id="bill_of_sales_order_report_document1">
        <t t-call="web.external_layout">
            <div class="page" style="margin-top:0px">
                <style type="text/css">
                    .tg {border-collapse:collapse;border-spacing:0;}
                    .tg td{border-color:black;border-style:solid;border-width:1px;font-family:Arial,
                    sans-serif;font-size:10px;
                    overflow:hidden;padding:10px 5px;word-break:normal;}
                    .tg th{border-color:black;border-style:solid;border-width:1px;font-family:Arial,
                    sans-serif;font-size:10px;
                    font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;}
                    .tg .tg-cly1{text-align:left;vertical-align:middle}
                    .tg .tg-lqfj{font-size:10px;text-align:center;vertical-align:middle}
                    .tg .tg-blwt{background-color:#D0CECE;border-color:inherit;text-align:center;vertical-align:middle}
                    .tg .tg-d9wi{background-color:#D0CECE;font-size:10px;text-align:center;vertical-align:middle}
                    .tg .tg-24qy{background-color:#D0CECE;text-align:center;vertical-align:middle}
                    .tg .tg-nrix{text-align:center;vertical-align:middle}
                </style>
                <table class="tg" style="undefined;table-layout: fixed; width: 100%">
                    <thead style="border-style:none;font-family:Arial;font-size:15px">
                        <tr style="border-style:none;">
                            <th height="10" colspan="8" style="border-style:none;">
                                <div class="text-center" style="border-style:none;">
                                    <h4 class="text_center">
                                        安徽联科技有限公司
                                    </h4>
                                </div>
                                <tr style="border-style:none;">
                                    <td style="border-style:none;font-family:Arial;font-size:12px" colspan="4">客户名称:
                                        <span t-field="doc_id.partner_id.name"/>

                                    </td>
                                    <td style="border-style:none;font-family:Arial;font-size:12px" colspan="4">制单日期:
                                         <span t-field="doc_id.date_order" t-options='{"widget": "date"}'/>
                                    </td>
                                </tr>
                                <tr style="border-style:none;">
                                    <td style="border-style:none;font-family:Arial;font-size:12px" colspan="4">客户地址:
                                        <span t-field="doc_id.partner_id.street"/>
                                    </td>
                                </tr>
                            </th>
                        </tr>
                        <tr>
                            <th class="tg-blwt">订单号码</th>
                            <th class="tg-24qy">货物编号</th>
                            <th class="tg-24qy">型号/规格</th>
                            <th class="tg-24qy">单位</th>
                            <th class="tg-24qy">数量</th>
                            <th class="tg-24qy">单价</th>
                            <th class="tg-24qy">备注</th>
                            <th class="tg-d9wi">入库单号</th>
                        </tr>
                    </thead>
                    <tbody>
                        <t t-set="items" t-value="[0,1,2]"/>
                        <t t-set="i" t-value="0"/>
                        <t t-set="k" t-value="0"/>
                        <t t-set="q" t-value="0"/>
                        <tr t-foreach="doc_id.order_line" t-as="l" class="gxtr">
                            <td class="tg-nrix">
                                <span t-field="doc_id.name"/>
                            </td>
                            <td class="tg-nrix">
                               <span t-field="l.product_id.name"/>
                            </td>
                            <td class="tg-nrix">
                                <span t-field="l.product_id.name"/>
                            </td>
                            <td class="tg-nrix">
                                <span t-field="l.product_uom.name"/>
                            </td>
                            <td class="tg-nrix">
                                <span t-field="l.product_uom_qty"/>
                            </td>
                            <td class="tg-nrix">
                                <span t-field="l.price_unit"/>
                            </td>
                            <td class="tg-nrix">
                                <span t-field="l.name"/>
                            </td>
                            <td class="tg-lqfj">
                                <span t-value="l.product_uom_qty"/>
                            </td>
                            <t t-set="q" t-value="q+l.product_uom_qty"/>
                            <t t-set="i" t-value="i+1"/>
                        </tr>
                        <tr t-foreach="items" t-as="j" class="gxtr">
                            <t t-if="j>=(i%8)">
                                <td class="tg-nrix"></td>
                                <td class="tg-nrix"></td>
                                <td class="tg-nrix"></td>
                                <td class="tg-nrix"></td>
                                <td class="tg-nrix"></td>
                                <td class="tg-nrix"></td>
                                <td class="tg-nrix"></td>
                                <td class="tg-lqfj"></td>
                            </t>
                            <t t-set="k" t-value="k+1"/>
                        </tr>
                        <tr>
                            <td class="tg-nrix" colspan="4"></td>
                            <td class="tg-nrix" style="border-right:none">
                                <t t-esc="q"/>
                            </td>
                            <td style="border-left:none" colspan="3">
                            </td>
                        </tr>
                    </tbody>
                    <tfoot style="border-style:none;">
                        <tr style="border-style:none;">
                            <td style="border-style:none;font-family:Arial;font-size:12px" colspan="4">制单:
                                <span t-field="doc_id.create_uid.name"/>
                            </td>
                        </tr>
                    </tfoot>
                </table>
            </div>
        </t>
    </template>

    <template id="bill_of_sales_order_report">
        <t t-call="web.html_container">
            <t t-foreach="docs" t-as="doc_id">
                <t t-call="bill_of_sales_order_report_document1" t-lang="doc_id.partner_id.lang"/>
            </t>
        </t>
    </template>
</odoo>

 

四、全局修改样式面包屑

.breadcrumb-item + .breadcrumb-item::before {
  float: left;
  padding-right: 0.5rem;
  color: red !important;
  content: var(--bs-breadcrumb-divider, ">>>") !important;}

 

标签:常用,里面,name,odoo16,align,limit,tg,products,border
From: https://www.cnblogs.com/1314520xh/p/17408838.html

相关文章

  • Nginx 常用的基础配置(web前端相关方面)
    基础配置userroot;worker_processes1;events{worker_connections10240;}http{log_format'$remote_addr-$remote_user[$time_local]''"$request"$st......
  • Set接口和常用方法+HashSet分析
    1. Set接口基本介绍  5171)无序(添加和取出的顺序不一致),没有索引[后面演示]2)不允许重复元素,所以最多包含一个null3) JDK API中Set接口的实现类有:2. Set 接口的常用方法和 List 接口一样, Set 接口也是 Collection 的子接口,因此,常用方法和 Collection 接口一样. ......
  • Map接口和常用方法
    1. Map 接口实现类的特点 [很实用]  530注意:这里讲的是JDK8的Map接口特点Map java1) Map与Collection并列存在。 用于保存具有映射关系的数据:Key-Value2) Map中的key和value可以是任何引用类型的数据,会封装到HashMap$Node对象中3) Map中的key不允许重复,原因和HashSet一......
  • ★常用设计模式
    创建型模式简单工厂选择不一样的参数,生成不一样的产品可用switch()来做参数选择publicclassFoodFactory{publicstaticFoodmakeFood(Stringname){if(name.equals("noodle")){Foodnoodle=newLanZhouNoodle();noodle.addSpicy("more");returnnoodle;}elseif......
  • dpkg命令用法、Ubuntu下deb包的解压、打包、安装、卸载及常用命令参数
    dpkg命令的用法不带图简装:https://blog.csdn.net/wanghuohuo13/article/details/78916821?ops_request_misc=&request_id=&biz_id=102&utm_term=dpkg&utm_medium=distribute.pc_search_result.none-task-blog-2allsobaiduweb~default-6-.first_rank_v2_pc_rank_v29&am......
  • SpringBoot中使用Thymeleaf常用功能(一):表达式访问数据
    环境搭建:  创建一个Maven项目,按照Maven项目的规范,在src/main/下新建一个名为resources的文件夹,并在下面新建static和templates文件夹。 ① 修改pom.xml:<projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi......
  • git常用命令
    github指令Git是一个开源的分布式版本控制系统创建本地空仓库gitinit克隆现有存储库,使用clone克隆存储库gitclone可以直接在本地创建相同的仓库。gitclone将文件添加到缓存区gitadd使用gitadd命令可以将文件添加到本地仓库的提交缓存,但这个时候还不算添加到了本地仓库,我......
  • SQL常用的基础语法
    声明        本公众号所有内容,均属微信公众号:开源优测 所有,任何媒体、网站或个人未经授权不得转载、链接、转贴或以其他方式复制发布/发表。已经本公众号协议授权的媒体、网站,在使用时必须注明"稿件来源微信公众号:开源优测",违者本公众号将依法追究责任。SQL常用的语法......
  • Xcode常用环境变量与常见使用场景
    在Xcode的工程配置中,与路径相关的都是使用环境变量,这样可以避免使用决定路径时项目移植性差的问题。Xcode常用宏__FILE__当前文件所在目录__DATE__编译日期的字符串,格式为“mmddyyyy”(例如:“Sep162015”)__FUNCTION__当前函数名称__LINE__当前语句在源......
  • 常用指令—python,cmd,pytorch等
    1.查看当前使用的python解释器查看电脑里有多少个pythonwherepython查看当前使用的python解释器在哪个路径下在cmd中,切换到pythonimportsyssys.executable2.conda查看虚拟环境列表condaenvlist激活具体虚拟环境condaactivate环境名3.pytorchimport......