Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

Showing Error: "[object with reference: partner_id - partner.id] " for function return

Naroči se

Get notified when there's activity on this post

This question has been flagged
1 Odgovori
6703 Prikazi
Avatar
Pawan Kumar Sharma

Hello All,

I create a function for button(Send By SMS)  wizard action in Odoo10. In this function when i return value in the function following error shows on the screen. I also Define button action in sale order inherit file.  

The operation cannot be completed, probably due to the following:
- deletion: you may be trying to delete a record while other records still reference it
- creation/update: a mandatory field is not correctly set

[object with reference: partner_id - partner.id]     

So, What i return instead of code?

My Python and XML Code is Here:

Pythode Code:

import urllib2
import cookielib
from getpass import getpass
import sys
import os
from stat import *

class way2smsBase(models.Model):
_name = "way.base"
_rec_name = "user_name"

user_name = fields.Char(string="UserName", required=True)
password = fields.Char(string="Password", required=True)

class SaleMail(models.TransientModel):
_name = "sale.mail.wizard"
_description = "Sale Mail Wizard"

message = fields.Text(String="Message", size=140)
number = fields.Text(string="Receiver Number", required=True, size=12)
user_acc = fields.Many2one("way.base", 'ACC', required=True)
date_time = fields.Datetime(string="Date & Time", readonly=True)

def sendSms(self):
url = 'http://sunarctechnologies.com'
data = 'username=' + self.user_acc.user_name + '&password=' + self.user_acc.password + '&Submit=Sign+in'
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
opener.addheaders = [('User-Agent',
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120')]
try:
usock = opener.open(url, data)
except IOError:
raise Warning(_("Error pls Check account or mobile number"))
jession_id = str(cj).split('~')[1].split(' ')[0]
send_sms_url = 'http://site24.way2sms.com/smstoss.action?'
send_sms_data = 'ssaction=ss&Token=' + jession_id + '&mobile=' + self.number + '&message=' + self.message + '&msgLen=136'
opener.addheaders = [('Referer', 'http://site25.way2sms.com/sendSMS?Token=' + jession_id)]
try:
sms_sent_page = opener.open(send_sms_url, send_sms_data)
except IOError:
raise Warning(_("Error pls Check account or mobile number"))
self.date_time = str(datetime.now())
raise Warning(_("Message Sent"))

@api.one
@api.constrains('number')
def validatePhonenumber(self):
for phone in self:
if re.match("[0-9]", phone.number) == None:
raise Warning("Mobile number is not valid one, Please specify valid number")
return False
return True

@api.multi
def action_mail_add(self):
rec = self._context.get('active_ids', [])
print "REC"
if rec:
line_values = {'message': self.message,
'number': self.number,
#'user_acc': self.user_acc,
#'date_time': self.date_time,
}
print "Values:", line_values
#return line_values
return self.env['sale.order'].create(line_values)


XML Code:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_sale_mail_wizard" model="ir.ui.view">
<field name="name">SaleMail</field>
<field name="model">sale.mail.wizard</field>
<field name="arch" type="xml">
<form string="Sales mail">
<sheet>
<!--<separator string="SMS"/> -->
<group string="Way2SMS" style="width: 40%%" col="2" colspan="2">
<field name="user_acc"/>
<field name="number"/>
<field name="message"/>
<field name="date_time"/>
</group>
</sheet>
<footer>
<button name="action_mail_add" type="object" String="Ok"
class="oe_highlight" icon="fa-commenting-o" confirm="Are you sure want to send sms"
attrs="{'invisible':[('date_time','!=',False)]}"
help="this button will send an sms "/>
<button string="Cancel" class="btn-default" special="cancel"/>
</footer>
</form>
</field>
</record>

<record id="action_view_sale_mail_wizard" model="ir.actions.act_window">
<field name="name">SaleMail</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.mail.wizard</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</openerp>

XML Code in Sales Order Inherit File:
<?xml version="1.0"?>
<openerp>
<data>
<record model="ir.ui.view" id="custom_order_form">
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="name">Sale Order Pet Form</field>
<field name="model">sale.order</field>
<field name="arch" type="xml">
<data>
<xpath expr="//button[@name='action_quotation_send']" position="after">
<button name="%(action_view_sale_mail_wizard)d" string="Send by SMS" type="action" class="btn-primary"/>
</xpath>
</data>
</field>
</record>
</data>
</openerp>


0
Avatar
Opusti
Avatar
Niyas Raphy (Walnut Software Solutions)
Best Answer

Hi,

The problem is that you didn't give /mention the partner_id in your code while creation of the sale order.

partner_id is the required field in the sale.order model.

So here in this code,

 line_values = {'message': self.message,
                'partner_id' : 1,
'number': self.number,
#'user_acc': self.user_acc,
#'date_time': self.date_time,
}
print "Values:", line_values
return self.env['sale.order'].create(line_values)

Modify the code by adding the partner_id in the creation of sale order.

Thanks

2
Avatar
Opusti
Pawan Kumar Sharma
Avtor

Hello Niyas,

Yes your point work for me.

Thanks

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Prijavi
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now