Skip to content
Snippets Groups Projects
Commit 0eaf31d1 authored by Dani Quilez's avatar Dani Quilez
Browse files

Merge branch 'connect-wp-erp' into 'dev'

Connect wp erp

See merge request !132
parents 2d6f122f f1957673
No related branches found
No related tags found
4 merge requests!138Hotfix setup name error,!134Release v14.0.1.1.6,!132Connect wp erp,!129Draft: Release v14.0.1.1.5
Pipeline #31566 passed
......@@ -70,15 +70,17 @@ class LandingPage(models.Model):
def action_landing_page_status(self):
for record in self:
new_status = "draft" if record.status == "publish" else "publish"
instance_company = self.env['res.company'].search(
[('hierarchy_level', '=', 'instance')])
if instance_company:
username = instance_company.wordpress_db_username
password = instance_company.wordpress_db_password
auth = Authenticate(username, password).authenticate()
token = "Bearer %s" % auth["token"]
landing_page_data = record.to_dict()
landing_page_data["status"] = new_status
landing_page_resource = LandingPageResource(
record.wp_landing_page_id)
landing_page_resource.update(token, landing_page_data)
username = self.company_id.wordpress_db_username
password = self.company_id.wordpress_db_password
auth = Authenticate(username, password).authenticate()
token = "Bearer %s" % auth["token"]
landing_page_data = record.to_dict()
landing_page_data["status"] = new_status
landing_page_resource = LandingPageResource(
record.wp_landing_page_id)
landing_page_resource.update(token, landing_page_data)
record.write({"status": new_status})
record.write({"status": new_status})
......@@ -14,9 +14,10 @@ class LandingService(Component):
CE WP landing page requests
"""
# TODO: This is not restful, we should ask for landing_id directly. Refactor WP before fixing this.
def get(self, _id):
landing_page = self.env['landing.page'].browse(_id)
return self._to_dict(landing_page)
related_company = self.env['res.company'].browse(_id)
return self._to_dict(related_company.landing_page_id)
@staticmethod
def _to_dict(landing_page):
......
......@@ -16,6 +16,7 @@
<h4 style="color:orange;" attrs="{'invisible': [('status','!=','draft')]}">Draft</h4>
</group>
<group>
<field name="wp_landing_page_id" readonly="True"/>
<field name="name"/>
<field name="allow_new_members"/>
<field name="number_of_members"/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment