Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

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

Odoberať

Get notified when there's activity on this post

This question has been flagged
1 Odpoveď
6729 Zobrazenia
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
Zrušiť
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
Zrušiť
Pawan Kumar Sharma
Autor

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!

Registrácia
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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