Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/工单文件优化

# Conflicts:
#	sf_manufacturing/models/mrp_workorder.py
This commit is contained in:
jinling.yang
2023-01-10 09:27:14 +08:00
46 changed files with 1877 additions and 150 deletions

View File

@@ -77,6 +77,7 @@ class MachineTool(models.Model):
b_axis = fields.Integer('B轴') b_axis = fields.Integer('B轴')
c_axis = fields.Integer('C轴') c_axis = fields.Integer('C轴')
remark = fields.Text('备注') remark = fields.Text('备注')
is_binding = fields.Boolean('是否绑定机床', default=False)
precision = fields.Float('加工精度') precision = fields.Float('加工精度')
control_system_id = fields.Many2one('sf.machine.control_system', control_system_id = fields.Many2one('sf.machine.control_system',
string="控制系统") string="控制系统")

View File

@@ -359,7 +359,7 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="机床"> <form string="机床">
<header> <header>
<button type="object" class="oe_highlight" name='enroll_machine_tool' string="机床注册"/> <button type="object" class="oe_highlight" name='enroll_machine_tool' string="机床注册" attrs="{'invisible': [('code','!=',False)]}"/>
</header> </header>
<group string="基本信息"> <group string="基本信息">
<group> <group>

View File

@@ -8,7 +8,7 @@ from odoo.http import request
class Sf_Bf_Connect(http.Controller): class Sf_Bf_Connect(http.Controller):
@http.route('/api/bfm_process_order/list', type='json', auth='none', methods=['GET', 'POST'], csrf=False, @http.route('/api/bfm_process_order/list', type='http', auth='none', methods=['GET', 'POST'], csrf=False,
cors="*") cors="*")
def get_bfm_process_order_list(self, **kw): def get_bfm_process_order_list(self, **kw):
""" """
@@ -19,9 +19,9 @@ class Sf_Bf_Connect(http.Controller):
res = {'status': 1, 'factory_order_no': ''} res = {'status': 1, 'factory_order_no': ''}
logging.info('get_bfm_process_order_list:%s' % kw) logging.info('get_bfm_process_order_list:%s' % kw)
try: try:
datas = request.httprequest.data # datas = request.httprequest.data
ret = json.loads(datas) # ret = json.loads(datas)
ret = json.loads(ret['result']) # ret = json.loads(ret['result'])
product_id = request.env.ref('sf_dlm.product_template_sf').sudo() product_id = request.env.ref('sf_dlm.product_template_sf').sudo()
logging.info('product_id:%s' % product_id) logging.info('product_id:%s' % product_id)
self_machining_id = request.env.ref('sf_dlm.product_embryo_sf_self_machining').sudo() self_machining_id = request.env.ref('sf_dlm.product_embryo_sf_self_machining').sudo()
@@ -30,13 +30,20 @@ class Sf_Bf_Connect(http.Controller):
company_id = request.env.ref('base.main_company').sudo() company_id = request.env.ref('base.main_company').sudo()
user_id = request.env.ref('base.user_admin').sudo() user_id = request.env.ref('base.user_admin').sudo()
logging.info('user_id:%s' % user_id) logging.info('user_id:%s' % user_id)
bfm_process_order_list = json.loads(kw['bfm_process_order_list'])
order_id = request.env['sale.order'].with_user(request.env.ref("base.user_admin")).sale_order_create( order_id = request.env['sale.order'].with_user(request.env.ref("base.user_admin")).sale_order_create(
company_id, ret['delivery_name'], ret['delivery_telephone'], ret['delivery_address'], company_id, kw['delivery_name'], kw['delivery_telephone'], kw['delivery_address'],
ret['delivery_end_date'], user_id) kw['delivery_end_date'], user_id)
i = 1 i = 1
for item in ret['bfm_process_order_list']: for item in bfm_process_order_list:
# product_has = request.env['product.template'].with_user(request.env.ref("base.user_admin")).search([('barcode','=', item['barcode'])])
# if product_has:
# logging.info('product_has:%s' % product_has)
# logging.info('barcode:%s' % item['barcode'])
# order_id.with_user(request.env.ref("base.user_admin")).sale_order_create_line(product_has, item)
# else:
product = request.env['product.template'].sudo().product_create(product_id, item, order_id, product = request.env['product.template'].sudo().product_create(product_id, item, order_id,
ret['order_number'], i) kw['order_number'], i)
# order_id.with_user(request.env.ref("base.user_admin")).sale_order_create_line(product, item) # order_id.with_user(request.env.ref("base.user_admin")).sale_order_create_line(product, item)
logging.info('order_id:%s' % order_id) logging.info('order_id:%s' % order_id)
logging.info('product:%s' % product) logging.info('product:%s' % product)
@@ -53,11 +60,11 @@ class Sf_Bf_Connect(http.Controller):
self_machining_embryo = request.env['product.template'].sudo().no_bom_product_create( self_machining_embryo = request.env['product.template'].sudo().no_bom_product_create(
self_machining_id, self_machining_id,
item, item,
order_id, 'self_machining') order_id, 'self_machining', i)
# 创建胚料的bom # 创建胚料的bom
self_machining_bom = request.env['mrp.bom'].with_user( self_machining_bom = request.env['mrp.bom'].with_user(
request.env.ref("base.user_admin")).bom_create( request.env.ref("base.user_admin")).bom_create(
self_machining_embryo, 'normal') self_machining_embryo, 'normal', False)
# 创建胚料里bom的组件 # 创建胚料里bom的组件
self_machining_bom.with_user(request.env.ref("base.user_admin")).bom_create_line( self_machining_bom.with_user(request.env.ref("base.user_admin")).bom_create_line(
self_machining_embryo) self_machining_embryo)
@@ -72,7 +79,8 @@ class Sf_Bf_Connect(http.Controller):
outsource_embryo = request.env['product.template'].sudo().no_bom_product_create(outsource_id, outsource_embryo = request.env['product.template'].sudo().no_bom_product_create(outsource_id,
item, item,
order_id, order_id,
'subcontract') 'subcontract',
i)
# 创建胚料的bom # 创建胚料的bom
outsource_bom = request.env['mrp.bom'].with_user(request.env.ref("base.user_admin")).bom_create( outsource_bom = request.env['mrp.bom'].with_user(request.env.ref("base.user_admin")).bom_create(
outsource_embryo, outsource_embryo,
@@ -88,16 +96,15 @@ class Sf_Bf_Connect(http.Controller):
purchase_embryo = request.env['product.template'].sudo().no_bom_product_create(purchase_id, purchase_embryo = request.env['product.template'].sudo().no_bom_product_create(purchase_id,
item, item,
order_id, order_id,
'purchase') 'purchase', i)
# 产品配置bom # 产品配置bom
product_bom_purchase = request.env['mrp.bom'].with_user( product_bom_purchase = request.env['mrp.bom'].with_user(
request.env.ref("base.user_admin")).bom_create(product, 'normal', False) request.env.ref("base.user_admin")).bom_create(product, 'normal', False)
product_bom_purchase.with_user(request.env.ref("base.user_admin")).bom_create_line_has( product_bom_purchase.with_user(request.env.ref("base.user_admin")).bom_create_line_has(
purchase_embryo) purchase_embryo)
i += 1
order_id.with_user(request.env.ref("base.user_admin")).sale_order_create_line(product, item) order_id.with_user(request.env.ref("base.user_admin")).sale_order_create_line(product, item)
i += 1
res['factory_order_no'] = order_id.name res['factory_order_no'] = order_id.name
return json.JSONEncoder().encode(res)
except Exception as e: except Exception as e:
logging.info('get_bfm_process_order_list error:%s' % e) logging.info('get_bfm_process_order_list error:%s' % e)
res['status'] = -1 res['status'] = -1

View File

@@ -0,0 +1,110 @@
from odoo import api, fields, models, SUPERUSER_ID, _
from odoo.exceptions import ValidationError
from datetime import datetime
import logging
from odoo.exceptions import UserError
import requests
_logger = logging.getLogger(__name__)
class StatusChange(models.Model):
_inherit = 'sale.order'
default_code = fields.Char(string='内部编码')
def action_confirm(self):
logging.info('函数已经执行=============')
if self._get_forbidden_state_confirm() & set(self.mapped('state')):
raise UserError(_(
"It is not allowed to confirm an order in the following states: %s",
", ".join(self._get_forbidden_state_confirm()),
))
logging.info('函数已经执行=============1')
for order in self:
if order.partner_id in order.message_partner_ids:
logging.info('函数已经执行=============2')
continue
order.message_subscribe([order.partner_id.id])
logging.info('函数已经执行=============3')
self.write(self._prepare_confirmation_values())
# Context key 'default_name' is sometimes propagated up to here.
# We don't need it and it creates issues in the creation of linked records.
context = self._context.copy()
context.pop('default_name', None)
logging.info('函数已经执行=============4')
self.with_context(context)._action_confirm()
if self.env.user.has_group('sale.group_auto_done_setting'):
logging.info('函数已经执行=============5')
self.action_done()
process_start_time = str(datetime.now())
json1 = {
'params': {
'model_name': 'jikimo.process.order',
'field_name': 'name',
# 'default_code': 'PO-2022-1214-0022',
'default_code': self.default_code,
# 'default_code': self.name,
'state': '加工中',
'process_start_time': process_start_time,
},
}
url1 = 'https://bfm.cs.jikimo.com/api/get/state/get_order'
requests.post(url1, json=json1, data=None)
logging.info('接口已经执行=============')
return True
def action_cancel(self):
""" Cancel SO after showing the cancel wizard when needed. (cfr `_show_cancel_wizard`)
For post-cancel operations, please only override `_action_cancel`.
note: self.ensure_one() if the wizard is shown.
"""
logging.info('函数已经执行=============')
cancel_warning = self._show_cancel_wizard()
logging.info('函数已经执行=============2')
json1 = {
'params': {
'model_name': 'jikimo.process.order',
'field_name': 'name',
'default_code': self.default_code,
# 'default_code': self.name,
'state': '待派单',
},
}
url1 = 'https://bfm.cs.jikimo.com/api/get/state/cancel_order'
requests.post(url1, json=json1, data=None)
if cancel_warning:
logging.info('函数已经执行=============3')
self.ensure_one()
logging.info('函数已经执行=============4')
template_id = self.env['ir.model.data']._xmlid_to_res_id(
'sale.mail_template_sale_cancellation', raise_if_not_found=False
)
lang = self.env.context.get('lang')
template = self.env['mail.template'].browse(template_id)
if template.lang:
lang = template._render_lang(self.ids)[self.id]
ctx = {
'default_use_template': bool(template_id),
'default_template_id': template_id,
'default_order_id': self.id,
'mark_so_as_canceled': True,
'default_email_layout_xmlid': "mail.mail_notification_layout_with_responsible_signature",
'model_description': self.with_context(lang=lang).type_name,
}
return {
'name': _('Cancel %s', self.type_name),
'view_mode': 'form',
'res_model': 'sale.order.cancel',
'view_id': self.env.ref('sale.sale_order_cancel_view_form').id,
'type': 'ir.actions.act_window',
'context': ctx,
'target': 'new'
}
else:
return self._action_cancel()

View File

@@ -10,7 +10,7 @@
""", """,
'category': 'sf', 'category': 'sf',
'website': 'https://www.sf.jikimo.com', 'website': 'https://www.sf.jikimo.com',
'depends': ['mrp', 'base', 'sf_manufacturing', 'purchase', 'mrp_subcontracting'], 'depends': ['mrp', 'base', 'sf_manufacturing'],
'data': [ 'data': [
'data/product_data.xml', 'data/product_data.xml',
'views/product_template_view.xml' 'views/product_template_view.xml'

View File

@@ -15,7 +15,7 @@
<field name="type">原材料</field> <field name="type">原材料</field>
</record> </record>
<record id="product_template_sf" model="product.template"> <record id="product_template_sf" model="product.product">
<field name="name">CNC加工产品模板</field> <field name="name">CNC加工产品模板</field>
<field name="active" eval="False"/> <field name="active" eval="False"/>
<field name="categ_id" ref="product_category_finished_sf"/> <field name="categ_id" ref="product_category_finished_sf"/>
@@ -31,7 +31,7 @@
<field name="tracking">serial</field> <field name="tracking">serial</field>
</record> </record>
<record id="product_embryo_sf_self_machining" model="product.template"> <record id="product_embryo_sf_self_machining" model="product.product">
<field name="name">胚料自加工模板</field> <field name="name">胚料自加工模板</field>
<field name="active" eval="False"/> <field name="active" eval="False"/>
<field name="categ_id" ref="product_category_embryo_sf"/> <field name="categ_id" ref="product_category_embryo_sf"/>
@@ -48,7 +48,7 @@
<!-- <field name="active" eval="False"/>--> <!-- <field name="active" eval="False"/>-->
</record> </record>
<record id="product_embryo_sf_outsource" model="product.template"> <record id="product_embryo_sf_outsource" model="product.product">
<field name="name">胚料外协加工模板</field> <field name="name">胚料外协加工模板</field>
<field name="active" eval="False"/> <field name="active" eval="False"/>
<field name="categ_id" ref="product_category_embryo_sf"/> <field name="categ_id" ref="product_category_embryo_sf"/>
@@ -63,7 +63,7 @@
<field name="tracking">serial</field> <field name="tracking">serial</field>
<!-- <field name="active" eval="False"/>--> <!-- <field name="active" eval="False"/>-->
</record> </record>
<record id="product_embryo_sf_purchase" model="product.template"> <record id="product_embryo_sf_purchase" model="product.product">
<field name="name">胚料采购模板</field> <field name="name">胚料采购模板</field>
<field name="active" eval="False"/> <field name="active" eval="False"/>
<field name="categ_id" ref="product_category_embryo_sf"/> <field name="categ_id" ref="product_category_embryo_sf"/>

11
sf_dlm/data/uom_data.xml Normal file
View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="1">
<!-- UOM.UOM -->
<!-- VOLUME -->
<record id="product_uom_cubic_millimeter" model="uom.uom">
<field name="name">立方毫米</field>
<field name="category_id" ref="uom.product_uom_categ_vol"/>
<field name="factor_inv">1000</field>
<field name="uom_type">bigger</field>
</record>
</odoo>

View File

@@ -1,12 +1,17 @@
from odoo import models, fields, api from odoo import models, fields, api
from odoo.exceptions import ValidationError from odoo.exceptions import ValidationError
import logging import logging
import base64
import os
# from OCC.Extend.DataExchange import read_step_file, write_stl_file
from odoo.modules import get_resource_path
class ResProductTemplate(models.Model): class ResProductTemplate(models.Model):
_inherit = 'product.template' _inherit = 'product.template'
# 模型的长,宽,高,体积,精度,材料 # 模型的长,宽,高,体积,精度,材料
model_name = fields.Char('模型名称')
model_long = fields.Float('模型长[mm]', digits=(16, 3)) model_long = fields.Float('模型长[mm]', digits=(16, 3))
model_width = fields.Float('模型宽[mm]', digits=(16, 3)) model_width = fields.Float('模型宽[mm]', digits=(16, 3))
model_height = fields.Float('模型高[mm]', digits=(16, 3)) model_height = fields.Float('模型高[mm]', digits=(16, 3))
@@ -29,6 +34,17 @@ class ResProductTemplate(models.Model):
materials_id = fields.Many2one('sf.production.materials', string='材料') materials_id = fields.Many2one('sf.production.materials', string='材料')
materials_type_id = fields.Many2one('sf.materials.model', string='材料型号') materials_type_id = fields.Many2one('sf.materials.model', string='材料型号')
single_manufacturing = fields.Boolean(string="单个制造") single_manufacturing = fields.Boolean(string="单个制造")
upload_model_file = fields.Many2many('ir.attachment', 'upload_model_file_attachment_ref', string='上传模型文件')
model_code = fields.Char('模型编码')
def _get_volume_uom_id_from_ir_config_parameter(self):
product_length_in_feet_param = self.env['ir.config_parameter'].sudo().get_param('product.volume_in_cubic_feet')
if product_length_in_feet_param == '1':
return self.env.ref('uom.product_uom_cubic_foot')
else:
return self.env.ref('sf_dlm.product_uom_cubic_millimeter')
# model_file = fields.Binary('模型文件')
# 胚料的库存路线设置 # 胚料的库存路线设置
# def _get_routes(self, route_type): # def _get_routes(self, route_type):
@@ -53,59 +69,82 @@ class ResProductTemplate(models.Model):
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品 # 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品
def product_create(self, product_id, item, order_id, order_number, i): def product_create(self, product_id, item, order_id, order_number, i):
copy_product_id = product_id.with_user(self.env.ref("base.user_admin")).copy() copy_product_id = product_id.with_user(self.env.ref("base.user_admin")).copy()
# copy_product_id.product_tmpl_id.active = True copy_product_id.product_tmpl_id.active = True
model_type = self.env['sf.model.type'].search([], limit=1)
attachment = self.attachment_create(item['model_name'], item['model_data'])
vals = { vals = {
'name': '%s-%s' % (order_id.name, i), 'name': '%s-%s' % (order_id.name, i),
'model_long': item['model_long'], 'model_long': item['model_long'] + model_type.embryo_tolerance,
'model_width': item['model_width'], 'model_width': item['model_width'] + model_type.embryo_tolerance,
'model_height': item['model_height'], 'model_height': item['model_height'] + model_type.embryo_tolerance,
'model_volume': (item['model_long'] + model_type.embryo_tolerance) * (
item['model_width'] + model_type.embryo_tolerance) * (
item['model_height'] + model_type.embryo_tolerance),
'model_type_id': 1, 'model_type_id': 1,
'model_machining_precision': item['model_machining_precision'], # 'model_machining_precision': item['model_machining_precision'],
'model_processing_panel': 'R,U', 'model_processing_panel': 'R',
'model_machining_precision': '±0.10mm',
'model_code': item['barcode'],
'length': item['model_long'], 'length': item['model_long'],
'width': item['model_width'], 'width': item['model_width'],
'height': item['model_height'], 'height': item['model_height'],
'volume': (item['model_long'] * item['model_width'] * item['model_height']), 'volume': item['model_long'] * item['model_width'] * item['model_height'],
# 'model_price': item['price'], 'model_file': '' if not item['model_file'] else base64.b64decode(item['model_file']),
'model_name': attachment.name,
'upload_model_file': [(6, 0, [attachment.id])],
# 'single_manufacturing': True, # 'single_manufacturing': True,
'tracking': 'serial',
'list_price': item['price'], 'list_price': item['price'],
# 'categ_id': self.env.ref('sf_dlm.product_category_finished_sf').id, # 'categ_id': self.env.ref('sf_dlm.product_category_finished_sf').id,
'materials_id': self.env['sf.production.materials'].search( 'materials_id': self.env['sf.production.materials'].search(
[('materials_no', '=', item['texture_code'])]).id, [('materials_no', '=', item['texture_code'])]).id,
'materials_type_id': self.env['sf.materials.model'].search( 'materials_type_id': self.env['sf.materials.model'].search(
[('materials_no', '=', item['texture_type_code'])]).id, [('materials_no', '=', item['texture_type_code'])]).id,
# 'model_surface_process_id': self.env['sf.production.process'].search( 'model_surface_process_id': self.env['sf.production.process'].search(
# [('process_encode', '=', item['surface_process_code'])]).id, [('process_encode', '=', item['surface_process_code'])]).id,
# 'model_process_parameters_id': self.env['sf.processing.technology'].search( # 'model_process_parameters_id': self.env['sf.processing.technology'].search(
# [('process_encode', '=', item['process_parameters_code'])]).id, # [('process_encode', '=', item['process_parameters_code'])]).id,
'model_remark': item['remark'], 'model_remark': item['remark'],
'default_code': '%s-%s' % (order_number, i), 'default_code': '%s-%s' % (order_number, i),
'barcode': item['barcode'], # 'barcode': item['barcode'],
'active': True, 'active': True,
# 'route_ids': self._get_routes('') # 'route_ids': self._get_routes('')
} }
copy_product_id.sudo().write(vals) copy_product_id.sudo().write(vals)
# product_id.active = False # product_id.product_tmpl_id.active = False
return copy_product_id return copy_product_id
def attachment_create(self, name, data):
attachment = self.env['ir.attachment'].create({
'datas': base64.b64decode(data),
'type': 'binary',
'description': '模型文件',
'name': name
})
return attachment
# 创建胚料 # 创建胚料
def no_bom_product_create(self, product_id, item, order_id, route_type): def no_bom_product_create(self, product_id, item, order_id, route_type, i):
no_bom_copy_product_id = product_id.with_user(self.env.ref("base.user_admin")).copy() no_bom_copy_product_id = product_id.with_user(self.env.ref("base.user_admin")).copy()
# no_bom_copy_product_id.product_tmpl_id.active = True no_bom_copy_product_id.product_tmpl_id.active = True
materials_id = self.env['sf.production.materials'].search( materials_id = self.env['sf.production.materials'].search(
[('materials_no', '=', item['texture_code'])]) [('materials_no', '=', item['texture_code'])])
materials_type_id = self.env['sf.materials.model'].search( materials_type_id = self.env['sf.materials.model'].search(
[('materials_no', '=', item['texture_type_code'])]) [('materials_no', '=', item['texture_type_code'])])
model_type = self.env['sf.model.type'].search([], limit=1)
supplier = self.env['mrp.bom'].get_supplier(materials_type_id) supplier = self.env['mrp.bom'].get_supplier(materials_type_id)
logging.info('no_bom_copy_product_supplier-vals:%s' % supplier) logging.info('no_bom_copy_product_supplier-vals:%s' % supplier)
vals = { vals = {
'name': '%s %s %s %s * %s * %s' % ( 'name': '%s-%s %s %s %s * %s * %s' % (
order_id.name, materials_id.name, materials_type_id.name, item['model_long'], item['model_width'], order_id.name, i, materials_id.name, materials_type_id.name,
item['model_height']), item['model_long'] + model_type.embryo_tolerance, item['model_width'] + model_type.embryo_tolerance,
'length': item['model_long'], item['model_height'] + model_type.embryo_tolerance),
'width': item['model_width'], 'length': item['model_long'] + model_type.embryo_tolerance,
'height': item['model_height'], 'width': item['model_width'] + model_type.embryo_tolerance,
'volume': item['model_long'] * item['model_width'] * item['model_height'], 'height': item['model_height'] + model_type.embryo_tolerance,
'volume': (item['model_long'] + model_type.embryo_tolerance) * (
item['model_width'] + model_type.embryo_tolerance) * (
item['model_height'] + model_type.embryo_tolerance),
# 'model_price': item['price'], # 'model_price': item['price'],
'list_price': item['price'], 'list_price': item['price'],
'materials_id': materials_id.id, 'materials_id': materials_id.id,
@@ -131,22 +170,32 @@ class ResProductTemplate(models.Model):
logging.info('no_bom_copy_product_id-seller_ids-vals:%s' % no_bom_copy_product_id.seller_ids) logging.info('no_bom_copy_product_id-seller_ids-vals:%s' % no_bom_copy_product_id.seller_ids)
no_bom_copy_product_id.write(vals) no_bom_copy_product_id.write(vals)
logging.info('no_bom_copy_product_id-vals:%s' % vals) logging.info('no_bom_copy_product_id-vals:%s' % vals)
# product_id.active = False # product_id.product_tmpl_id.active = False
return no_bom_copy_product_id return no_bom_copy_product_id
# 根据模型类型默认给模型的长高宽加配置的长度; # @api.onchange('upload_model_file')
@api.onchange('model_type_id') # def onchange_model_file(self):
def add_product_size(self): # for item in self:
if not self.model_type_id: # if len(item.upload_model_file) > 1:
return # raise ValidationError('只允许上传一个文件')
model_type = self.env['sf.model.type'].search( # if item.upload_model_file:
[('id', '=', self.model_type_id.id), ('embryo_tolerance', '=', True)]) # file_attachment_id = item.upload_model_file[0]
if model_type: # item.model_name = file_attachment_id.name
self.model_long = self.model_long + 1 # # 附件路径
self.model_width = self.model_width + 1 # report_path = file_attachment_id._full_path(file_attachment_id.store_fname)
self.model_height = self.model_width + 1 # shapes = read_step_file(report_path)
else: # output_file = get_resource_path('sf_dlm', 'static/file', 'out.stl')
return # write_stl_file(shapes, output_file, 'binary', 0.03, 0.5)
# # 转化为glb
# output_glb_file = get_resource_path('sf_dlm', 'static/file', 'out.glb')
# util_path = get_resource_path('sf_dlm', 'static/util')
# cmd = 'python %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file)
# os.system(cmd)
# # 转base64
# with open(output_glb_file, 'rb') as fileObj:
# image_data = fileObj.read()
# base64_data = base64.b64encode(image_data)
# item.model_file = base64_data
class ResMrpBom(models.Model): class ResMrpBom(models.Model):
@@ -207,8 +256,6 @@ class ResMrpBom(models.Model):
# 匹配bom # 匹配bom
def get_bom(self, product): def get_bom(self, product):
logging.info('get_bom-product:%s' % product)
logging.info('get_bom-product:%s' % product.materials_type_id.id)
embryo_has = self.env['product.product'].search( embryo_has = self.env['product.product'].search(
[('categ_id.type', '=', '胚料'), ('materials_type_id', '=', product.materials_type_id.id), [('categ_id.type', '=', '胚料'), ('materials_type_id', '=', product.materials_type_id.id),
('length', '>', product.length), ('width', '>', product.width), ('length', '>', product.length), ('width', '>', product.width),
@@ -220,7 +267,7 @@ class ResMrpBom(models.Model):
logging.info('get_bom-vals:%s' % embryo_has) logging.info('get_bom-vals:%s' % embryo_has)
if embryo_has: if embryo_has:
rate_of_waste = ((embryo_has.volume - product.model_volume) % embryo_has.volume) * 100 rate_of_waste = ((embryo_has.volume - product.model_volume) % embryo_has.volume) * 100
if rate_of_waste >= 20: if rate_of_waste <= 20:
return embryo_has return embryo_has
else: else:
return return

BIN
sf_dlm/static/file/out.glb Normal file

Binary file not shown.

BIN
sf_dlm/static/file/out.stl Normal file

Binary file not shown.

View File

@@ -0,0 +1,277 @@
import os
def stl_to_gltf(binary_stl_path, out_path, is_binary):
import struct
gltf2 = '''
{
"scenes" : [
{
"nodes" : [ 0 ]
}
],
"nodes" : [
{
"mesh" : 0
}
],
"meshes" : [
{
"primitives" : [ {
"attributes" : {
"POSITION" : 1
},
"indices" : 0
} ]
}
],
"buffers" : [
{
%s
"byteLength" : %d
}
],
"bufferViews" : [
{
"buffer" : 0,
"byteOffset" : 0,
"byteLength" : %d,
"target" : 34963
},
{
"buffer" : 0,
"byteOffset" : %d,
"byteLength" : %d,
"target" : 34962
}
],
"accessors" : [
{
"bufferView" : 0,
"byteOffset" : 0,
"componentType" : 5125,
"count" : %d,
"type" : "SCALAR",
"max" : [ %d ],
"min" : [ 0 ]
},
{
"bufferView" : 1,
"byteOffset" : 0,
"componentType" : 5126,
"count" : %d,
"type" : "VEC3",
"min" : [%f, %f, %f],
"max" : [%f, %f, %f]
}
],
"asset" : {
"version" : "2.0"
}
}
'''
header_bytes = 80
unsigned_long_int_bytes = 4
float_bytes = 4
vec3_bytes = 4 * 3
spacer_bytes = 2
num_vertices_in_face = 3
vertices = {}
indices = []
if not is_binary:
out_bin = os.path.join(out_path, "out.bin")
out_gltf = os.path.join(out_path, "out.gltf")
else:
out_bin = out_path
unpack_face = struct.Struct("<12fH").unpack
face_bytes = float_bytes*12 + 2
with open(path_to_stl, "rb") as f:
f.seek(header_bytes) # skip 80 bytes headers
num_faces_bytes = f.read(unsigned_long_int_bytes)
number_faces = struct.unpack("<I", num_faces_bytes)[0]
# the vec3_bytes is for normal
stl_assume_bytes = header_bytes + unsigned_long_int_bytes + number_faces * (vec3_bytes*3 + spacer_bytes + vec3_bytes)
assert stl_assume_bytes == os.path.getsize(path_to_stl), "stl is not binary or ill formatted"
minx, maxx = [9999999, -9999999]
miny, maxy = [9999999, -9999999]
minz, maxz = [9999999, -9999999]
vertices_length_counter = 0
data = struct.unpack("<" + "12fH"*number_faces, f.read())
len_data = len(data)
for i in range(0, len_data, 13):
for j in range(3, 12, 3):
x, y, z = data[i+j:i+j+3]
x = int(x*100000)/100000
y = int(y*100000)/100000
z = int(z*100000)/100000
tuple_xyz = (x, y, z);
try:
indices.append(vertices[tuple_xyz])
except KeyError:
vertices[tuple_xyz] = vertices_length_counter
vertices_length_counter += 1
indices.append(vertices[tuple_xyz])
if x < minx: minx = x
if x > maxx: maxx = x
if y < miny: miny = y
if y > maxy: maxy = y
if z < minz: minz = z
if z > maxz: maxz = z
# f.seek(spacer_bytes, 1) # skip the spacer
number_vertices = len(vertices)
vertices_bytelength = number_vertices * vec3_bytes # each vec3 has 3 floats, each float is 4 bytes
unpadded_indices_bytelength = number_vertices * unsigned_long_int_bytes
out_number_vertices = len(vertices)
out_number_indices = len(indices)
unpadded_indices_bytelength = out_number_indices * unsigned_long_int_bytes
indices_bytelength = (unpadded_indices_bytelength + 3) & ~3
out_bin_bytelength = vertices_bytelength + indices_bytelength
if is_binary:
out_bin_uir = ""
else:
out_bin_uir = '"uri": "out.bin",'
gltf2 = gltf2 % ( out_bin_uir,
#buffer
out_bin_bytelength,
# bufferViews[0]
indices_bytelength,
# bufferViews[1]
indices_bytelength,
vertices_bytelength,
# accessors[0]
out_number_indices,
out_number_vertices - 1,
# accessors[1]
out_number_vertices,
minx, miny, minz,
maxx, maxy, maxz
)
glb_out = bytearray()
if is_binary:
gltf2 = gltf2.replace(" ", "")
gltf2 = gltf2.replace("\n", "")
scene = bytearray(gltf2.encode())
scene_len = len(scene)
padded_scene_len = (scene_len + 3) & ~3
body_offset = padded_scene_len + 12 + 8
file_len = body_offset + out_bin_bytelength + 8
# 12-byte header
glb_out.extend(struct.pack('<I', 0x46546C67)) # magic number for glTF
glb_out.extend(struct.pack('<I', 2))
glb_out.extend(struct.pack('<I', file_len))
# chunk 0
glb_out.extend(struct.pack('<I', padded_scene_len))
glb_out.extend(struct.pack('<I', 0x4E4F534A)) # magic number for JSON
glb_out.extend(scene)
while len(glb_out) < body_offset:
glb_out.extend(b' ')
# chunk 1
glb_out.extend(struct.pack('<I', out_bin_bytelength))
glb_out.extend(struct.pack('<I', 0x004E4942)) # magin number for BIN
# print('<%dI' % len(indices))
# print(struct.pack('<%dI' % len(indices), *indices))
glb_out.extend(struct.pack('<%dI' % len(indices), *indices))
for i in range(indices_bytelength - unpadded_indices_bytelength):
glb_out.extend(b' ')
vertices = dict((v, k) for k,v in vertices.items())
# glb_out.extend(struct.pack('f',
# print([each_v for vertices[v_counter] for v_counter in range(number_vertices)]) # magin number for BIN
vertices = [vertices[i] for i in range(number_vertices)]
flatten = lambda l: [item for sublist in l for item in sublist]
# for v_counter in :
# v_3f = vertices[v_counter]
# all_floats_in_vertices.append(v_3f[0])
# all_floats_in_vertices.append(v_3f[1])
# all_floats_in_vertices.append(v_3f[2])
# for v_counter in range(number_vertices):
glb_out.extend(struct.pack('%df' % number_vertices*3, *flatten(vertices))) # magin number for BIN
# for v_counter in range(number_vertices):
# glb_out.extend(struct.pack('3f', *vertices[v_counter])) # magin number for BIN
# for (v_x, v_y, v_z), _ in sorted(vertices.items(), key=lambda x: x[1]):
# glb_out.extend(struct.pack('3f', v_x, v_y, v_z)) # magin number for BIN
# # glb_out.extend(struct.pack('f', v_y)) # magin number for BIN
# # glb_out.extend(struct.pack('f', v_z)) # magin number for BIN
with open(out_bin, "wb") as out:
out.write(glb_out)
if not is_binary:
with open(out_gltf, "w") as out:
out.write(gltf2)
print("Done! Exported to %s" %out_path)
if __name__ == '__main__':
import sys
if len(sys.argv) < 3:
print("use it like python3 stl_to_gltf.py /path/to/stl /path/to/gltf/folder")
print("or python3 stl_to_gltf.py /path/to/stl /path/to/glb/file -b")
sys.exit(1)
path_to_stl = sys.argv[1]
out_path = sys.argv[2]
if len(sys.argv) > 3:
is_binary = True
else:
is_binary = False
if out_path.lower().endswith(".glb"):
print("Use binary mode since output file has glb extension")
is_binary = True
else:
if is_binary:
print("output file should have glb extension but not %s", out_path)
if not os.path.exists(path_to_stl):
print("stl file does not exists %s" % path_to_stl)
if not is_binary:
if not os.path.isdir(out_path):
os.mkdir(out_path)
stl_to_gltf(path_to_stl, out_path, is_binary)

View File

@@ -6,7 +6,13 @@
<field name="model">product.template</field> <field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/> <field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<!-- <field name="image_1920" position="replace">-->
<!-- <field name="upload_model_file" required="True"-->
<!-- widget='many2many_binary'/>-->
<!-- </field>-->
<field name="invoice_policy" position="after"> <field name="invoice_policy" position="after">
<field name="model_file" required="True" widget="model_viewer"/>
<field name="materials_id" string="材料"/> <field name="materials_id" string="材料"/>
<field name="materials_type_id" string="型号" <field name="materials_type_id" string="型号"
domain="[('materials_id', '=', materials_id)]"/> domain="[('materials_id', '=', materials_id)]"/>
@@ -101,8 +107,8 @@
<field name="inherit_id" ref="mrp.mrp_bom_form_view"/> <field name="inherit_id" ref="mrp.mrp_bom_form_view"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="subcontractor_ids" position="replace"> <field name="subcontractor_ids" position="replace">
<field name="subcontractor_id" widget="many2one_tags" readonly="1" <field name="subcontractor_id"
attrs="{'invisible':[('type', 'in', ['normal','phantom'])]}"/> attrs="{'invisible': [('type', '!=', 'subcontract')], 'required': [('type', '=', 'subcontract')]}"/>
</field> </field>
</field> </field>
</record> </record>

View File

@@ -17,8 +17,8 @@
'report/tray_report.xml', 'report/tray_report.xml',
'views/mrp_maintenance_views.xml', 'views/mrp_maintenance_views.xml',
'views/mrp_routing_workcenter_view.xml', 'views/mrp_routing_workcenter_view.xml',
'views/mrp_workorder_view.xml',
'views/mrp_workcenter_views.xml', 'views/mrp_workcenter_views.xml',
'views/mrp_workorder_view.xml',
'views/tray_view.xml', 'views/tray_view.xml',
'views/model_type_view.xml', 'views/model_type_view.xml',

View File

@@ -6,6 +6,9 @@ from . import mrp_routing_workcenter
from . import mrp_workorder from . import mrp_workorder
from . import model_type from . import model_type
from . import stock from . import stock
from . import res_user

View File

@@ -2,6 +2,9 @@
from odoo import api, fields, models,_ from odoo import api, fields, models,_
class resProduct(models.Model):
_inherit = 'product.template'
model_file = fields.Binary('模型文件')
class MrpProduction(models.Model): class MrpProduction(models.Model):
_inherit = 'mrp.production' _inherit = 'mrp.production'
@@ -10,6 +13,7 @@ class MrpProduction(models.Model):
tray_ids = fields.One2many('sf.tray', 'production_id', string="托盘") tray_ids = fields.One2many('sf.tray', 'production_id', string="托盘")
maintenance_count = fields.Integer(compute='_compute_maintenance_count', string="Number of maintenance requests") maintenance_count = fields.Integer(compute='_compute_maintenance_count', string="Number of maintenance requests")
request_ids = fields.One2many('maintenance.request', 'production_id') request_ids = fields.One2many('maintenance.request', 'production_id')
model_file = fields.Binary('模型文件', related='product_id.model_file')
@api.depends('request_ids') @api.depends('request_ids')
def _compute_maintenance_count(self): def _compute_maintenance_count(self):

View File

@@ -7,6 +7,8 @@ class ResWorkcenter(models.Model):
_inherit = "mrp.workcenter" _inherit = "mrp.workcenter"
machine_tool_id = fields.Many2one('sf.machine_tool', '机床') machine_tool_id = fields.Many2one('sf.machine_tool', '机床')
users_ids = fields.Many2many("res.users", 'users_workcenter')
equipment_ids = fields.One2many( equipment_ids = fields.One2many(
'maintenance.equipment', 'workcenter_id', string="Maintenance Equipment", 'maintenance.equipment', 'workcenter_id', string="Maintenance Equipment",
check_company=True) check_company=True)

View File

@@ -4,6 +4,7 @@ import math
import requests import requests
import logging import logging
import base64 import base64
import hashlib
# import subprocess # import subprocess
from datetime import datetime from datetime import datetime
from dateutil.relativedelta import relativedelta from dateutil.relativedelta import relativedelta
@@ -19,6 +20,7 @@ class ResMrpWorkOrder(models.Model):
_order = 'sequence' _order = 'sequence'
workcenter_id = fields.Many2one('mrp.workcenter', required=False) workcenter_id = fields.Many2one('mrp.workcenter', required=False)
users_ids = fields.Many2many("res.users", 'users_workorder', related="workcenter_id.users_ids")
processing_panel = fields.Char('加工面') processing_panel = fields.Char('加工面')
sequence = fields.Integer(string='工序') sequence = fields.Integer(string='工序')
routing_type = fields.Selection([ routing_type = fields.Selection([
@@ -29,6 +31,26 @@ class ResMrpWorkOrder(models.Model):
('后置三元质量检测', '后置三元质量检测'), ('后置三元质量检测', '后置三元质量检测'),
('解除装夹', '解除装夹'), ('解除装夹', '解除装夹'),
], string="工序类型") ], string="工序类型")
@api.onchange('users_ids')
def get_user_permissions(self):
uid = self.env.uid
for workorder in self:
if workorder.users_ids:
list_user_id = []
for item in workorder.users_ids:
list_user_id.append(item.id)
if uid in list_user_id:
workorder.user_permissions = True
else:
workorder.user_permissions = False
else:
workorder.user_permissions = False
user_permissions = fields.Boolean('用户权限', compute='get_user_permissions')
programming_no = fields.Char('编程单号')
work_state = fields.Char('业务状态')
programming_state = fields.Char('编程状态')
cnc_worksheet = fields.Binary( cnc_worksheet = fields.Binary(
'工作指令', readonly=True) '工作指令', readonly=True)
material_center_point = fields.Char(string='配料中心点') material_center_point = fields.Char(string='配料中心点')
@@ -104,7 +126,11 @@ class ResMrpWorkOrder(models.Model):
print("(%.2f,%.2f)" % (x, y)) print("(%.2f,%.2f)" % (x, y))
self.material_center_point = ("(%.2f,%.2f,%.2f)" % (x, y, z)) self.material_center_point = ("(%.2f,%.2f,%.2f)" % (x, y, z))
self.X_deviation_angle = jdz self.X_deviation_angle = jdz
return self.material_center_point # 将补偿值写入CNC加工工单
workorder = self.env['mrp.workorder'].browse(self.ids)
work = workorder.production_id.workorder_ids
work.compensation_value_x = eval(self.material_center_point)[0]
work.compensation_value_y = eval(self.material_center_point)[1]
def json_workorder_str(self, k, production, route): def json_workorder_str(self, k, production, route):
workorders_values_str = [0, '', { workorders_values_str = [0, '', {
@@ -114,6 +140,7 @@ class ResMrpWorkOrder(models.Model):
'name': route.route_workcenter_id.name, 'name': route.route_workcenter_id.name,
'processing_panel': k, 'processing_panel': k,
'routing_type': route.routing_type, 'routing_type': route.routing_type,
'work_state': '' if not route.routing_type == '获取CNC加工程序' else '待发起',
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids), 'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids),
'date_planned_start': False, 'date_planned_start': False,
'date_planned_finished': False, 'date_planned_finished': False,
@@ -231,6 +258,9 @@ class ResMrpWorkOrder(models.Model):
else: else:
return True return True
# def fetchCNCing(self):
# return None
# cnc程序获取 # cnc程序获取
def fetchCNC(self): def fetchCNC(self):
try: try:
@@ -280,12 +310,21 @@ class ResMrpWorkOrder(models.Model):
self.write( self.write(
{'programming_no': ret['programming_no'], 'programming_state': '编程中', 'work_state': '编程中'}) {'programming_no': ret['programming_no'], 'programming_state': '编程中', 'work_state': '编程中'})
else: else:
logging.info('fetchCNC-error:%s' % ret['message']) logging.info('fetchCNC-error:%s' % cnc)
raise UserError(ret['message']) raise UserError('行业资源库解析失败')
except Exception as e: except Exception as e:
logging.info('fetchCNC error:%s' % e) logging.info('fetchCNC error:%s' % e)
raise UserError(e) raise UserError(e)
# return {
# 'name': _("工单"),
# 'view_mode': 'form',
# 'res_model': 'mrp.workorder',
# 'res_id': self.id,
# 'type': 'ir.actions.act_window',
# 'target': 'new'
# }
def json_workorder_str1(self, k, production, route): def json_workorder_str1(self, k, production, route):
workorders_values_str = [0, '', { workorders_values_str = [0, '', {
'product_uom_id': production.product_uom_id.id, 'product_uom_id': production.product_uom_id.id,
@@ -294,6 +333,7 @@ class ResMrpWorkOrder(models.Model):
'name': route.route_workcenter_id.name, 'name': route.route_workcenter_id.name,
'processing_panel': k, 'processing_panel': k,
'routing_type': route.routing_type, 'routing_type': route.routing_type,
'work_state': '' if not route.routing_type == '获取CNC加工程序' else '待发起',
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids), 'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids),
'date_planned_start': False, 'date_planned_start': False,
'date_planned_finished': False, 'date_planned_finished': False,
@@ -367,49 +407,78 @@ class CNCprocessing(models.Model):
depth_of_processing_z = fields.Char('加工深度(Z)') depth_of_processing_z = fields.Char('加工深度(Z)')
cutting_tool_extension_length = fields.Char('刀具伸出长度') cutting_tool_extension_length = fields.Char('刀具伸出长度')
cutting_tool_handle_type = fields.Char('刀柄型号') cutting_tool_handle_type = fields.Char('刀柄型号')
estimated_processing_time = fields.Datetime('预计加工时间') estimated_processing_time = fields.Char('预计加工时间')
remark = fields.Text('备注') remark = fields.Text('备注')
workorder_id = fields.Many2one('mrp.workorder', string="工单") workorder_id = fields.Many2one('mrp.workorder', string="工单")
# mrs下发编程单创建CNC加工 # mrs下发编程单创建CNC加工
def cnc_processing_create(self, obj): def cnc_processing_create(self, cnc_workorder, ret):
workorder = self.env['mrp.workorder'].search([('production_id.name', '=', obj['manufacturing_order_no']), for obj in ret['programming_list']:
('processing_panel', '=', obj['processing_panel']), workorder = self.env['mrp.workorder'].search([('production_id.name', '=', ret['production_order_no']),
('routing_type', '=', 'CNC加工')]) ('processing_panel', '=', obj['processing_panel']),
vals = { ('routing_type', '=', 'CNC加工')])
'workorder_id': workorder.id, cnc_processing = self.env['sf.cnc.processing'].create({
'sequence_number': obj['sequence_number'], 'workorder_id': workorder.id,
'program_name': obj['program_name'], 'sequence_number': obj['sequence_number'],
'cutting_tool_name': obj['cutting_tool_name'], 'program_name': obj['program_name'],
'cutting_tool_no': obj['cutting_tool_no'], 'cutting_tool_name': obj['cutting_tool_name'],
'processing_type': obj['processing_type'], 'cutting_tool_no': obj['cutting_tool_no'],
'margin_x_y': obj['margin_x_y'], 'processing_type': obj['processing_type'],
'margin_z': obj['margin_z'], 'margin_x_y': obj['margin_x_y'],
'depth_of_processing_z': obj['depth_of_processing_z'], 'margin_z': obj['margin_z'],
'cutting_tool_extension_length': obj['cutting_tool_extension_length'], 'depth_of_processing_z': obj['depth_of_processing_z'],
'cutting_tool_handle_type': obj['cutting_tool_handle_type'], 'cutting_tool_extension_length': obj['cutting_tool_extension_length'],
'estimated_processing_time': obj['estimated_processing_time'], 'cutting_tool_handle_type': obj['cutting_tool_handle_type'],
'remark': obj['remark'] 'estimated_processing_time': obj['estimated_processing_time'],
} 'remark': obj['remark']
return self.env['sf.cnc.processing'].create(vals) })
self.get_cnc_processing_file(ret['folder_name'], cnc_processing)
cnc_workorder.state = 'done'
cnc_workorder.work_state = '已编程'
cnc_workorder.programming_state = '已编程'
cnc_workorder.time_ids.date_end = datetime.now()
def get_cnc_processing_file(self, folder_name, cnc_processing):
logging.info('folder_name:%s' % folder_name)
serverdir = os.path.join('/', folder_name, 'return', cnc_processing.processing_panel)
logging.info('serverdir:%s' % serverdir)
for root, dirs, files in os.walk(server_dir):
for f in files:
logging.info('f:%s' % f)
if os.path.splitext(f)[1] == ".pdf":
full_path = os.path.join(server_dir, root, f)
logging.info('pdf:%s' % full_path)
if full_path != False:
if not cnc_processing.workorder_id.cnc_worksheet:
cnc_processing.workorder_id.cnc_worksheet = base64.b64encode(
open(full_path, 'rb').read())
else:
if cnc_processing.program_name == f.split('.')[0]:
cnc_file_path = os.path.join(server_dir, root, f)
logging.info('cnc_file_path:%s' % cnc_file_path)
cnc_processing.with_user(request.env.ref("base.user_admin")).write_file(cnc_file_path,
cnc_processing)
# 创建附件(nc文件) # 创建附件(nc文件)
def attachment_create(self, name, data): def attachment_create(self, name, data):
attachment = self.env['ir.attachment'].create({ attachment = self.env['ir.attachment'].create({
'datas': base64.b64encode(data), 'datas': base64.b64encode(data),
'type': 'binary', 'type': 'binary',
'public': True,
'description': '程序文件', 'description': '程序文件',
'name': name 'name': name
}) })
return attachment return attachment
# 将FTP的nc文件下载到临时目录 # 将FTP的nc文件下载到临时目录
def download_file_tmp(self, model_code, processing_panel): def download_file_tmp(self, production_no, processing_panel):
remotepath = os.path.join('/', model_code, 'return', processing_panel) remotepath = os.path.join('/', production_no, 'return', processing_panel)
serverdir = os.path.join('/tmp', model_code, 'return', processing_panel) serverdir = os.path.join('/tmp', production_no, 'return', processing_panel)
ftp = FtpController() ftp_resconfig = self.env['res.config.settings'].get_values()
ftp.download_file_tree(remotepath, serverdir) ftp = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']), ftp_resconfig['ftp_user'],
return serverdir ftp_resconfig['ftp_password'])
download_state = ftp.download_file_tree(remotepath, serverdir)
return download_state
# 将nc文件存到attach的datas里 # 将nc文件存到attach的datas里
def write_file(self, nc_file_path, cnc): def write_file(self, nc_file_path, cnc):

View File

@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
from odoo import SUPERUSER_ID, _, api, fields, models, registry
class Users(models.Model):
_inherit = 'res.users'
workcenter_ids = fields.Many2many("mrp.workcenter", 'users_workcenter')

View File

@@ -66,9 +66,12 @@ class StockRule(models.Model):
list2 = [] list2 = []
for item in procurements: for item in procurements:
num = int(item[0].product_qty) num = int(item[0].product_qty)
product = self.env['product.template'].search(
["&", ("name", '=', item[0].product_id.display_name), ('single_manufacturing', '!=', False)]) product = self.env['product.product'].search(
if product: [("id", '=', item[0].product_id.id)])
product_tmpl = self.env['product.template'].search(
["&", ("id", '=', product.product_tmpl_id.id), ('single_manufacturing', "!=", False)])
if product_tmpl:
if num > 1: if num > 1:
for no in range(1, num + 1): for no in range(1, num + 1):
Procurement = namedtuple('Procurement', ['product_id', 'product_qty', Procurement = namedtuple('Procurement', ['product_id', 'product_qty',

View File

@@ -20,6 +20,41 @@ class Tray(models.Model):
def updateTrayState(self): def updateTrayState(self):
if self.workorder_id != False: if self.workorder_id != False:
self.state = '占用' self.state = '占用'
else: else:
self.state = '空闲' self.state = '空闲'

View File

@@ -24,14 +24,16 @@
</field> </field>
</record> </record>
<record id="mrp_workcenter_view_kanban_inherit_workorder" model="ir.ui.view"> <record id="mrp_workcenter_view_kanban_inherit_workorder" model="ir.ui.view">
<field name="name">mrp.workcenter.view.kanban.inherit.mrp.workorder</field> <field name="name">mrp.workcenter.view.kanban.inherit.mrp.workorder</field>
<field name="model">mrp.workcenter</field> <field name="model">mrp.workcenter</field>
<field name="inherit_id" ref="mrp.mrp_workcenter_kanban"/> <field name="inherit_id" ref="mrp.mrp_workcenter_kanban"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<!-- Desktop view --> <!-- Desktop view -->
<xpath expr="//div[@name='o_wo']" position="inside"> <xpath expr="//div[@name='o_wo']" position="inside">
<button class="btn btn-secondary fa fa-desktop" name="action_work_order" type="object" context="{'search_default_ready': 1, 'search_default_progress': 1, 'search_default_pending': 1, 'desktop_list_view': 1, 'search_default_workcenter_id': active_id}" title="Work orders" aria-label="Work orders"/> <button class="btn btn-secondary fa fa-desktop" name="action_work_order" type="object"
context="{'search_default_ready': 1, 'search_default_progress': 1, 'search_default_pending': 1, 'desktop_list_view': 1, 'search_default_workcenter_id': active_id}"
title="Work orders" aria-label="Work orders"/>
</xpath> </xpath>
</field> </field>
</record> </record>
@@ -39,25 +41,46 @@
<!-- override to change the no content image --> <!-- override to change the no content image -->
<record id="mrp.action_work_orders" model="ir.actions.act_window"> <record id="mrp.action_work_orders" model="ir.actions.act_window">
<field name="help" type="html"> <field name="help" type="html">
<p class="o_view_nocontent_workorder"> <p class="o_view_nocontent_workorder">
No work orders to do! No work orders to do!
</p><p> </p>
Work orders are operations to do as part of a manufacturing order. <p>
Operations are defined in the bill of materials or added in the manufacturing order directly. Work orders are operations to do as part of a manufacturing order.
</p><p> Operations are defined in the bill of materials or added in the manufacturing order directly.
Use the table work center control panel to register operations in the shop floor directly. </p>
The tablet provides worksheets for your workers and allow them to scrap products, track time, <p>
launch a maintenance request, perform quality tests, etc. Use the table work center control panel to register operations in the shop floor directly.
</p> The tablet provides worksheets for your workers and allow them to scrap products, track time,
launch a maintenance request, perform quality tests, etc.
</p>
</field>
</record>
<record id="mrp_workcenter_kanban_action1" model="ir.actions.act_window">
<field name="name">Work Centers Overview</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.workcenter</field>
<field name="view_mode">kanban,form</field>
<field name="view_id" ref="mrp.mrp_workcenter_kanban"/>
<field name="search_view_id" ref="mrp.view_mrp_workcenter_search"/>
<field name="domain">[('users_ids','in',uid)]</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create a new work center
</p>
<p>
Manufacturing operations are processed at Work Centers. A Work Center can be composed of
workers and/or machines, they are used for costing, scheduling, capacity planning, etc.
They can be defined via the configuration menu.
</p>
</field> </field>
</record> </record>
<menuitem id="menu_mrp_dashboard" <menuitem id="menu_mrp_dashboard"
name="工作中心概述" name="工作中心概述"
action="mrp.mrp_workcenter_kanban_action" action="mrp_workcenter_kanban_action1"
groups="mrp.group_mrp_routings" groups="mrp.group_mrp_routings"
parent="mrp.menu_mrp_root" parent="mrp.menu_mrp_root"
sequence="5"/> sequence="5"/>
<!-- MRP.WORKCENTER --> <!-- MRP.WORKCENTER -->
<record model="ir.ui.view" id="view_mrp_workcenter_form_inherit_sf"> <record model="ir.ui.view" id="view_mrp_workcenter_form_inherit_sf">
@@ -79,6 +102,9 @@
</field> </field>
</page> </page>
</xpath> </xpath>
<xpath expr="//field[@name='company_id']" position="after">
<field name="users_ids" widget="many2many_tags" string="可操作用户"/>
</xpath>
<xpath expr="//field[@name='alternative_workcenter_ids']" position="after"> <xpath expr="//field[@name='alternative_workcenter_ids']" position="after">
<field name="machine_tool_id"/> <field name="machine_tool_id"/>

View File

@@ -7,10 +7,41 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="name" position="before"> <field name="name" position="before">
<field name="sequence"/> <field name="sequence"/>
<field name='user_permissions'/>
</field> </field>
<field name="name" position="after"> <field name="name" position="after">
<field name="processing_panel"/> <field name="processing_panel"/>
</field> </field>
<xpath expr="//button[@name='button_start']" position="attributes">
<attribute name="attrs">{'invisible': ['|', '|', '|','|', ('production_state','in', ('draft', 'done',
'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel')),
('is_user_working', '!=', False),("user_permissions","=",False)]}
</attribute>
</xpath>
<xpath expr="//button[@name='%(mrp.act_mrp_block_workcenter_wo)d']" position="attributes">
<attribute name="attrs">{'invisible': [("user_permissions","=",False)]} </attribute>
<attribute name="string">停工</attribute>
</xpath>
<xpath expr="//button[@name='action_open_wizard']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<!-- <button name="button_start" type="object" string="Start" class="btn-success"-->
<!-- attrs="{'invisible': ['|', '|', '|', ('production_state','in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel')), ('is_user_working', '!=', False)]}"/>-->
<!-- <button name="button_pending" type="object" string="Pause" class="btn-warning"-->
<!-- attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}"/>-->
<!-- <button name="button_finish" type="object" string="Done" class="btn-success"-->
<!-- attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}"/>-->
<!-- <button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="Block" context="{'default_workcenter_id': workcenter_id}" class="btn-danger"-->
<!-- attrs="{'invisible': ['|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked')]}"/>-->
<!-- <button name="button_unblock" type="object" string="Unblock" context="{'default_workcenter_id': workcenter_id}" class="btn-danger"-->
<!-- attrs="{'invisible': ['|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked')]}"/>-->
<!-- <button name="action_open_wizard" type="object" icon="fa-external-link" class="oe_edit_only"-->
<!-- title="Open Work Order"/>-->
<tree position="attributes">
<attribute name="multi_edit"></attribute>
<attribute name="editable"></attribute>
</tree>
</field> </field>
</record> </record>
@@ -57,10 +88,18 @@
<field name="model">mrp.workorder</field> <field name="model">mrp.workorder</field>
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/> <field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="field[@name='is_user_working']" position="before">
<field name='user_permissions' invisible="1"/>
</xpath>
<xpath expr="//page[last()]" position="after"> <xpath expr="//page[last()]" position="after">
<page string="获取CNC加工程序" attrs='{"invisible": [("routing_type","!=","获取CNC加工程序")]}'> <page string="获取CNC加工程序" attrs='{"invisible": [("routing_type","!=","获取CNC加工程序")]}'>
<div class="col-12 col-lg-6 o_setting_box"> <div class="col-12 col-lg-6 o_setting_box">
<button type="object" class="oe_highlight" name="fetchCNC" string="获取CNC程序代码"/> <div class="col-12 col-lg-6 o_setting_box" style="white-space: nowrap">
<button type="object" class="oe_highlight" name="fetchCNC" string="获取CNC程序代码"
attrs='{"invisible": ["|",("state","!=","progress"),("user_permissions","=",False)]}'/>
<button type="object" class="oe_highlight disabled" name="fetchCNC" string="获取CNC程序代码"
attrs='{"invisible": ["|",("user_permissions","=",False),("programming_no","=",False)]}'/>
</div>
</div> </div>
</page> </page>
@@ -71,12 +110,14 @@
<field name="routing_type" invisible="1"/> <field name="routing_type" invisible="1"/>
<field name="processing_panel" readonly="1"/> <field name="processing_panel" readonly="1"/>
<field name="tray_code"/> <field name="tray_code"/>
<field name="tray_id" readonly="1"/>
</group> </group>
<div class="col-12 col-lg-6 o_setting_box"> <div class="col-12 col-lg-6 o_setting_box">
<button type="object" class="oe_highlight" name="gettray" string="绑定托盘" <button type="object" class="oe_highlight" name="gettray" string="绑定托盘"
attrs='{"invisible": [("production_id","=",False)]}'/> attrs='{"invisible": ["|","|",("tray_id","!=",False),("state","!=","progress"),("production_id","=",False)]}'/>
</div>
</div>
</page> </page>
</xpath> </xpath>
@@ -185,7 +226,8 @@
</div> </div>
<div class="col-12 col-lg-6 o_setting_box"> <div class="col-12 col-lg-6 o_setting_box">
<button type="object" class="oe_highlight" name="getcenter" string="计算定位"/> <button type="object" class="oe_highlight" name="getcenter" string="计算定位"
attrs='{"invisible": ["|","|",("material_center_point","!=",False),("state","!=","progress"),("user_permissions","=",False)]}'/>
</div> </div>
<group> <group>
@@ -222,25 +264,26 @@
<xpath expr="//page[last()]" position="after"> <xpath expr="//page[last()]" position="after">
<page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","后置三元质量检测")]}'> <page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","后置三元质量检测")]}'>
<group> <group>
<field name="test_results" widget="selection" /> <field name="test_results" widget="selection"/>
</group> </group>
<div class="col-12 col-lg-6 o_setting_box"> <div class="col-12 col-lg-6 o_setting_box">
<button type="object" class="oe_highlight" name="recreateManufacturingOrWorkerOrder" <button type="object" class="oe_highlight" name="recreateManufacturingOrWorkerOrder"
string="检测确认"/> string="检测确认" attrs='{"invisible": ["|",("state","!=","progress"),("user_permissions","=",False)]}'/>
</div> </div>
</page> </page>
</xpath> </xpath>
<xpath expr="//page[last()]" position="after"> <xpath expr="//page[last()]" position="after">
<page string="解除装夹" attrs='{"invisible": [("routing_type","!=","解除装夹")]}'> <page string="解除装夹" attrs='{"invisible": [("routing_type","!=","解除装夹")]}'>
<div class="col-12 col-lg-6 o_setting_box"> <div class="col-12 col-lg-6 o_setting_box">
<button type="object" class="oe_highlight" name="unbindtray" string="解除装夹"/> <button type="object" class="oe_highlight" name="unbindtray" string="解除装夹"
</div> attrs='{"invisible": ["|",("state","!=","progress"),("user_permissions","=",False)]}'/>
<div class="col-12 col-lg-6 o_setting_box"> </div>
<button type="action" class="oe_highlight" name="sf_manufacturing.label_sf_tray_code1" <div class="col-12 col-lg-6 o_setting_box">
string="打印标签"/> <button type="action" class="oe_highlight" name="sf_manufacturing.label_sf_tray_code1"
</div> string="打印标签" attrs='{"invisible": ["|",("state","!=","progress"),("user_permissions","=",False)]}'/>
</div>
</page> </page>
</xpath> </xpath>

BIN
sf_manufacturing1.zip Normal file

Binary file not shown.

View File

@@ -32,20 +32,32 @@ class Sf_Mrs_Connect(http.Controller):
logging.info('model_code:%s' % model_code) logging.info('model_code:%s' % model_code)
server_dir = cnc.with_user(request.env.ref("base.user_admin")).download_file_tmp(model_code, server_dir = cnc.with_user(request.env.ref("base.user_admin")).download_file_tmp(model_code,
processing_panel) processing_panel)
cnc_file_path = os.path.join('/', server_dir, cnc.program_name + '.nc') # cnc_file_path = os.path.join('/', server_dir, cnc.program_name + '.nc')
logging.info('cnc_file_path:%s' % cnc_file_path) # logging.info('cnc_file_path:%s' % cnc_file_path)
cnc.with_user(request.env.ref("base.user_admin")).write_file(cnc_file_path, cnc) # cnc.with_user(request.env.ref("base.user_admin")).write_file(cnc_file_path, cnc)
logging.info('get_cnc_processing_create:%s' % '111111111111111') logging.info('server_dir:%s' % server_dir)
# for root, dirs, files in os.walk(server_dir): for root, dirs, files in os.walk(server_dir):
# for f in files: for f in files:
# if os.path.splitext(f)[1] == ".pdf": logging.info('f:%s' % f)
# pdf_path = os.path.splitext(file)[1] + '.PDF' logging.info('f[0]:%s' % f.split('.')[0])
# if os.path.splitext(f)[1] == ".pdf":
# if pdf_path != False: full_path = os.path.join(server_dir, root, f)
# if not cnc.workorder_id.cnc_worksheet: logging.info('pdf:%s' % full_path)
# cnc.workorder_id.cnc_worksheet = base64.b64encode(open(cnc_pdf_path, 'rb').read()) if full_path != False:
# else: if not cnc.workorder_id.cnc_worksheet:
# logging.info('break:%s' % 'break') cnc.workorder_id.cnc_worksheet = base64.b64encode(open(full_path, 'rb').read())
# break else:
logging.info('break:%s' % 'break')
continue
else:
logging.info('cnc.program_name:%s' % cnc.program_name)
if cnc.program_name == f.split('.')[0]:
logging.info('f[0]:%s' % f[0])
cnc_file_path = os.path.join(server_dir, root, f)
logging.info('cnc_file_path:%s' % cnc_file_path)
cnc.with_user(request.env.ref("base.user_admin")).write_file(cnc_file_path, cnc)
else:
continue
except Exception as e: except Exception as e:
logging.info('get_cnc_processing_create error:%s' % e) logging.info('get_cnc_processing_create error:%s' % e)

View File

@@ -25,15 +25,16 @@ class FtpController():
# 下载目录下的文件 # 下载目录下的文件
def download_file_tree(self, target_dir, serverdir): def download_file_tree(self, target_dir, serverdir):
self.ftp.cwd(target_dir) # 切换工作路径
if not os.path.exists(serverdir): if not os.path.exists(serverdir):
os.makedirs(serverdir) os.makedirs(serverdir)
remotenames = self.ftp.nlst() self.ftp.cwd(target_dir) # 切换工作路径
for file in remotenames: remotenames = self.ftp.nlst()
server = os.path.join(serverdir, file) for file in remotenames:
if file.find(".") != -1: server = os.path.join(serverdir, file)
self.download_file(server, file) if file.find(".") != -1:
return self.download_file(server, file)
else:
return
# 下载指定目录下的指定文件 # 下载指定目录下的指定文件
def download_file(self, serverfile, remotefile): def download_file(self, serverfile, remotefile):

View File

@@ -44,6 +44,7 @@ class ReSaleOrder(models.Model):
product.model_machining_precision, product.model_machining_precision,
product.materials_id.name), product.materials_id.name),
'price_unit': product.list_price, 'price_unit': product.list_price,
# 'route_id': product.route_ids,
'product_uom_qty': item['number'] 'product_uom_qty': item['number']
} }
return self.env['sale.order.line'].create(vals) return self.env['sale.order.line'].create(vals)

View File

@@ -0,0 +1,126 @@
===================
Model viewer widget
===================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
:target: https://github.com/OCA/web/tree/14.0/web_widget_model_viewer
:alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-14-0/web-14-0-web_widget_model_viewer
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/162/14.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
``<model-viewer>`` is a web component that makes rendering interactive 3D models - optionally in AR - easy to do, on as many browsers and devices as possible. ``<model-viewer>`` strives to give you great defaults for rendering quality and performance.
See `source repository <https://github.com/google/model-viewer>`_ and `documentation <https://modelviewer.dev/>`_.
The model to load is a GLTF 2.0 file format.
See `<https://www.khronos.org/gltf/>`_ and GLTF overview:
.. figure:: https://raw.githubusercontent.com/OCA/web/14.0/web_widget_model_viewer/static/img/gltfOverview.png
Many engine developers have already started transitioning to glTF 2.0 to reap performance, portability and quality benefits, including BabylonJS, three.js, Cesium, Sketchfab, and xeogl and instant3Dhub engines. glTF 2.0 is also seeing industry support by companies such as Adobe, Google, Marmoset, Microsoft, NVIDIA, Oculus, UX3D, and more as well as prominent universities such as, University of Pennsylvania and Sapienza University of Rome.
"example" directory contains the GLB file of a chair, that is rendered in the following way:
.. figure:: https://raw.githubusercontent.com/OCA/web/14.0/web_widget_model_viewer/static/img/Eames_Lounge_Chair.gif
**Table of contents**
.. contents::
:local:
Usage
=====
Add ``widget="model_viewer"`` to your binary field in form view. Optionally you can set ``style`` and ``max_upload_size`` (in MB) attributes.
Changelog
=========
14.0.1.0.0 (2021-10-07)
~~~~~~~~~~~~~~~~~~~~~~~
* [MIG] v14
12.0.2.0.0 (2020-07-14)
~~~~~~~~~~~~~~~~~~~~~~~
* [IMP] fullscreen and view redesign
12.0.1.0.0 (2020-07-10)
~~~~~~~~~~~~~~~~~~~~~~~
* Start of the history.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_widget_model_viewer%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
Credits
=======
Authors
~~~~~~~
* TAKOBI
* Openindustry.it
Contributors
~~~~~~~~~~~~
* Lorenzo Battistini (https://takobi.online)
* Andrea Piovesana (https://openindustry.it)
* Marco Colombo (https://phi.technology)
Other credits
~~~~~~~~~~~~~
Chair © Copyright 2020 Shopify Inc., licensed under CC-BY-4.0.
Maintainers
~~~~~~~~~~~
This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
.. |maintainer-eLBati| image:: https://github.com/eLBati.png?size=40px
:target: https://github.com/eLBati
:alt: eLBati
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-eLBati|
This module is part of the `OCA/web <https://github.com/OCA/web/tree/14.0/web_widget_model_viewer>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

View File

@@ -0,0 +1,33 @@
# Copyright 2020 Andrea Piovesana @ Openindustry.it
# Copyright 2020 Lorenzo Battistini @ TAKOBI
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Model viewer widget",
"summary": "Easily display interactive 3D models on the web & in AR",
"version": "14.0.1.0.0",
"development_status": "Beta",
"category": "Web",
"website": "https://github.com/OCA/web",
"author": "TAKOBI, Openindustry.it, Odoo Community Association (OCA)",
"maintainers": ["eLBati"],
"license": "AGPL-3",
"depends": [
"web",
],
'assets': {
'web.assets_qweb': [
"/web_widget_model_viewer/static/src/xml/*.xml",
],
'web.assets_backend': [
'/web_widget_model_viewer/static/src/js/web_widget_model_viewer.js',
],
},
"data": [
"views/assets.xml",
],
"qweb": [
],
"application": False,
"installable": True,
}

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

View File

@@ -0,0 +1,67 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_widget_model_viewer
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2021-02-17 13:45+0000\n"
"Last-Translator: claudiagn <claudia.gargallo@qubiq.es>\n"
"Language-Team: none\n"
"Language: ca\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.3.2\n"
#. module: web_widget_model_viewer
#. openerp-web
#: code:addons/web_widget_model_viewer/static/src/js/web_widget_model_viewer.js:59
#: code:addons/web_widget_model_viewer/static/src/xml/web_widget_model_viewer.xml:26
#, python-format
msgid "3D model"
msgstr "Model 3D"
#. module: web_widget_model_viewer
#. openerp-web
#: code:addons/web_widget_model_viewer/static/src/xml/web_widget_model_viewer.xml:8
#, python-format
msgid "Clear"
msgstr "Clar"
#. module: web_widget_model_viewer
#. openerp-web
#: code:addons/web_widget_model_viewer/static/src/js/web_widget_model_viewer.js:59
#, python-format
msgid "Could not display the selected model."
msgstr "No s'ha pogut mostrar el model seleccionat."
#. module: web_widget_model_viewer
#. openerp-web
#: code:addons/web_widget_model_viewer/static/src/xml/web_widget_model_viewer.xml:7
#, python-format
msgid "Edit"
msgstr "Editar"
#. module: web_widget_model_viewer
#. openerp-web
#: code:addons/web_widget_model_viewer/static/src/xml/web_widget_model_viewer.xml:28
#, python-format
msgid "Fullscreen"
msgstr "Pantalla completa"
#. module: web_widget_model_viewer
#. openerp-web
#: code:addons/web_widget_model_viewer/static/src/xml/web_widget_model_viewer.xml:10
#, python-format
msgid "Uploading..."
msgstr "Pujant..."
#. module: web_widget_model_viewer
#. openerp-web
#: code:addons/web_widget_model_viewer/static/src/xml/web_widget_model_viewer.xml:28
#, python-format
msgid "View fullscreen"
msgstr "Veure pantalla completa"

View File

@@ -0,0 +1,67 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_widget_model_viewer
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2020-09-16 14:00+0000\n"
"Last-Translator: claudiagn <claudia.gargallo@qubiq.es>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 3.10\n"
#. module: web_widget_model_viewer
#. openerp-web
#: code:addons/web_widget_model_viewer/static/src/js/web_widget_model_viewer.js:59
#: code:addons/web_widget_model_viewer/static/src/xml/web_widget_model_viewer.xml:26
#, python-format
msgid "3D model"
msgstr "Modelo 3D"
#. module: web_widget_model_viewer
#. openerp-web
#: code:addons/web_widget_model_viewer/static/src/xml/web_widget_model_viewer.xml:8
#, python-format
msgid "Clear"
msgstr "Claro"
#. module: web_widget_model_viewer
#. openerp-web
#: code:addons/web_widget_model_viewer/static/src/js/web_widget_model_viewer.js:59
#, python-format
msgid "Could not display the selected model."
msgstr "No se pudo mostrar el modelo seleccionado."
#. module: web_widget_model_viewer
#. openerp-web
#: code:addons/web_widget_model_viewer/static/src/xml/web_widget_model_viewer.xml:7
#, python-format
msgid "Edit"
msgstr "Editar"
#. module: web_widget_model_viewer
#. openerp-web
#: code:addons/web_widget_model_viewer/static/src/xml/web_widget_model_viewer.xml:28
#, python-format
msgid "Fullscreen"
msgstr "Pantalla completa"
#. module: web_widget_model_viewer
#. openerp-web
#: code:addons/web_widget_model_viewer/static/src/xml/web_widget_model_viewer.xml:10
#, python-format
msgid "Uploading..."
msgstr "Subiendo..."
#. module: web_widget_model_viewer
#. openerp-web
#: code:addons/web_widget_model_viewer/static/src/xml/web_widget_model_viewer.xml:28
#, python-format
msgid "View fullscreen"
msgstr "Ver pantalla completa"

View File

@@ -0,0 +1,65 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_widget_model_viewer
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
#. module: web_widget_model_viewer
#. openerp-web
#: code:addons/web_widget_model_viewer/static/src/js/web_widget_model_viewer.js:59
#: code:addons/web_widget_model_viewer/static/src/xml/web_widget_model_viewer.xml:26
#, python-format
msgid "3D model"
msgstr ""
#. module: web_widget_model_viewer
#. openerp-web
#: code:addons/web_widget_model_viewer/static/src/xml/web_widget_model_viewer.xml:8
#, python-format
msgid "Clear"
msgstr ""
#. module: web_widget_model_viewer
#. openerp-web
#: code:addons/web_widget_model_viewer/static/src/js/web_widget_model_viewer.js:59
#, python-format
msgid "Could not display the selected model."
msgstr ""
#. module: web_widget_model_viewer
#. openerp-web
#: code:addons/web_widget_model_viewer/static/src/xml/web_widget_model_viewer.xml:7
#, python-format
msgid "Edit"
msgstr ""
#. module: web_widget_model_viewer
#. openerp-web
#: code:addons/web_widget_model_viewer/static/src/xml/web_widget_model_viewer.xml:28
#, python-format
msgid "Fullscreen"
msgstr ""
#. module: web_widget_model_viewer
#. openerp-web
#: code:addons/web_widget_model_viewer/static/src/xml/web_widget_model_viewer.xml:10
#, python-format
msgid "Uploading..."
msgstr ""
#. module: web_widget_model_viewer
#. openerp-web
#: code:addons/web_widget_model_viewer/static/src/xml/web_widget_model_viewer.xml:28
#, python-format
msgid "View fullscreen"
msgstr ""

View File

@@ -0,0 +1,3 @@
* Lorenzo Battistini (https://takobi.online)
* Andrea Piovesana (https://openindustry.it)
* Marco Colombo (https://phi.technology)

View File

@@ -0,0 +1 @@
Chair © Copyright 2020 Shopify Inc., licensed under CC-BY-4.0.

View File

@@ -0,0 +1,15 @@
``<model-viewer>`` is a web component that makes rendering interactive 3D models - optionally in AR - easy to do, on as many browsers and devices as possible. ``<model-viewer>`` strives to give you great defaults for rendering quality and performance.
See `source repository <https://github.com/google/model-viewer>`_ and `documentation <https://modelviewer.dev/>`_.
The model to load is a GLTF 2.0 file format.
See `<https://www.khronos.org/gltf/>`_ and GLTF overview:
.. figure:: ../static/img/gltfOverview.png
Many engine developers have already started transitioning to glTF 2.0 to reap performance, portability and quality benefits, including BabylonJS, three.js, Cesium, Sketchfab, and xeogl and instant3Dhub engines. glTF 2.0 is also seeing industry support by companies such as Adobe, Google, Marmoset, Microsoft, NVIDIA, Oculus, UX3D, and more as well as prominent universities such as, University of Pennsylvania and Sapienza University of Rome.
"example" directory contains the GLB file of a chair, that is rendered in the following way:
.. figure:: ../static/img/Eames_Lounge_Chair.gif

View File

@@ -0,0 +1,14 @@
14.0.1.0.0 (2021-10-07)
~~~~~~~~~~~~~~~~~~~~~~~
* [MIG] v14
12.0.2.0.0 (2020-07-14)
~~~~~~~~~~~~~~~~~~~~~~~
* [IMP] fullscreen and view redesign
12.0.1.0.0 (2020-07-10)
~~~~~~~~~~~~~~~~~~~~~~~
* Start of the history.

View File

@@ -0,0 +1 @@
Add ``widget="model_viewer"`` to your binary field in form view. Optionally you can set ``style`` and ``max_upload_size`` (in MB) attributes.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@@ -0,0 +1,472 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<title>Model viewer widget</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="model-viewer-widget">
<h1 class="title">Model viewer widget</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/14.0/web_widget_model_viewer"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-14-0/web-14-0-web_widget_model_viewer"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/162/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><tt class="docutils literal"><span class="pre">&lt;model-viewer&gt;</span></tt> is a web component that makes rendering interactive 3D models - optionally in AR - easy to do, on as many browsers and devices as possible. <tt class="docutils literal"><span class="pre">&lt;model-viewer&gt;</span></tt> strives to give you great defaults for rendering quality and performance.</p>
<p>See <a class="reference external" href="https://github.com/google/model-viewer">source repository</a> and <a class="reference external" href="https://modelviewer.dev/">documentation</a>.</p>
<p>The model to load is a GLTF 2.0 file format.</p>
<p>See <a class="reference external" href="https://www.khronos.org/gltf/">https://www.khronos.org/gltf/</a> and GLTF overview:</p>
<div class="figure">
<img alt="https://raw.githubusercontent.com/OCA/web/14.0/web_widget_model_viewer/static/img/gltfOverview.png" src="https://raw.githubusercontent.com/OCA/web/14.0/web_widget_model_viewer/static/img/gltfOverview.png" />
</div>
<p>Many engine developers have already started transitioning to glTF 2.0 to reap performance, portability and quality benefits, including BabylonJS, three.js, Cesium, Sketchfab, and xeogl and instant3Dhub engines. glTF 2.0 is also seeing industry support by companies such as Adobe, Google, Marmoset, Microsoft, NVIDIA, Oculus, UX3D, and more as well as prominent universities such as, University of Pennsylvania and Sapienza University of Rome.</p>
<p>“example” directory contains the GLB file of a chair, that is rendered in the following way:</p>
<div class="figure">
<img alt="https://raw.githubusercontent.com/OCA/web/14.0/web_widget_model_viewer/static/img/Eames_Lounge_Chair.gif" src="https://raw.githubusercontent.com/OCA/web/14.0/web_widget_model_viewer/static/img/Eames_Lounge_Chair.gif" />
</div>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#usage" id="id4">Usage</a></li>
<li><a class="reference internal" href="#changelog" id="id5">Changelog</a><ul>
<li><a class="reference internal" href="#id1" id="id6">14.0.1.0.0 (2021-10-07)</a></li>
<li><a class="reference internal" href="#id2" id="id7">12.0.2.0.0 (2020-07-14)</a></li>
<li><a class="reference internal" href="#id3" id="id8">12.0.1.0.0 (2020-07-10)</a></li>
</ul>
</li>
<li><a class="reference internal" href="#bug-tracker" id="id9">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id10">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id11">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id12">Contributors</a></li>
<li><a class="reference internal" href="#other-credits" id="id13">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="id14">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#id4">Usage</a></h1>
<p>Add <tt class="docutils literal"><span class="pre">widget=&quot;model_viewer&quot;</span></tt> to your binary field in form view. Optionally you can set <tt class="docutils literal">style</tt> and <tt class="docutils literal">max_upload_size</tt> (in MB) attributes.</p>
</div>
<div class="section" id="changelog">
<h1><a class="toc-backref" href="#id5">Changelog</a></h1>
<div class="section" id="id1">
<h2><a class="toc-backref" href="#id6">14.0.1.0.0 (2021-10-07)</a></h2>
<ul class="simple">
<li>[MIG] v14</li>
</ul>
</div>
<div class="section" id="id2">
<h2><a class="toc-backref" href="#id7">12.0.2.0.0 (2020-07-14)</a></h2>
<ul class="simple">
<li>[IMP] fullscreen and view redesign</li>
</ul>
</div>
<div class="section" id="id3">
<h2><a class="toc-backref" href="#id8">12.0.1.0.0 (2020-07-10)</a></h2>
<ul class="simple">
<li>Start of the history.</li>
</ul>
</div>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id9">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_widget_model_viewer%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#id10">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id11">Authors</a></h2>
<ul class="simple">
<li>TAKOBI</li>
<li>Openindustry.it</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id12">Contributors</a></h2>
<ul class="simple">
<li>Lorenzo Battistini (<a class="reference external" href="https://takobi.online">https://takobi.online</a>)</li>
<li>Andrea Piovesana (<a class="reference external" href="https://openindustry.it">https://openindustry.it</a>)</li>
<li>Marco Colombo (<a class="reference external" href="https://phi.technology">https://phi.technology</a>)</li>
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#id13">Other credits</a></h2>
<p>Chair © Copyright 2020 Shopify Inc., licensed under CC-BY-4.0.</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id14">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/eLBati"><img alt="eLBati" src="https://github.com/eLBati.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/14.0/web_widget_model_viewer">OCA/web</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 MiB

View File

@@ -0,0 +1,114 @@
// Copyright 2020 Lorenzo Battistini @ TAKOBI
// Copyright 2020 Andrea Piovesana @ Openindustry.it
odoo.define("web_widget_model_viewer.FieldBinaryModelViewer", function (require) {
"use strict";
var BasicFields = require("web.basic_fields");
var core = require("web.core");
var registry = require("web.field_registry");
var session = require("web.session");
var utils = require("web.utils");
var _t = core._t;
var qweb = core.qweb;
var FieldBinaryModelViewer = BasicFields.FieldBinaryFile.extend({
template: "FieldBinaryModelViewer",
events: _.extend({}, BasicFields.FieldBinaryFile.prototype.events, {
click: function () {
if (this.mode === "readonly") {
this.trigger_up("bounce_edit");
}
},
"click #model-viewer-fullscreen": "fullscreen",
}),
supportedFieldTypes: ["binary"],
init: function () {
this._super.apply(this, arguments);
var max_upload_size = this.attrs.max_upload_size;
if (max_upload_size) {
this.max_upload_size = parseInt(max_upload_size, 10) * 1024 * 1024;
} else {
// 250M
this.max_upload_size = 250 * 1024 * 1024;
}
},
_render: function () {
var self = this;
var url = "";
if (this.value) {
if (utils.is_bin_size(this.value)) {
url = session.url("/web/content", {
model: this.model,
id: JSON.stringify(this.res_id),
field: this.name,
});
} else {
url = "data:model/gltf-binary;base64," + this.value;
}
}
var $glb = $(
qweb.render("FieldBinaryModelViewer-glb", {widget: this, url: url})
);
var style = this.attrs.style;
if (style) {
$glb.attr("style", style);
}
this.$("> model-viewer").remove();
this.$el.prepend($glb);
$glb.on("error", function () {
self._clearFile();
$glb.attr("src", "");
self.do_warn(
_t("3D model"),
_t("Could not display the selected model.")
);
});
},
/* eslint-disable complexity */
fullscreen: function (ev) {
var isFullscreenAvailable =
document.fullscreenEnabled ||
document.mozFullScreenEnabled ||
document.webkitFullscreenEnabled ||
document.msFullscreenEnabled ||
false;
var modelViewerElem = ev.target.parentElement.parentElement.parentElement;
if (isFullscreenAvailable) {
var fullscreenElement =
document.fullscreenElement ||
document.mozFullScreenElement ||
document.webkitFullscreenElement ||
document.msFullscreenElement;
if (fullscreenElement) {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) {
/* Firefox */
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
/* Chrome, Safari and Opera */
document.webkitExitFullscreen();
} else if (document.msExitFullscreen) {
/* IE/Edge */
document.msExitFullscreen();
}
} else if (modelViewerElem.requestFullscreen) {
modelViewerElem.requestFullscreen();
} else if (modelViewerElem.mozRequestFullScreen) {
/* Firefox */
modelViewerElem.mozRequestFullScreen();
} else if (modelViewerElem.webkitRequestFullscreen) {
/* Chrome, Safari and Opera */
modelViewerElem.webkitRequestFullscreen();
} else if (modelViewerElem.msRequestFullscreen) {
/* IE/Edge */
modelViewerElem.msRequestFullscreen();
}
} else {
console.error("ERROR : full screen not supported by web browser");
}
},
});
registry.add("model_viewer", FieldBinaryModelViewer);
});

View File

@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<t t-name="FieldBinaryModelViewer">
<div
class="o_field_image"
aria-atomic="true"
style="background-color: #FFFFFF;"
>
<t t-if="widget.mode !== 'readonly'">
<div class="o_form_image_controls">
<button
class="fa fa-pencil float-left o_select_file_button fa-2x"
title="Edit"
aria-label="Edit"
/>
<button
class="fa fa-trash-o float-right o_clear_file_button fa-2x"
title="Clear"
aria-label="Clear"
/>
<span class="o_form_binary_progress">Uploading...</span>
<t t-call="HiddenInputFile">
<t t-set="image_only" t-value="true" />
<t t-set="fileupload_id" t-value="widget.fileupload_id" />
</t>
</div>
</t>
</div>
</t>
<t t-name="FieldBinaryModelViewer-glb">
<model-viewer
t-att-src='url'
t-att-border="widget.readonly ? 0 : 1"
t-att-name="widget.name"
alt="3D model"
auto-rotate="1"
camera-controls="1"
>
<div class="text-center mt-2 mb-2 mr-2">
<span
id="model-viewer-fullscreen"
title="View fullscreen"
role="img"
aria-label="Fullscreen"
>
<i class="fa fa-arrows-alt fa-2x" />
</span>
</div>
<!-- <span style="position: absolute;top: 85%;left: 0%;font-size: 9px;" >-->
<!-- L<t t-esc="widget.recordData.model_length"/>-->
<!-- W:<t t-esc="widget.recordData.model_width"/>-->
<!-- H:<t t-esc="widget.recordData.model_height"/>-->
<!-- V:<t t-esc="widget.recordData.model_volume"/>-->
<!-- </span>-->
</model-viewer>
</t>
</templates>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template
id="web_layout_model_viewer"
name="Web layout Model viewer"
inherit_id="web.layout"
>
<xpath expr="//head" position="inside">
<script
type="module"
src="/web_widget_model_viewer/static/src/lib/model-viewer.min.js"
/>
</xpath>
</template>
<!-- <template-->
<!-- id="assets_backend"-->
<!-- name="web_widget_model_viewer assets"-->
<!-- inherit_id="web.assets_backend"-->
<!-- >-->
<!-- <xpath expr="." position="inside">-->
<!-- <script-->
<!-- type="text/javascript"-->
<!-- src="/web_widget_model_viewer/static/src/js/web_widget_model_viewer.js"-->
<!-- />-->
<!-- </xpath>-->
<!-- </template>-->
</odoo>