Merge branch 'develop' into feature/commercially_launched

This commit is contained in:
胡尧
2025-03-14 13:52:18 +08:00
7 changed files with 79 additions and 48 deletions

View File

@@ -115,9 +115,20 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', {
this.setRequired()
this.listherHeaderBodyNum()
})
owl.onPatched(() => {
owl.onPatched(() => {
this.listherHeaderBodyNum()
})
const treeModifiers = this.getFieldModifiers(this.props.archInfo.__rawArch);
// console.log('treeModifiers', treeModifiers);
if(treeModifiers) {
this.props.merge_key = treeModifiers.merge_key;
this.props.merge_fields = treeModifiers.merge_fields.split(',');
const data = this.setColumns(this.props.merge_key);
console.log('data', data);
owl.onMounted(() => {
this.mergeColumns(this.props.merge_fields, data)
})
}
return this._super(...arguments);
},
setRequired() {
@@ -163,7 +174,58 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', {
} catch (e) {
console.log(e)
}
},
setColumns( merge_key) {
const data = this.props.list.records
let sourceIndex = 0;
let sourceValue = ''
data.forEach((item, index) => {
if(!item.colspan) {
item.colspan = 1;
}
if(item.data[merge_key] === sourceValue) {
data[sourceIndex].colspan ++ ;
item.colspan = 0;
} else {
sourceIndex = index;
sourceValue = item.data[merge_key];
}
})
return data
},
getFieldModifiers(xmlString) {
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xmlString, "text/xml");
// 提取 <tree> 的 modifiers
const treeElement = xmlDoc.querySelector("tree");
const treeModifiers = treeElement.getAttribute("modifiers");
if (treeModifiers) {
const parsedTreeModifiers = JSON.parse(treeModifiers);
console.log("Tree Modifiers:", parsedTreeModifiers);
return parsedTreeModifiers;
}
return null;
},
mergeColumns(merge_fields, data) {
const dom = this.tableRef.el
const thead = $(dom).children('thead')
const tbody = $(dom).children('tbody')
tbody.children('tr.o_data_row').each(function () {
const tr = $(this)
const td = tr.children('td')
const index = $(this).index()
td.each(function () {
if(merge_fields.indexOf($(this).attr('name')) >= 0) {
$(this).attr('rowspan', data[index].colspan)
if(data[index].colspan == 0) {
$(this).remove()
}
}
})
})
}
})
patch(FormLabel.prototype, 'jikimo_frontend.FormLabel', {
get className() {
@@ -176,7 +238,6 @@ patch(FormLabel.prototype, 'jikimo_frontend.FormLabel', {
);
const classes = this.props.className ? [this.props.className] : [];
const otherRequired = filedRequiredList[this.props.fieldName]
if(this.props.fieldInfo?.rawAttrs?.class?.indexOf('custom_required') >= 0 || otherRequired) {
classes.push('custom_required_add')
}
@@ -193,35 +254,6 @@ patch(FormLabel.prototype, 'jikimo_frontend.FormLabel', {
}
})
// 根据进度条设置水印
// const statusbar_params = {
// '已完工': 'bg-primary',
// '完成': 'bg-primary',
// '采购订单': 'bg-primary',
// '作废': 'bg-danger',
// '封存(报废)': 'bg-danger',
// }
// patch(StatusBarField.prototype, 'jikimo_frontend.StatusBarField', {
// setup() {
// owl.onMounted(this.ribbons);
// return this._super(...arguments);
// },
// ribbons() {
// try {
// const dom = $('.o_form_sheet.position-relative')
// const status = statusbar_params[this.currentName]
// if(status && dom.length) {
// dom.prepend(`<div class="o_widget o_widget_web_ribbon">
// <div class="ribbon ribbon-top-right">
// <span class="bg-opacity-75 ${status}" title="">${this.currentName}</span>
// </div>
// </div>`)
// }
// } catch (e) {
// console.log(e)
// }
// }
// })
$(function () {

View File

@@ -190,7 +190,6 @@ class QualityCheck(models.Model):
# doubly linked chain for tablet view navigation
next_check_id = fields.Many2one('quality.check')
previous_check_id = fields.Many2one('quality.check')
# is_produced = fields.Boolean(string="Has Been Produced")
# For components registration
move_id = fields.Many2one(

View File

@@ -108,15 +108,11 @@ class StockPicking(models.Model):
def action_open_quality_check_picking(self):
action = self.env["ir.actions.actions"]._for_xml_id("quality_control.quality_check_action_picking")
action['context'] = self.env.context.copy()
keys_to_remove = [key for key in action['context'] if key.startswith('default_')]
for key in keys_to_remove:
del action['context'][key]
action['context'].update({
action['context'] = {
'search_default_picking_id': [self.id],
'default_picking_id': self.id,
'show_lots_text': self.show_lots_text,
})
}
return action
def button_quality_alert(self):

View File

@@ -117,6 +117,8 @@ class PurchaseOrderLine(models.Model):
@api.depends('product_id')
def _compute_related_product(self):
for record in self:
if record.part_number or record.part_name:
continue
if record.product_id.categ_id.name == '坯料':
product_name = ''
match = re.search(r'(S\d{5}-\d)', record.product_id.name)

View File

@@ -12,18 +12,18 @@
<div class="alert alert-warning" role="alert">
<field name="display_message" readonly="1" nolabel="1"/>
</div>
<field name="related_docs">
<tree string="下游单据" create="false" edit="false" delete="false">
<field name="related_docs" >
<tree string="下游单据" create="false" edit="false" delete="false" attrs="{'merge_fields': 'category,doc_name,operation_type,doc_number,doc_state, cancel_reason', 'merge_key': 'doc_number'}">
<!-- <field name="sequence" string="序号"/> -->
<field name="category" string="大类"/>
<field name="doc_name" string="单据名称"/>
<field name="operation_type" string="作业类型"/>
<field name="doc_number" string="单据编号"/>
<field name="doc_state" string="单据状态"/>
<field name="cancel_reason" string="禁止取消原因"/>
<field name="line_number" string="行号"/>
<field name="product_name" string="产品名称"/>
<field name="quantity_str" string="数量"/>
<field name="doc_state" string="单据状态"/>
<field name="cancel_reason" string="禁止取消原因"/>
</tree>
</field>
<footer>

View File

@@ -18,13 +18,13 @@ class StockPicking(models.Model):
fail_check_text = ''
for product_id in product_list:
check_ids = quality_check_ids.filtered(lambda qc: qc.product_id == product_id)
number = sum(check_ids.mapped('qty_line'))
if number != 0:
fail_check_text = (f'{fail_check_text}{product_id.name} {number}'
if fail_check_text != '' else f'{product_id.name} {number}')
if all(check_id.measure_on == 'move_line' for check_id in check_ids):
number = sum(check_ids.mapped('qty_line'))
else:
fail_check_text = (f'{fail_check_text}{product_id.name}'
if fail_check_text != '' else f'{product_id.name}')
number = sum(self.move_ids_without_package.filtered(
lambda ml: ml.product_id == product_id).mapped('quantity_done'))
fail_check_text = (f'{fail_check_text}{product_id.name} {number}'
if fail_check_text != '' else f'{product_id.name} {number}')
return {
'type': 'ir.actions.act_window',
'res_model': 'picking.validate.check.wizard',

View File

@@ -382,6 +382,8 @@ class RePurchaseOrder(models.Model):
'product_qty': 1,
'product_uom': server_template.uom_id.id,
'related_product': production.product_id.id,
'part_number': pp.part_number,
'part_name': pp.part_name,
}))
# 获取服务商品最后一个供应商的采购员
purchase_user_id = server_template.seller_ids[-1].partner_id.purchase_user_id