更新同步模块
This commit is contained in:
@@ -52,3 +52,8 @@ class MrsProcessingTechnology(models.Model):
|
|||||||
process_encode = fields.Char("编码")
|
process_encode = fields.Char("编码")
|
||||||
production_process_ids = fields.Many2many('mrs.production.process', 'mrs_associated_processes',
|
production_process_ids = fields.Many2many('mrs.production.process', 'mrs_associated_processes',
|
||||||
index=True)
|
index=True)
|
||||||
|
|
||||||
|
|
||||||
|
class ProductTemplate(models.Model):
|
||||||
|
_inherit = 'product.template'
|
||||||
|
_description = '产品'
|
||||||
|
|||||||
@@ -271,10 +271,11 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
<!--产品-->
|
<!--产品-->
|
||||||
|
<!-- <field name="domain">[('materials_model_ids', '!=', False)]</field>-->
|
||||||
<record id="sf_product_template" model="ir.actions.act_window">
|
<record id="sf_product_template" model="ir.actions.act_window">
|
||||||
<field name="name">产品</field>
|
<field name="name">产品</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
<field name="domain">[('materials_model_ids', '!=', False)]</field>
|
|
||||||
<field name="res_model">product.template</field>
|
<field name="res_model">product.template</field>
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="help" type="html">
|
<field name="help" type="html">
|
||||||
@@ -285,19 +286,17 @@
|
|||||||
</field>
|
</field>
|
||||||
|
|
||||||
</record>
|
</record>
|
||||||
<record id="view_product_account_purchase_ok_form" model="ir.ui.view">
|
<!-- <record id="view_product_account_purchase_ok_form" model="ir.ui.view">-->
|
||||||
<field name="name">product.template.materials</field>
|
<!-- <field name="name">product.template.materials</field>-->
|
||||||
<field name="model">product.template</field>
|
<!-- <field name="model">product.template</field>-->
|
||||||
<field name="inherit_id" ref="account.product_template_form_view"/>
|
<!-- <field name="inherit_id" ref="account.product_template_form_view"/>-->
|
||||||
<field name="arch" type="xml">
|
<!-- <field name="arch" type="xml">-->
|
||||||
<field name="name" position="after" >
|
<!-- <field name="name" position="after" >-->
|
||||||
<group>
|
|
||||||
<field name="materials_model_ids" widget="many2many"/>
|
|
||||||
</group>
|
|
||||||
|
|
||||||
</field>
|
|
||||||
</field>
|
<!-- </field>-->
|
||||||
</record>
|
<!-- </field>-->
|
||||||
|
<!-- </record>-->
|
||||||
<record id="view_product_account_purchase_ok_search" model="ir.ui.view">
|
<record id="view_product_account_purchase_ok_search" model="ir.ui.view">
|
||||||
<field name="name">product.template.materials.search</field>
|
<field name="name">product.template.materials.search</field>
|
||||||
<field name="model">product.template</field>
|
<field name="model">product.template</field>
|
||||||
|
|||||||
@@ -1,4 +1,2 @@
|
|||||||
# -*-coding:utf-8-*-
|
# -*-coding:utf-8-*-
|
||||||
from . import models
|
from . import models
|
||||||
|
|
||||||
pengge
|
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
""",
|
""",
|
||||||
'category': 'YZ',
|
'category': 'YZ',
|
||||||
'website': 'https://www.sf.cs.jikimo.com',
|
'website': 'https://www.sf.cs.jikimo.com',
|
||||||
'depends': ['account', 'sf_base'],
|
'depends': ['account', 'sf_base', 'base'],
|
||||||
'data': [
|
'data': [
|
||||||
|
|
||||||
'data/sf_cron.xml'
|
'data/sf_cron.xml'
|
||||||
|
|||||||
@@ -4,13 +4,18 @@ import math
|
|||||||
import requests
|
import requests
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
from datetime import timedelta, datetime
|
from datetime import timedelta, datetime
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
import time
|
||||||
|
import datetime
|
||||||
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
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
MRS = 'https://mrs.cs.jikimo.com'
|
||||||
|
|
||||||
|
|
||||||
class MrsProductionMaterials(models.Model):
|
class MrsProductionMaterials(models.Model):
|
||||||
_inherit = "mrs.production.materials"
|
_inherit = "mrs.production.materials"
|
||||||
@@ -18,9 +23,24 @@ class MrsProductionMaterials(models.Model):
|
|||||||
url = '/api/production_materials/list'
|
url = '/api/production_materials/list'
|
||||||
|
|
||||||
def sync_production_materials(self):
|
def sync_production_materials(self):
|
||||||
str = '定时同步材料资源库'
|
timestamp_str = int(time.time())
|
||||||
|
headers = {'TOKEN': '4130d97c-37be-11ed-84a7-f8b54df29535',
|
||||||
|
'TIMESTAMP': '1663859413',
|
||||||
|
'check_str': 'e840309b4ac386b5b9005dfb85ca9e9eee7149bd'}
|
||||||
|
str = MRS + self.url
|
||||||
print(str)
|
print(str)
|
||||||
return str
|
r = requests.post(str, data=None, json={},headers=headers)
|
||||||
|
r = r.json()
|
||||||
|
data = json.loads(r['result'])
|
||||||
|
if data['status'] == 1:
|
||||||
|
production_materials_list = data['production_materials_list']
|
||||||
|
if production_materials_list:
|
||||||
|
for item in production_materials_list:
|
||||||
|
port = self.env['mrs.production.materials'].search([('materials_no', '=', item.materials_no)])
|
||||||
|
if not port:
|
||||||
|
port = item
|
||||||
|
else:
|
||||||
|
return "访问失败"
|
||||||
|
|
||||||
|
|
||||||
class MrsMaterialModel(models.Model):
|
class MrsMaterialModel(models.Model):
|
||||||
|
|||||||
Reference in New Issue
Block a user