一、全局搜索与显示
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